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

Activity Trend

Last 30 days
Show:
Private Message
    Hi all,

    I'm trying to program an interaction using opencv, in which

    1) The script looks for faces in a video feed
    2) When a face is found, it calculates the area of the face
    3) If the area is larger than a set number, it starts a photobooth. Otherwise, start from (1)
    4) When in photobooth mode, the screen flashes the "3" for one second, "2" for one second, "1" for one second, and then it captures the frame
    5) After the frame is captured, the image is displayed on screen for as long as the person stands in front of the camera (as long as a face is still detected)
    6) When a face is no longer detected, start over.

    I'm having problems with (4) and (5)

    This is the script I have so far. In place of 4, I have it display a word "hello" for 3 seconds, but what I'm getting is a blank screen for three seconds, then a captured image, then a blank screen for three seconds, etc.


    import hypermedia.video.*;
    import java.awt.Rectangle;
    boolean doCapture = false; // determines whether to enter sequence
    int prevMillis;
    int count;

    OpenCV opencv;
    OpenCV photob;
    PFont font;
    PImage photo;

    void setup() {

      size(640,480);
        
      // Font
      font = loadFont("skyhook.vlw");
      textFont(font, 200); 
        
      // OpenCV
      opencv=new OpenCV(this); // when doCapture=false
      opencv.capture(width,height,1);
      opencv.cascade(OpenCV.CASCADE_FRONTALFACE_ALT); // load the FRONTALFACE description file
      photob=new OpenCV(this); // when doCapture=true
      photob.capture(width,height,24);
    }

    void draw() {
      
      if (!doCapture) {
        opencv.read();
        image( opencv.image(), 0, 0 );
            
      // detect anything resembling a FRONTALFACE
      Rectangle[] faces = opencv.detect(1.2, 2, 0, 1, 1);

      // check if found face meets the conditions for triggering a capture.
      for( int i=0; i<faces.length; i++ ) {
          // Is the face at least 7.5% the total area of the screen?
          if( ((faces[i].width * faces[i].height) > (.075 * width * height)) ){
            doCapture = true;
          }
          else {
            doCapture = false;
          }
        }
      }
      
      // If the face is at least 7.5% the total area of the screen
      if(doCapture) {
        background(0); // clear background
        prevMillis = millis(); // start time counter
        photobooth(); // start photobooth sequence
      }
    }

    // photobooth sequence
    void photobooth() {
      photob.read();
      image( photob.image(), 0, 0);

      // insert text in photobooth mode
      fill(255,0,55,100);
      textAlign(CENTER,BOTTOM);
      text("hello", width/2, height/1);

      println (millis() - prevMillis); // troubleshooting time count

      // if the time elapsed is less than 3 seconds
      if( millis() - prevMillis < 3000) {
        photobooth();
      }
      // if the time elapsed is more than 3 seconds
      else {
        image( photob.image(), 0, 0); // load video feed without text
        saveFrame("image" + count + ".jpg");  // save image
        photo = loadImage("image" + count + ".jpg");  // display image on screen
        count++; // add 1 to the file number
      }
    }


    Any help would be greatly appreciated, thanks!

    Hi all,

    I'm new to processing, and trying to write code to do a simple slideshow. The slideshow is simply an image shown on a screen for a number of seconds, followed by the next, and looped from the beginning.

    I've been looking into arrays and classes since I know that doing it via brute repetition is horribly inefficient, but the problem I have is that the number of images is not constant; it steadily increases over time as new images are added through a webcam capture.

    Any help would be greatly appreciated! Thanks!
    Hi,

    I'm new to processing, and trying to write code for an installation that I will be doing.

    Basically, I've been using face detection in OpenCV to find faces in a live webcam feed. What I want to do is to trigger an image capture only when the size and position of the face cross certain thresholds, say 25% of the area and near the center of the image.

    The opencv base code ( http://ubaa.net/shared/processing/opencv/opencv_detect.html) draws a rectangle where a face is detected ... could I use the size/position of the rectangle to decide whether or not it triggers the capture? And how can I capture the frame without the rectangle in it?

    Thanks!