strange image fading away problem
in
Programming Questions
•
3 years ago
Hello,
I wrote a simple little program that tracks a face using OpenCV and puts a mask image over the face. Basically it's the same as an OpenCV tutorial I just use PImage to put an image over the face instead of rect(); like in the library example.
However, in my program, oddly enough, the .png image that I use fades away after about 20 seconds. Anyone know what's going on here? Here is the code and thanks so much for any help!
I wrote a simple little program that tracks a face using OpenCV and puts a mask image over the face. Basically it's the same as an OpenCV tutorial I just use PImage to put an image over the face instead of rect(); like in the library example.
However, in my program, oddly enough, the .png image that I use fades away after about 20 seconds. Anyone know what's going on here? Here is the code and thanks so much for any help!
- import hypermedia.video.*;
import java.awt.Rectangle;
PImage mymask;
OpenCV opencv;
void setup() {
size( 640, 480, P2D );
mymask = loadImage("mymask.png");
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)
//image(mymask,20,50); //even if i put the image here with the resize it still fades away
//mymask.resize(0,100);
for( int i=0; i<faces.length; i++ ) {
//rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
mymask.resize(faces[i].width, faces[i].height);
image(mymask, faces[i].x, faces[i].y);
}
}
1