Face Detection not working

Hi , I am using the code below , and when I use it with my external Logitech C9000 camera , it shows a live stream , but it's failing to detect (show a square box) my face. Can anyone help me with this ?

Here is the code :

import gab.opencv.*;
import java.awt.*;
import processing.video.*;

Capture cam;
OpenCV opencv;

void setup() {
  size(320, 200);

  String[] cameras = Capture.list();

  cam = new Capture(this, cameras[1]);

  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); 

  cam.start();
}


void draw() {
   scale(0.5 , 0.5);
  if (cam.width > 0)
  {
  opencv.loadImage(cam);}

  image(cam, 0 , 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }

}

void captureEvent(Capture cam) {
  cam.read();
}

Thanks in advance ^^

Tagged:
Sign In or Register to comment.