Face Detection and Alarm
in
Contributed Library Questions
•
1 year ago
Hello -
I'm looking to create an alarm (buzz/sound, etc), when the face is out of frame for a 30 seconds. I'm not sure where to put an if statement using, Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );. Can anyone point a direction? Thanks!
I'm using the following code:
I'm looking to create an alarm (buzz/sound, etc), when the face is out of frame for a 30 seconds. I'm not sure where to put an if statement using, Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );. Can anyone point a direction? Thanks!
I'm using the following code:
- import hypermedia.video.*;
- import java.awt.Rectangle;
- OpenCV opencv;
- // contrast/brightness values
- int contrast_value = 0;
- int brightness_value = 0;
- void setup() {
- size( 640, 480 );
- opencv = new OpenCV( this );
- opencv.capture( width, height ); // open video stream
- opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
- }
- public void stop() {
- opencv.stop();
- super.stop();
- }
- void draw() {
- // grab a new frame
- opencv.read();
- opencv.contrast( contrast_value );
- opencv.brightness( brightness_value );
- // proceed detection
- Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
- // display the image
- image( opencv.image(), 0, 0 );
- // draw 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 );
- }
- }
1