Interactive image using Face detection (OpenCV)

edited December 2017 in Kinect


there is a program I would like to make with a face detector using OpenCV. So basically you would have an image A (could be a video) that when a face is close enough to the camera, slowly morphs into an image B. So far, I got to make the program change the images whether or not the face is recognized but now I would like to : 1) tell the face detector to detect the face only when it's around 3feet (1meter) away so the image can change only in that moment. 2) make the "image changing" really smooth and progressive (maybe if the two images merge together using opacity or something ?)

I am new to Processing and even more to OpenCv that's why I would be so gload if someone has the solution or can help me !

I quoted my code if it helps… The images can be replaced (btw, they are scaled up when the program runs and I don't understand why… that's another problem but not the most important one)

import gab.opencv.*; import*; import java.awt.Rectangle; PImage image; PImage flou; PImage nette; Capture cam; OpenCV opencv; Rectangle[] faces; void setup() { fullScreen(); background (0, 0, 0); cam = new Capture( this, 640, 480, 30); cam.start(); opencv = new OpenCV(this, cam.width, cam.height); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); image=loadImage("image.jpg"); nette=loadImage("nette.jpg"); flou=loadImage("flou.jpg"); } void draw() { opencv.loadImage(cam); faces = opencv.detect(); image(cam, 0, 0); if (faces!=null) { for (int i=0; i< faces.length; i++) { image(nette,0,0); noFill(); stroke(255, 255, 0); strokeWeight(10);
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height); } } if (faces.length<=0) { textAlign(CENTER); fill(255, 0, 0); textSize(56); println("no faces"); image(flou,0,0); text("UNDETECTED", 200, 100); } } void captureEvent(Capture cam) {;}

Thank you so much !!

Sign In or Register to comment.