We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › HELP WITH FACE DETECTION AND PIMAGE !!!!
Page Index Toggle Pages: 1
HELP WITH FACE DETECTION AND PIMAGE !!!! (Read 850 times)
HELP WITH FACE DETECTION AND PIMAGE !!!!
Jul 20th, 2009, 12:28pm
 
Well hello guys...

I'm pretty new to Processing but I've been working on how to recognize a face and at the same time place an image on top of it like some webcam softwares out in the market... I'm using Bryan Chung's method to recognize faces (bryanchung.net/?page_id=251) but instead of placing a red rectangle on top of the face I want to place an image thats located on the data folder like sunglasses or something like that. Here's the code:

Code:
import pFaceDetect.*;
import JMyron.*;

PFaceDetect face;
JMyron m;
PImage img;

void setup() {
 size(320,240);
 m = new JMyron();
 m.start(width,height);
 m.findGlobs(0);
 face = new PFaceDetect(this,width,height,
 "haarcascade_frontalface_default.xml");
 frameRate(15);
 // I GUESS THIS IS THE PART THAT HAS TO BE MODIFIED
 img = createImage(width,height,ARGB);
 rectMode(CORNER);
 // HERE'S THE RECTANGLE INSTEAD OF THIS I WANT A IMAGE LOCATED ON THE FOLDER
 noFill();
 stroke(255,0,0);
 smooth();
}

void draw() {
 background(0);
 m.update();
 arraycopy(m.cameraImage(),img.pixels);
 img.updatePixels();
 face.findFaces(img);
 image(img,0,0);
 drawFace();
}

void drawFace() {
 int [][] res = face.getFaces();
 if (res.length>0) {
   for (int i=0;i<res.length;i++) {
     int x = res[i][0];
     int y = res[i][1];
     int w = res[i][2];
     int h = res[i][3];
     rect(x,y,w,h);
   }
 }
}

void stop() {
 m.stop();
 super.stop();
}


I hope to get answers Shocked
Thanks in advance!!! Cool
PLEASE REPLY
Reply #1 - Jul 22nd, 2009, 11:38pm
 
COME ON GUYS... PLEASE HELP AND REPLY!!!

THANKS!!!!
Re: HELP WITH FACE DETECTION AND PIMAGE !!!!
Reply #2 - Jul 23rd, 2009, 3:53am
 
the rectangle in the original code is:
Code:

rect(x,y,w,h);

if you want an image instead of the rectangle you simply need to create a PImage, put your image inside the PImage, draw your image insted of the rectangle; so it should look like:
Code:

...
PImage my_img;
...
void setup(){
...
my_img = loadImage("yourpath/yourimg.ext");
...
}
void draw(){
...
image(my_img,x,y); //this is to be placed where in the original there's the rect() call
...
}


it's really easy: reading the tutorials and the reference should give you all you need to handle basic processing bits like rect() and image().

maybe next time, when a new problem arises, read the manual before hitting cap lock  Smiley
Page Index Toggle Pages: 1