Loading...
Logo
Processing Forum
midcon's Profile
1 Posts
0 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Currently I am working on a project that will involve:
    -detecting faces
    -recording when a face is detected
    -stop recording when a face is detected
    -replay this footage with the face removed

    Right now I have a base code that accomplishes deleting the face by using a copy of the image stored (background image) when the space bar is hit.  However, I need to have it record the face in video, then replay it, and this action triggered by the detection of a face.  Any suggestions of how to go about doing this?  Also, I know that there is a way to change the size of the rectangle placed around the face detected, but how do I go about doing that?  I've done it before in simpler programs, but I can't seem to do it now.  This project will be used for a video installation.


    current code is:


    // This program takes a single image when you press any key (background image)
    // it then detects faces and replaces the face area with
    // the background image

    import hypermedia.video.*;
    import java.awt.Rectangle;

    OpenCV opencv;

    void setup() {

       
        size( 640, 480 );

        opencv = new OpenCV(this);
        opencv.capture( 320, 240 );
     
         // face recognition
        opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );    // load the FRONTALFACE description file
      
    }

    void draw() {
       
        opencv.read();
        // display the current video feed
        image( opencv.image(), 0, 0 );
       
        // detect anything ressembling a FRONTALFACE
        Rectangle[] faces = opencv.detect();
       
        // draw detected face area(s)
        fill(255,0,0);
        stroke(255,0,0);
        for( int i=0; i<faces.length; i++ ) {
         
          // copy a specific area from the image in memory (the background)
          // place the copy exactly where the face is in the current image
          rectMode(CENTER);
          copy(opencv.image(OpenCV.MEMORY),faces[i].x,faces[i].y,faces[i].width,faces[i].height,faces[i].x, faces[i].y,faces[i].width,faces[i].height);

        }
       
        // display the image in memory
        image( opencv.image(OpenCV.MEMORY), 329, 0 ); 
       
    }

    // When a key is pressed, capture the background image

    void keyPressed() {

        opencv.remember();  // store the actual image in memory
    }





    Thanks