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 › face detection sketch troubles - PLEASE HELP
Page Index Toggle Pages: 1
face detection sketch troubles - PLEASE HELP (Read 877 times)
face detection sketch troubles - PLEASE HELP
Jan 14th, 2010, 4:19am
 
i am using bryan chungs face detection library and example to build a sketch that switches all faces detected out with eachother.

im having trouble with the flickering of the face detection and want the faces to fade out instead of on/off approach
i also want to mask out the faces with a masking image this is done easily with img.mask.pixels kinda way.

anyway here is some code:
Code:
void drawFace() {
int k;
int [][] res = face.getFaces();
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];

images[i] = get(x,y,w,h);

/* here the mask is resized and made into an array of pixels so
it can be used by multiple faces at once*/
mymask2=createImage(w,h,RGB);
mymask2.copy(mymask,0,0, 300, 300,x,y,w,h);
mymask2.loadPixels();
mymask2.updatePixels();

k=i;
/*here three different states is calculated, one face, move first face to last face, and loop down the faces*/
if(res.length==1){
images[i].mask(mymask2.pixels);
image(images[i],x,y,w,h);
println("one face");
}else{

if(i-1==-1){
images[i].mask(mymask2.pixels);
image(images[i],res[0][0],res[0][1],res[0][2],res[0][3]);
println("more faces 2");

}else{
images[i].mask(mymask2.pixels);
image(images[i],res[i-1][0],res[i-1][1],res[i-1][2],res[i-1][3]);
println("more faces 1");
}
}
}
}


if there is any help at all you can give me dont hesitate Smiley
Re: face detection sketch troubles - PLEASE HELP
Reply #1 - Jan 14th, 2010, 8:32am
 
please help me as i have nbeen trying to solve thios problem for one week without coming one step further = going mad! Sad

again:
i need to:
take the face of one person and put on the face of another person in such a manner that detected face 3 =>2 , detected 2=>1, detected 1=>3.
so they rotate like that of course not more than one time - avoid flickering.

this as i see it needs the implementation of face recognmition contra face detection. nobody on these forums have talked aboput that point of view so let me fill out the space : face recognition is where every face is given an ID therefore able to track individual faces.

again  PLEASE HELP ME.
i have an exhibition  in a week and thought that the forums could help me but until now i havent got the help i needed , proove me wrong and excite me Smiley

johannesgj@gmail.com
Re: face detection sketch troubles - PLEASE HELP
Reply #2 - Jan 14th, 2010, 9:47am
 
I've got very limited experience with the face-detection libraries; though certainly found examples to mask out the background from one face (though things obviously get more complex when working with more than one).

Face recognition (as opposed to detection) is non-trivial; but I think what you really mean is slightly different.  IIRC face detection libraries don't necessarily return the array of recognised faces in the same order each frame, meaning that a face might jump from index 0 to index 3 and back again in a matter of a few frames - which obviously causes problems with your goal.

To resolve the problem I guess I'd create a 'Face' class with x and y position.  When a new face is recognised I'd create a Face object.  Then each frame I'd compare the position of faces returned by the face detection library with last known position of the Face objects and work on the crude basis that the nearest detected face to the last known position of the Face object is the correct one.  You'd then do the face swapping on the Face object rather than the detected face.

That's a pretty crude solution and is open to all kinds of problems: like what happens when two faces get close together?  How do you determine if a face has left the camera?  How do you handle those frames in which faces are temporarily not detected?  And no doubt more besides...

I don't doubt that this is a frequent issue though, so I'm sure people have come up with solutions before...  So it's either a matter of finding them; or hoping they post something here; or figuring something out yourself...

Best of luck!
Re: face detection sketch troubles - PLEASE HELP
Reply #3 - Jan 15th, 2010, 4:23am
 
thanks for the thought provoking reply Smiley
ive never thought of using classes in this project so this is definetly a new approach. in the matter of the problems generated by this approach i right now dont have a clue of how to solve them.
two faces close to eachother, face left the camera, is two things i right now have too much chaos in my mind to figure out. (chaos caused by bruteforcing a solution to my sketch troubles through 3 nights without result Smiley
well i guess a class might be a good start, ive never done so much with classes before but im sure theres help to get,
first thing though is to extract what needs to be put in the class. i guess an image and some coordinates to the image.
well i hope to figure it all out, but if anyone have an advice feel free to fire off Smiley (bad translation of a danish saying hehe)

kind regards johannes
Page Index Toggle Pages: 1