Face recognition saving img

edited June 2017 in Kinect

Does somebody know a sketch or way to save the bounding box of a face detection program/software/sketch. I want to safe the image in the bounding box (the face). Googlefu leaves me wondering around.

Answers

  • Something like this should get you started in Processing using OpenCV:

    import gab.opencv.*;
    import processing.video.*;
    import java.awt.*;
    
    Capture video;
    OpenCV opencv;
    
    PGraphics pg;
    PImage firstFace;
    
    void setup() {
      size(640, 480);
      pg = createGraphics(640, 480);
      video = new Capture(this, 640, 480);
      opencv = new OpenCV(this, 640, 480);
      opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  
      video.start();
    }
    
    void draw() {
      opencv.loadImage(video);
      image(video, 0, 0 );
    
      noFill();
      stroke(255, 255, 0);
      strokeWeight(3);
      Rectangle[] faces = opencv.detect();
      println(faces.length);
    
      if (faces.length == 1) {
        firstFace = video.get(faces[0].x, faces[0].y, faces[0].width, faces[0].height);
        image(firstFace, 0, 0);
        text("Press key to save the face", width/2, height/2);
      } 
    }
    
    void captureEvent(Capture c) {
      c.read();
    }
    
    void keyPressed() {
      pg.beginDraw();
      pg.image(firstFace, 0, 0, width, height);
      pg.endDraw();
     pg.save("face.jpg"); 
    }
    
Sign In or Register to comment.