Hardware Reference
In-Depth Information
The draw() method is much
simpler than the last project because
you're not looking at every pixel. It uses
the OpenCV detect() method to look
for rectangles matching the pattern
you chose, and delivers them in an
array. Then it iterates over the array
and draws ellipses over each face.
8
void draw() {
// grab a new frame:
opencv.read();
// Look for faces:
Rectangle[] faces = opencv.detect();
// display the image:
image( opencv.image(), 0, 0 );
When you run this, point your face at it,
and you'll get a nice fuchsia mask, as
shown in Figure 9-3.
// draw circles around the faces:
fill(0xFF, 0x00, 0x84, 0x3F); // a nice shade of fuchsia
noStroke(); // no border
Try the program on different versions
of faces and different conditions. Also
try the other face-detection cascades
mentioned on the OpenCV for Process-
ing site.
for ( int thisFace=0; thisFace<faces.length; thisFace++ ) {
ellipse( faces[thisFace].x, faces[thisFace].y,
faces[thisFace].width, faces[thisFace].height );
}
}
Figure 9-3
The face detection finds
me fairly well.
Turning sideways, I
disappear.
It does well with a photo
of people, even the
abstracted face on my
shirt. Facial hair and other
markings make a person
harder to detect.
Animals are not detected
by this algorithm.
Noodles is not detected
(and not happy either).
 
Search WWH ::




Custom Search