Interactivity and capture

Hi! I’m working on a project for university and I’m having some difficulties with Processing.
Concept: There are two pictures and the program makes a transition by transparency from one picture to another, by moving the mouse from left to right. The program is working but from now, I’d like to use something better than the mouse to make the transition between both pictures. I’d like to use a webcam to make people interact with my work.
Basically, if somebody is on the left, Picture A appears. And if he/she walks to the right Picture B appears.

The problem is that I’m a beginner, so I can modify some lines of the code but I’m really bad at writing the whole program. I’d appreciate if somebody could help me fixing my problem. Here is where I am:

PImage one,two;
void setup(){
// Size of the background. Has to be the same as both pictures.
size(1199,787,P3D);
one = loadImage("RT21.jpg");
two = loadImage("RT22.jpg");
}
void draw(){
// Background is the first image (here: RT21.jpg)
background(one);
// Second imges appears according to the position of the mouse.
tint(255,255,255,(255.0/width)*pmouseX);
image(two,0,0);
}
1 Like

Hi,
If it is a camara on an Android phone, you could try the Ketai Library wich has face detection.
Or on windows see here, or watch this

1 Like

Thinking better, maybe you want only the movement from someone further away.
That is more difficult. But assist this video.
It can help you. I did a hand move experiment, you can see here.

1 Like

I think facial detection is a nice idea so I’ll focus on that. I’m reading the link you joined to your first comment at the moment.

Thank you!

Other options include background subtraction, motion detection, and blob detection – e.g. with the opencv or boofcv libraries. Then anything (any moving thing) in the camera field will return a location box, regardless of whether or not its face is identifiable.