Finally, this is the Windows version of the face detection library for Processing. It bases on the sample face detection library in OpenCV and uses the Java Native Interface to send back the face information to the Processing library.
It requires you to put the sample Haar cascade classifiers XML file in the data folder of the sketch. And the present library does not include the executable files for OpenCV. You need to install it before running the sketch. Here is a sample demonstration code. I use the JMyron library to have a live webcam input. The complete library sources (Java and C++) and documentation will be posted soon.
import pFaceDetect.*;
import JMyron.*;
PFaceDetect face;
JMyron m;
PImage img;
void setup() {
size(320,240);
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);
}
}
}
void stop() {
m.stop();
super.stop();
}

Veeeeeeery Good!
I’ll try to use it NOW
Hello,
I’m having some trouble to get it up and runnig!
There is a .so and a .dll but there is no .dylib for Mac OS (wich I’m using).
When I run the code I get an exception:
Exception in thread “Thread-2″ java.lang.UnsatisfiedLinkError: no PFaceDetect in java.library.path
Thanks and see ya
Dear Lucas,
The one I post is for Windows only. You can find the MAC version from http://tokage.cafe24.com/facedetect/. Thanks.
Bryan
Bryan,
Have you had an opportunity to create the documentation. I am attempting to implement your example (but with a twist) and having a few problems. I am planning on submitting a photo for processing for facial detection. My goal is to alter the photo enough where the algorithm will not detect the photo. The next step would be to smooth/median (some image filtering process) the photo until the face is detected by resubmitting.
Thanks,
Marc
new to JNI, decent Java background, new to image processing, using Eclipse
Marc,
You can find the ‘official’ page of the library in http://www.bryanchung.net/?page_id=251 where you can find the documentation. Thanks.
Bryan
Bryan,
Sorry again for another question. It seems as if I have downloaded/installed and copied what I need at this point. My problem seems to be with understanding Processing and how to “deploy” the code above. It seems like this is an applet approach but I cannot create a class which html can then, in-turn, call. I’ve found many Processing examples online but none describe how to “deploy” them.
Thanks again,
Marc
You can delete that last post, just realized I need to create a “sketch” script and deploy via the Processing application. Thanks again.
Yes, the library works with Processing application at the moment, not Applet in an HTML.
Bryan