First time here? Check out the FAQ!

Ask Your Question
0

cvCalcOpticalFlowFarneback movement detection.

asked Dec 23 '12

Iblis gravatar image

Hello, I need to compare two consecutive frames from a webcam and if there is enough movement save the image to a file. I've studied the Farneback optical flow sample but I didn't understood so well how it works and how can I use the data to compare the images. I have to write the code in C. Thanks for any suggestion you can give me.

Preview: (hide)

2 answers

Sort by » oldest newest most voted
1

answered Feb 5 '13

John Brewer gravatar image

You'd probably be better off using the motion template example. It shows how to subtract out non-moving parts of a video feed in a way that highlights moving objects.

Preview: (hide)
0

answered Feb 5 '13

To detect movement between two images, you need a score. You can use the motion template as suggested, therefore, you sum all pixels labeled as ''moving''. Or, you could use the histogram comparison between two images. In OpenCV, different methods are proposed, and the Bhattacharyya distance is normed between [0;1]. 0 for identical image (nothing change in pixel intensity) and 1 for ''completely'' different images. A threshold would be easier to specify in [0;1] than for other solution. In this solution everything is done by OpenCV for you...

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Dec 23 '12

Seen: 1,148 times

Last updated: Feb 05 '13