2007年6月20日 星期三

How to use a webcam to capture the vister's position as the cursor controlled by mouse

hello, Keith,

As discussed last meeting, in my installation, i will use a webcam to capture the vister's position as the cursor controlled by mouse (the moving of mouse will become the moving of vister). Is there any ways to achieve that in processing? Can you suggest some ways for me to do that? Thanks.

Below is my source code about how to move the mouse to change the position and size of each image.

/**
* Moving the mouse changes the position and size of each image.
*/

void setup()
{
size(750, 750);
noStroke();
}

void draw()
{
background(255,255,255);



PImage b;
b = loadImage("er.gif");
image(b, width/1.1-mouseX, height/3, ((height-mouseY)/2)-100, ((height-mouseY)/2)-100);

PImage c;
c = loadImage("bu.gif");
image(c, mouseY/2, width/2-120, mouseX/2+10, mouseX/2+10);

PImage a;
a = loadImage("he.gif");
image(a, mouseX/2, height/3+120, mouseY/2+10, mouseY/2+10);

PImage d;
d = loadImage("tong.gif");
image(d, width/2.5, height-mouseY, ((height-mouseX)/2)+10, ((height-mouseX)/2)+10);

PImage e;
e = loadImage("junzi.gif");
image(e, width/2, height-mouseX, ((height-mouseX)/2)+10, ((height-mouseX)/2)+10);

}

1 則留言:

Keith 提到...

Please email me and i will forward you the demo code.