import hypermedia.video.*;
import java.awt.Rectangle;
OpenCV opencv;
//PImage img;
int efface=0;
int negative=0;
int rond=0;
int trait=0;
int orange=0;
int jaune=0;
int bleu=0;
int vert=0;
int rouge=0;
int violet=0;
int couleur=0;
int reset=1;
int xs = 5;   //factor multiplication
int cw = 320; //webcam width
int ch = 240; //webcam height
void setup() {
size( cw*(xs-1), (ch*xs)-cw );
opencv = new OpenCV(this);
opencv.capture( cw, ch );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT2);    // load the FRONTALFACE description file
}
void draw() {
opencv.read();
if (reset==1){
background(255);
}
if (reset==1){
reset=0;
}
if ((trait==1) && (rond==1) && (couleur==1)){
rond=0;
}
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
noFill();
float th1 = random(155);
float th2 = random(55);
float th3 = random(100);
stroke(th2+200,25);
if (efface==1){
stroke(th2,20);
}
for( int i=0; i<faces.length; i++ ) {
float fw = (faces[i].width)*xs;
float fh = (faces[i].height)*xs;
float fx = ((width-((faces[i].x)*xs))-fw)+(cw/2);
float fy = ((faces[i].y)*xs)-(cw/2);
float fx2 = fx + fw/2;
float fy2 = fy + fh/2;
float cc = (fw/70)*(fw/70);
float cb = (fw/50)*(fw/50);
if(trait==0){
line(fx + fw/2, fy + fh/2,fx + random(fw ), fy + random(fh ) );}
if(couleur==0){
stroke(255,0);
fill(th2*2,th1-th2,th3,10);
if(orange==1){
fill(th2+100,th2+th2,0,10);
}
if(jaune==1){
fill(th2+100,th2+th1,0,10);
}
if(vert==1){
fill(th1,th2+100,0,10);
}
if(bleu==1){
fill(0,50+th1,th2+th2,10);
}
if(rouge==1){
fill(100+th2,th2/2,th3/3,10);
}
if (violet==1){
fill(th2+100,0,th2+th2,10);
}
if (negative==1){
fill(255-th2*2,255-(th1-th2),255-th3,20);
if(orange==1){
fill(155-th2,255-(th2+th2),255,20);
}
if(jaune==1){
fill(155-th2,255-(th2+th1),255,20);
}
if(vert==1){
fill(255-th1,155-th2,255,20);
}
if(bleu==1){
fill(255,205-th1,255-(th2+th2),20);
}
if(rouge==1){
fill(155-th2,255-(th2/2),255-(th3/3),20);
}
if (violet==1){
fill(155-th2,255,255-(th2+th2),20);
}
}
if (efface==1){{
fill(th1+100,th2+th3+100,th3+155,10);
}       if (violet==1){
fill(th2+165,55,th1,20);
}
if(orange==1){
fill(255,th2+70,55,20);
}
if(jaune==1){
fill(255,th2+185,55,20);
}
if(vert==1){
fill(60+th2*2,255,55,20);
}
if(bleu==1){
fill(55,100+th1,255,20);
}
if(rouge==1){
fill(255,th2/2,th3/3,20);
}
if (negative==1){{
fill(155-th1,155-(th2+th3),100-th3,10);
}       if (violet==1){
fill(90-th2,200,255-th1,10);
}
if(orange==1){
fill(0,185-th2,200,10);
}
if(jaune==1){
fill(0,70-th2,200,10);
}
if(vert==1){
fill(195-th2*2,0,200,10);
}
if(bleu==1){
fill(200,155-th1,0,10);
}
if(rouge==1){
fill(0,255-(th2/2),255-(th3/3),10);
}
}
}
ellipse( fx2, fy2, cb, cb  );
}
if (rond==0){
stroke(0,10);
fill(0,33);
if(negative==1){
stroke(255,5);
fill(255,10);
}
if (efface==1){
fill(255,33);
stroke(255,10);
if(negative==1){
stroke(0,5);
fill(0,10);
}
}
ellipse( fx2, fy2, cc, cc  );
}
}
}
//void mousePressed()
void keyPressed() {
if(key==27)
key=0;
if (key == ENTER) {
if (efface==0){
efface=1;
}
else {
efface=0;
}
}
if (key == ' ') {
if (negative==0){
negative=1;
}
else {
negative=0;
}
}
if (key == '!') {
if (trait==0){
trait=1;
}
else {
trait=0;
}
}
if (key == '.') {
if (rond==0){
rond=1;
}
else {
rond=0;
}
}
if (key == BACKSPACE) {
if (couleur==0){
couleur=1;
}
else {
couleur=0;
}
}
if (key == DELETE) {
if (reset==0){
reset=1;
}
else {
reset=0;
}
}
{
if (key == CODED) {
if (keyCode == CONTROL ) {
if (rouge==0){
rouge=1;
jaune=0;
bleu=0;
orange=0;
vert=0;
violet=0;
}
else {
rouge=0;
}
}
if (keyCode == UP) {if (jaune==0){
jaune=1;
rouge=0;
bleu=0;
orange=0;
vert=0;
violet=0;
}
else {
jaune=0;
}
}
if (keyCode == DOWN) {if (bleu==0){
bleu=1;
rouge=0;
jaune=0;
orange=0;
vert=0;
violet=0;
}
else {
bleu=0;
}
}
if (keyCode == LEFT) {if (orange==0){
orange=1;
rouge=0;
jaune=0;
bleu=0;
vert=0;
violet=0;
}
else {
orange=0;
}
}
if (keyCode == RIGHT) {if (vert==0){
vert=1;
rouge=0;
jaune=0;
bleu=0;
orange=0;
violet=0;
}
else {
vert=0;
}
}
if (keyCode == SHIFT) {if (violet==0){
violet=1;
rouge=0;
jaune=0;
bleu=0;
orange=0;
vert=0;
}
else {
violet=0;
}
}
}
if (key == '0') {
efface=0;
negative=0;
trait=0;
rond=0;
couleur=0;
rouge=0;
jaune=0;
bleu=0;
orange=0;
vert=0;
violet=0;
}
}
}

2015

Scroll Upvulputate, Donec ut Nullam nunc ut odio adipiscing commodo neque.