I want to cut out everything outside the circle [openCV] facedetect
in
Contributed Library Questions
•
1 year ago
Hey Guys,
I have a question, it is possible to remove everything outside the circle so that only my face is visible?
I would be very happy with your help.
Here is my source:
- import hypermedia.video.*;
- import java.awt.Rectangle;
- OpenCV opencv;
- //PFont score;
- //PImage ballen;
- void setup(){
- size(600, 450);
- //score = loadFont( "ArialMT-16.vlw" );
- // ballen = loadImage("bal.png");
- opencv = new OpenCV( this );
- opencv.capture( width, height ); // open video stream
- opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
- ellipseMode(CORNER);
- }
- public void stop() {
- opencv.stop();
- super.stop();
- }
- void draw(){
- background(0);
- opencv.read();
- // proceed detection
- Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
- // display the image
- // image (opencv.image(), 0, 0);
- 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 );
- ellipse( faces[i].x, faces[i].y, faces[i].width, faces[i].height);
- }
- noStroke();
- fill(0);
- // x, y, breed, hoog
- rect(20,10,125,45);
- //textFont(score,16);
- fill(255);
- //text( "Score: " ,25,26);
- //text( "Level 1",25,50);
- //image(ballen, 19, 75);
- //image(ballen, 69, 75);
- //image(ballen, 119, 75);
- }
Thanks,
Lion_X
1