Konradenzo
YaBB Newbies
Offline
Posts: 22
Re: Face detector and JMyron
Reply #12 - May 16th , 2010, 8:05am
Hi I'm not sure if this is the correct place to post this query. I m working on a Final year project at uni using processing. The 2 libraries codes i m using are below.[color=#ff0000] [/color] float mx = 425; float my = 200; float bulge = 0; float leftdist; float rightdist; float fillr; float fillg; float fillb; int cx = (x+(w / 2)); // Centre of Face X Axis int cy = (y+(h / 2)); // // Centre of Face X Axis void setup() { size(640,480); } void draw() { background(0); smooth(); noStroke(); //eye color if(mousePressed) { fillr = 255; fillg = 210; fillb = 0; } else{ fillr = cx/5; fillg = 255; fillb = cy/2; } fill(fillr,fillg,fillb); pushMatrix(); translate(215,200); rotate(PI/8); ellipse(0,0,95,70); popMatrix(); fill(fillr,fillg,fillb); pushMatrix(); translate(425,200); rotate(-PI/8); ellipse(0,0,95,70); popMatrix(); //pupil movement float targetx = constrain(cx, 405, 445);// instead of WHATS THERE use cx and cy float targety = constrain(cy, 195,205); float easing = 0.15; mx = mx + (targetx-mx)*easing; my = my + (targety-my)*easing; fill(0); smooth(); if((mousePressed) && (bulge <= 10)) { bulge += 1; } else{ if(bulge > 0){ bulge -= 1; } } leftdist = dist(cx, cy, mx-210,my); rightdist = dist(cx,cy, mx, my); if((rightdist < 50) || (leftdist < 50 )){ if(bulge > -10){ bulge -= 1; } } else{ if(bulge < 0){ bulge += 1; } } arc(mx,my,25 + bulge,54 + bulge,-PI/2+1,3*PI/2); arc(mx-210,my,25 + bulge,54 + bulge,-PI/2+1,3*PI/2); } AND import pFaceDetect.*; import JMyron.*; PFaceDetect face; JMyron m;//a camera object PImage img; // Eyes Code float mx = 425; float my = 200; float bulge = 0; float leftdist; float rightdist; float fillr; float fillg; float fillb; void setup() { size(640,480); m = new JMyron(); m.start(width,height); m.findGlobs(0); face = new PFaceDetect(this,width,height, "haarcascade_frontalface_default.xml"); frameRate(15); img = createImage(width,height,ARGB); rectMode(CORNER); noFill(); stroke(255,0,0); smooth(); } void draw() { background(0); m.update(); arraycopy(m.cameraImage(),img.pixels); img.updatePixels(); face.findFaces(img); image(img,0,0); drawFace(); } void drawFace() { int [][] res = face.getFaces(); if (res.length>0) { for (int i=0;i<res.length;i++) { int x = res[i][0]; int y = res[i][1]; int w = res[i][2]; int h = res[i][3]; rect(x,y,w,h); int cx = (x+(w / 2)); // Centre of Face X Axis int cy = (y+(h / 2)); // // Centre of Face X Axis println ("centre = "+cx+" , "+cy+" size = "+w+" x "+h); } } } My goal is combine them so that the eyes move in realtion to the face detect any thoughts?? Thanks