Tuesday, September 1, 2009

Colour based motion tracking



For a while now I've been wanting to create a game that makes use of motion tracking from an ordinary web camera. The basic idea is to take two frames in succession from a recording, clean up their images and then find the difference between them. If there is a difference then thats were the movement was!

I soon found out that general motion capture wasn't exactly what I was looking for, I wanted a player to control some avatar in a game by using gestures, the best way to isolate one specific movement is to use colour. If the movement falls within some RGB range, then take that as the movement, draw a rectangle around it and take the center of the rectangle for your X and Y co-ordinates to move your avatar. This stops the motion detector from picking up the silly grin I had when I realised I was tracking motion.


The basic code is almost done, I'm just ironing some things out. Hopefully I can have the code up by this weekend with a tutorial. The actual game will be implemented in XNA, at the moment I'm thinking of making a 3D first person space shooter. Were your head will control yaw and pith (while you move your head left/right and up/down) and roll, strafing, acceleration and deceleration will be done using keyboard/mouse.
Perhaps I'll call it "Bobbing Heads Space Flight"

If anyone is interested in trying out something like this I recommend that you have a look at the AForge.NET framework, its just bloody amazing. Also, Andrew Kirillov provided most of the code I used above in his "Lego Plan Tilt Camera" so check out the link if you want to learn more about what he's done, lego pan tilt camera

No comments:

Post a Comment