Ask Your Question
0

cvCalcOpticalFlowFarneback movement detection.

asked 2012-12-23 09:55:17 -0500

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.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-02-04 21:46:45 -0500

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.

edit flag offensive delete link more
0

answered 2013-02-05 11:57:41 -0500

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...

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-12-23 09:55:17 -0500

Seen: 738 times

Last updated: Feb 05 '13