How to trigger an action with face detection?

edited December 2017 in Kinect

Hello, Is it possible to use face detection to trigger a video to play? if webcam detects a face, video plays im having trouble with achieving this

Answers

  • What have you tried? What are you using to detect the face? a webcam? do you know how to collect the video from the camera? Do you have some code that you have tested?

  • I use a webcam. I can get a video playback from the camera. I found a code that draws rectangles around the faces. I removed webcam footage from draw section. I got it working, but maybe you could suggest best settings for the video itself and should i improve something for it to run more smoothly?

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

    Capture cam; 
    OpenCV opencv; 
    Rectangle[] faces;
    Movie video1;
    
    void setup() { 
      size(displayWidth, displayHeight);
      frameRate(30);
      background (0, 0, 0); 
      video1 = new Movie (this, "1.mp4");
      cam = new Capture( this, 640, 480, 30); 
      cam.start(); 
      opencv = new OpenCV(this, cam.width, cam.height); 
      opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
      video1.loop();
    }
    
     void movieEvent(Movie m) {
       m.read();
     }
    
    void draw() { 
      opencv.loadImage(cam); 
      faces = opencv.detect(); 
    
    
    
      if (faces!=null) { 
    
        for (int i=0; i< faces.length; i++) { 
        image(video1, 0, 0 );
    
        }
      } 
      if (faces.length<=0) {
        textAlign(CENTER); 
        fill(255, 0, 0); 
        textSize(56); 
        println("no faces");
        text("stop", 100, 100);
      }
    }
    
    void captureEvent(Capture cam) { 
      cam.read();
    }
    
  • I want it to run fullscreen and the video to fit the screen and run smoothly

  • Answer ✓

    Please don't post duplicates.

    Choose one, close the other or you'll get answers to both and that'll confuse everyone.

  • how to close a discussion?

This discussion has been closed.