Hello there,
I have developed in Visual C++ a framework for my needs which allows me to select a list of available web cameras, grab the data from the web camera, display real-time video on a window and then superimpose graphics on this video with OpenGL.
I am trying now to make a program in C that detects motion using this video data. Generally speaking motion detection in its simplest form involves capturing a frame in greyscale, setting that as a reference frame and then capture a couple of more greyscaled frames, average these into one frame and subtract this from the reference frame. The result frame will have dark grey and bright grey pixels, where dark grey pixels represent areas that did not exhibit much motion and bright grey pixels which are the areas that exhibit some disturbance. This frame then becomes the reference frame and the cycle continues again.
Now this method is quite simplistic and does not really detect motion as such, it simply highlights areas where the luminance (the grey pixel values) have changed significantly to reveal that some disturbance exists. Nevertheless it is a start to indicate that some motion exists.
I want to detect motion. More precisely I want to have motion compensation, this means I want to follow a moving object. I want to partition my frame in regions say typically 8x8 pixels or 16x16 pixels and then as frames keep coming an arrow (a vector) from each block will point to an adjacent block indicating that some region has moved. The arrow (the vector) shows the direction of movement.
For this to happen my understanding is that an edge detection is performed first (may that be Sobel, Canny or Laplacian), which registers black and white pixels in these blocks and then as frames keep coming a best-match is performed around each block to guess where it has moved next, thus an arrow (a vector) is drawn.
There is something called optical flow, but it is quite exchaustive in the way it works. It computes a motion vector for each pixel in frame. For me that is a performance killer hence it won't offer me the functionality I need.
Could someone explain the method of motion compensation? Also can someone elaborate on what sort of information these vectors contain? Typically a vector would require 3 elements: an x location, a y location and an angle direction (at least for the context of this topic).
As a head-scratcher I point you to this link:
http://en.wikipedia.org/wiki/Optical_flow
there are other links in there to give you some information on what I am trying to do (motion compensation).
I have VirtualDub from long time ago, and I remember *somehow* I made it display motion vectors but now I can't find the option again! Does this ring a bell to anyone?
Thanks again, any help is much appreciated.
+ Reply to Thread
Results 1 to 5 of 5
-
-
Motion detection is possible with the avisynth plugin MVTools:
http://avisynth.org.ru/mvtools/mvtools.html
The source code is included in the download.
Maybe this can help you?
I don't know C++ programming but I have used MVTools once to change the framerate of a videoclip and it worked. -
Thank you,
I downloaded AVISynth and managed to open a script with VirtualDub.
As for MVTools I couldn't make AVISynth collaborate with it.
Nevertheless I read some information in the HTML guides for all of these, I think I can get started on what I am trying to do. -
Sample project in C#:
http://www.codeproject.com/csharp/Motion_Detection.asp
Used it with my web cam, and it works like a charm!
/Mats -
Yeah I have seen something like that in the same website here
http://www.codeproject.com/cs/media/Motion_Detection.asp
NOTE: If you wish to see that one running you need to download Microsoft .NET Framework Version 2.0 Redistributable Package (x86) from here
http://www.microsoft.com/downloads/details.aspx?familyid=0856eacb-4362-4b0d-8edd-aab15...displaylang=en
and after you install it you will find the following registry key on your machine (WinXP assumed):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
then you can unzip the motion detection demo and with notepad open motion.exe.config file and change supportedRuntime version to "v2.0.50727"
otherwise the demo thinks you don't have a .Net runtime package installed.
Thank you guys, I think I have enough information to get me going. The thing with these image processing techniques is that there isn't a standard solution to a problem, it's more an issue of what works for you, for your needs.
InD
Similar Threads
-
content based video analysis using motion detection
By Rimaz in forum ProgrammingReplies: 1Last Post: 4th Apr 2012, 10:30 -
Modifying H.264 motion vectors in FFmpeg
By qontranami in forum ProgrammingReplies: 0Last Post: 13th Feb 2012, 18:54 -
Motion detection | aftereffect | need a pro to help me out
By 4matc in forum EditingReplies: 10Last Post: 6th Dec 2009, 09:33 -
Extracting motion vectors from MPEG2 Stream.
By anuking in forum Newbie / General discussionsReplies: 2Last Post: 27th Dec 2007, 10:58 -
Is there a jerkiness (motion detection?) setting in CCE?
By robrosen in forum Video ConversionReplies: 0Last Post: 20th Sep 2007, 16:42