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 & HelpSyntax Questions › switch faces with face detection library
Page Index Toggle Pages: 1
switch faces with face detection library (Read 677 times)
switch faces with face detection library
Jan 10th, 2010, 9:38am
 
i am using the face detection library's standard example to make a sketch that takes the face of one detected face and puts it in the place of another detected face thereby shifting faces around.

right now i have the standard function of draw faces like this:
Code:
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);
}
}
}


and what i think about is to add
Code:
faceImage= get( res[i] [0],res[i] [1],res[i] [2],res[i] [3]); 


with faceImage being PYImage object.

but that would only let me do one picture so i need a way to make an array of PYImages like faceImage [i]

and in the end i would need a function to detect first if there is an even number or uneven.

pseudo code:
if even switch al faces with the face plus 1 and last face = face 0
or something

if uneven the same as above for the biggest even number and the last one gets his face switched with a pre recorded face video.

if you guys can help me anything of the above i say thanks!
kind regards johannes
Re: switch faces with face detection library
Reply #1 - Jan 10th, 2010, 11:01am
 
ive made something that works but it flickrs too much to be usable in an installation anybody able to give me some ideas?
here is the code:

Code:
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);
//println(i);
println((i/2)%2);
images[i] = get(res[i][0],res[i][1],res[i][2],res[i][3]);

if(i==0){
image(faceImage,res[i][0],res[i][1],res[i][2],res[i][3]);
}else{
image(images[i],res[i-1][0],res[i-1][1],res[i-1][2],res[i-1][3]);
}
}
}
}
Re: switch faces with face detection library
Reply #2 - Jan 10th, 2010, 11:13am
 
a small change brings me to the more consistent version:
Code:
void drawFace() {
int k;
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);
//println(i);
//println((i/2)%2);
images[i] = get(res[i][0],res[i][1],res[i][2],res[i][3]);
k=i;
if(res.length==1){
image(images[i],res[i][0],res[i][1],res[i][2],res[i][3]);
println("one face");
}else{
k=k-1;
if(k>-1){
image(images[i],res[i-1][0],res[i-1][1],res[i-1][2],res[i-1][3]);
}
}
}
}
}


where the changes have been done in the if segment
Page Index Toggle Pages: 1