package facetracking;
import java.awt.Rectangle;
import processing.core.*;
import hypermedia.video.*;
import org.openkinect.processing.*;
@SuppressWarnings("all")
public class FaceTracking extends PApplet {
OpenCV opencv;
Kinect kinect;
public void setup() {
size( 640, 480, P2D );
// OpenCV initialization
println( "initializing OpenCV instance..." );
opencv = new OpenCV( this );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_DEFAULT );
opencv.allocate( width, height );
// Kinect initialization
println( "initializing Kinect instance..." );
kinect = new Kinect( this );
kinect.start();
kinect.enableRGB( true );
}
public void draw() {
// grab RGB data from kinect camera
PImage img = kinect.getVideoImage();
opencv.copy( img );
image( opencv.image( OpenCV.BUFFER ), 0, 0 );
// detect anything that is a FRONTALFACE
Rectangle[] faces = opencv.detect();
// draw a rectangle for each detected object
fill( 200, 50, 50, 30 );
stroke( 255 );
for ( int i = 0; i < faces.length; i++ ) {
rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
}
}
}
When I run this there are not errors and it does display the image from the kinect in the opencv buffer. I can even perform other methods from opencv on the data in the buffer, such as blur() and it works fine and displays properly. Despite all this the length of faces remains 0.