Quantcast
Channel: Kinect - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 530

Using face detection to run a function

$
0
0

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

Capture video; OpenCV opencv;

Minim minim; AudioPlayer song; import ddf.minim.*;

PFont font; String time = "10"; int t; int interval = 10;

void setup() { size(640, 500);

minim = new Minim(this);

song = minim.loadFile("alarm.mp3");

font = createFont("Arial", 100);

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() {

background(0);

t = interval-int(millis()/1000); time = nf(t , 1); if(t == 0){ song.play(); // interval+=10; }

text(time, 10, 490);

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); rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height); } }

void captureEvent(Capture c) { c.read(); } void songClose() { song.close(); } ` I'm fairly new to processing, what would be the best way use the face detection library to control when the alarm audio is stopped?

Thanks in advance.


Viewing all articles
Browse latest Browse all 530

Trending Articles