OPENCV



Name cascade()
Examples faceDetect
import hypermedia.video.*;

OpenCV opencv;

void setup() {

    size( 320, 240 );

    opencv = new OpenCV(this);
    opencv.capture( width, height );
    opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );    // load the FRONTALFACE description file
}

void draw() {
    
    opencv.read();
    image( opencv.image(), 0, 0 );
    
    // detect anything ressembling a FRONTALFACE
    Rectangle[] faces = opencv.detect();
    
    // draw detected face area(s)
    noFill();
    stroke(255,0,0);
    for( int i=0; i<faces.length; i++ ) {
        rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height ); 
    }
}

Description Load into memory the descriptor file for a trained cascade classifier. Required by the object detection method (see detect()).

While you may use your own cascade description files, this library links as well to a standard family of detection cascades (CASCADE_FRONTALFACE_DEFAULT, CASCADE_FULLBODY, …). These are installed automatically in the Windows installer and most Linux packages. For those using Macs, we have included these files in our opencv-framework-*.*.dmg installer. If you use a different Mac installer, you will have to import these files on your own.

It is recommended that you avoid loading the file at each cycle.

Available detection cascade flags :

  • CASCADE_FRONTALFACE_ALT_TREE
  • CASCADE_FRONTALFACE_ALT
  • CASCADE_FRONTALFACE_ALT2
  • CASCADE_FRONTALFACE_DEFAULT
  • CASCADE_PROFILEFACE
  • CASCADE_FULLBODY
  • CASCADE_LOWERBODY
  • CASCADE_UPPERBODY
Syntax cascade(file);
Parameters
file String : The filepath, or standard cascade flag (see above) of the Haar classifier cascade file to be used for object detection
Return None
Usage Application