Sign in to follow this  
Followers 0
nimaid

Motion detecting webcam?

10 posts in this topic

I want to make a program that will take a picture from my webcam, than take another and compare them. If there are any differences, than play a user defined sound and save the pic to a user defined directory. I am a newb and only know the basics so if you could help me with not only methods but possibly code snippets it would be greatly appreciated!


This statement is a lie.˙uʍop-ǝpısdn sı ǝuo sıɥʇ ʇnq 'ǝıl ɐ ǝq ʎɐɯ ʇuǝɯǝʇɐʇs snoıʌǝɹd ǝɥʇ¡6u15nɟu0) ʎ||43ɹ 51 51ɥ7

Share this post


Link to post
Share on other sites



I want to make a program that will take a picture from my webcam, than take another and compare them. If there are any differences, than play a user defined sound and save the pic to a user defined directory. I am a newb and only know the basics so if you could help me with not only methods but possibly code snippets it would be greatly appreciated!

its really dificult, because the noise of the cam, i think, i can't make 2 same pictures with the webcam, the noise other, and other on every picture, so its really hard to make, i think

Share this post


Link to post
Share on other sites

Unfortunately I don't have a web cam so I can't really write/test any code, but I have an idea that might help. I think a solution could be to compair groups of pixels, located in the area you expect to see movement. If a percentage change in pixel colour occurs, then trigger an alarm. I'm guessing a bit, but I think you could set the sensitivity by changing the percentage and hopefully this will be able to differentiate between real movement and noise.

Share this post


Link to post
Share on other sites

If - besides the webcam - you also happen to own a Canon P&S digicam, you might want to check out

CHDK, a hack for above cams that also has built in motion detection

HTH,

whim

Share this post


Link to post
Share on other sites

i found (and played with) a very efficient flash motion detection app, the AS2 version got quite good speeds and with the right settings you can detect just the movement of eyes (blur: 2, minArea:2, everythingElse: 0, flip: false):

http://blog.soulwire.co.uk/download/as3-motion-tracking

i know the link says AS3, but it also has AS2 source code in it, though i recommend using the AS3 version if you can since it's going to be at least 2x as fast; you probably can't convert it to AutoIt code very efficiently but if you learn the basics of actionscript you can modify it so it reports information to autoit using FSCommand, possibly (though unlikely) ExternalInterface too

this thread demonstrates how to set up accepting commands from flash's FSCommand:

http://www.autoitscript.com/forum/index.php?showtopic=106257&view=findpost&p=750432

and somewhere there should be a reference for what functions/variables are exposed on the flash COM object, though i have been unable to find one

Share this post


Link to post
Share on other sites

A Ha.

I tried doing this a while ago. I do not believe it is possible to ta a picture and then cross reference it with other pictures. The Webcam is bad quality, and the lighting will change throughout the day.

What I did, was have a get pixel function on two points of the webcam display (Use Webcam UDF). I tried having it go off if it changed at all but there was too much noise in the signal...So I set up a variable treshold system for colour (Yes americans, this is the right spelling) change. It Sorta works.

Hope this helps...


ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

well, to account for the light and quality, you can blur it with a radius of 2 (the only way this will fail is if the blockyness is to the point you only have 4 or 6 squares of colour, total. the light is fixed because the change is so gradual (unless a light is turned on/off) that it isn't noticed from one frame to the next) and then you can look for a change greater than X pixels, for eye movement, 2 works well; for general movement, 5 works well, assuming they aren't in the distance, at that point the blur can remove them entirely

Share this post


Link to post
Share on other sites

Thank you all! I also thought that the getpixel function was the way to go, but had no idea how to get the pic, and static is pretty bad on my cam, but I think i can make this work. hank you!


This statement is a lie.˙uʍop-ǝpısdn sı ǝuo sıɥʇ ʇnq 'ǝıl ɐ ǝq ʎɐɯ ʇuǝɯǝʇɐʇs snoıʌǝɹd ǝɥʇ¡6u15nɟu0) ʎ||43ɹ 51 51ɥ7

Share this post


Link to post
Share on other sites

Thank you all! I also thought that the getpixel function was the way to go, but had no idea how to get the pic, and static is pretty bad on my cam, but I think i can make this work. hank you!

Just to leave your options open, you can use a pixelcheck function that isn't too strict. You can detect shades and variations to compensate for noise. Just my two cents if you want an autoit solution.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0