herkulano
YaBB Newbies
Offline
Posts: 1
Re: Face Detect Library
Reply #15 - Nov 11th , 2008, 12:31pm
hi, i'm trying to get your library to work with 2 simultaneous FaceDetects, one for front face detection another for profile face. the problem is that only the latter works. im my tests i saw that the problem is in the cascade xml detection: fdSide.start("haarcascade_profileface.xml", width, height, 20); it assumes only the last loaded cascade. it seems like the cascade is a singleton static variable, so there can be only one. can you tell me if my assumption is true and if so is there a way you can change this so we can have many facedetects at the same time? the code i'm using: import JMyron.*; import FaceDetect.*; FaceDetect fdFront; FaceDetect fdSide; int MAX = 10; JMyron m; int w = 640; int h = 480; int[] x = new int[MAX]; int[] y = new int[MAX]; int[] r = new int[MAX]; int[][] FrontFaces = new int[MAX][3]; int[][] SideFaces = new int[MAX][3]; int[] img = new int[w*h]; PImage face_img; // 160x247 PFont font; void setup(){ size(w,h); m = new JMyron(); m.start(width,height); fdFront = new FaceDetect(this); fdFront.start("haarcascade_frontalface_default.xml", width, height, 20); fdSide = new FaceDetect(this); fdSide.start("haarcascade_profileface.xml", width, height, 20); strokeWeight(2); stroke(255,200,0); noFill(); face_img = loadImage("smilingface_big.png"); font = loadFont("BitstreamVeraSansMono-Roman-12.vlw"); textFont(font); } void draw(){ background(0); m.update(); img = m.image(); loadPixels(); arraycopy(img,pixels); updatePixels(); SideFaces = fdSide.face(img); int sideCount = SideFaces.length; if (sideCount>0) { for (int i = 0;i<sideCount;i++) { x[i] = SideFaces[i][0]; y[i] = SideFaces[i][1]; r[i] = SideFaces[i][2]; ellipse(x[i],y[i],r[i],r[i]); } } FrontFaces = fdFront.face(img); int frontCount = FrontFaces.length; if (frontCount>0) { for (int i = 0;i<frontCount;i++) { x[i] = FrontFaces[i][0]; y[i] = FrontFaces[i][1]; image(face_img, x[i]-80, y[i]-150); } } String s = "Front Faces: " + Integer.toString(frontCount) + " | Side Faces: " + Integer.toString(sideCount); fill(255, 255, 0); text(s, 20, height - 20); noFill(); }