Face detection interaction [closed]

asked 2017-12-09 03:50:54 -0600

Pharonn gravatar image

updated 2017-12-09 04:06:29 -0600

Hello,

Basically, I want to do a program where you have an image (or video, whatever) that we'll call "image A". When a face is close enough to the camera and recognized, image A slowly morph into image B. To do that, I think I need a code that tells the face detector that the face needs to be, say, 3 feet (1meter) maximum from the camera and that the morphing needs to be really smooth. That's my two most important issues… I am new to Processing so that's why I really need your help please !

Thank you so much

Edit : Here is my code so far, I'm sorry it's so messy… and my images are scaled up so they're bigger on my screen i don't know why but this is not the most important problem i think (?).

 import gab.opencv.*; 
import processing.video.*; 
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) { 
  cam.read();}
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2017-12-09 04:14:41.088326

Comments

what have you tried so far ? is there any code, you can show ?

Processing -- if you mean the library, we cannot help you with that.

berak gravatar imageberak ( 2017-12-09 03:56:47 -0600 )edit

Hi, thank you for your quick answer ! I edited my post so you can have the code (without the data, i don't know how to import it but you can replace the images)

Pharonn gravatar imagePharonn ( 2017-12-09 04:08:40 -0600 )edit

i'm sorry, but we cannot help you with unsupported, 3rdparty libs like processing (which is also using only a very small subset of very outdated opencv1.0 code. better stop using that, entirely)

berak gravatar imageberak ( 2017-12-09 04:16:10 -0600 )edit

Okay thank you anyways. have a good day

Pharonn gravatar imagePharonn ( 2017-12-09 04:18:00 -0600 )edit

still, since faces don't come in arbitrary sizes, you're safe to assume, that a larger rectangle means a closer face. but this is only, where the real work would start, e.g. finding a mask from facial landmarks, delauny triangulation, seamless cloning. and again, i'm afraid, you won't be able to do anything like that from the very limited toolset, processing offers.

berak gravatar imageberak ( 2017-12-09 06:35:09 -0600 )edit