Control Mouse Cursor With Motion Tracking

Bob Zag's icon

Hi,

I am new to MAX and the motion tracking tools. Right now I am trying to figure out if it's possible to control my cursor through the cv.jit.features2track
Basically what I'd like to happen is to use a physical object and track its motion via the webcam in order to control the location of the cursor on my screen.
If any one can help please do!!

- Brett

madjax's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is possible, but hijacking your mouse can be a risky proposition because it can be difficult to regain control. if you send the average coordinates coming from the jit.3m object in the cv.jit.features2track patch to the message "; max pupdate $1 $2" it will take over your mouse and send to those coordinates. You would need to scale the coordinates to the resolution of your monitor to make it move all the way across your screen though. Here is a demo patch. I have put a 10 second timer that cuts off the cursor hijacking to ensure sanity. You could probably re-design this with a keyboard button push or some other sort of input. I tried mouse clicks, but it seemed to crash max.

Bob Zag's icon

Thanks this helps a ton!! Working well so far :)