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