Saving images on face detection [OpenCV]

edited November 2014 in Library Questions

Hey guys, I'm trying to make it so when the face is detected it will save an image named say face-01.jpg, then when face detected again save a second copy and so on. I tried saveFrame but when the face was detected it saved frame after frame really quickly. Apologies if i have posted incorrectly, first time poster. Thank you in advance.

    import gab.opencv.*;
    import processing.video.*;
    import java.awt.*;

    Capture video;
    OpenCV opencv;

    void setup() {
      size(640, 480);
      video = new Capture(this, 640/2, 480/2);
      opencv = new OpenCV(this, 640/2, 480/2);
      opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

      video.start();
    }

    void draw() {
      scale(2);
      opencv.loadImage(video);

      image(video, 0, 0 );

      noFill();
      stroke(0, 255, 0);
      strokeWeight(3);
      Rectangle[] faces = opencv.detect();
      println(faces.length);

      for (int i = 0; i < faces.length; i++) {
        println(faces[i].x + "," + faces[i].y);
      }
    }

    void captureEvent(Capture c) {
      c.read();
    }
Sign In or Register to comment.