Ask Your Question
0

Non-motion detection

asked 2013-02-22 14:16:25 -0600

Hello!

Here is a task:

I've got a lot of video captured by a camera mounted behind a car windshield, facing to the front. So I need to filter out parts of the video which were captured when the car stopped. So only parts of the video when the car was in motion should left.

Can you advice, how to achieve this using OpenCV?

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-02-22 22:07:59 -0600

Keba gravatar image

I am no expert, but I would think the video would contain more activity when the car was moving, compared to when it was parked. The task would then be to measure the activity, and determine how much activity constitutes car movement. One measure of activity of a video, is to calculate the absolute difference between the last and current frame (differencing), and take the sum of the resulting image. In this manner, one could calculate the activity for each pair of frames, and if this value exceeded some threshold, one could conclude that the car was moving.

edit flag offensive delete link more

Comments

Yes, this is true. So the question was, which C++ classes/methods should I use to detect such a difference. I looked through OpenCV "Video Processing" documentation, but haven't found the clear solution.

Yggdrasil gravatar imageYggdrasil ( 2013-02-25 07:04:25 -0600 )edit

Well... cv::VideoCapture can load a video and give you video frames cv::split can split your color image into 3 channels, blue, green and red cv::absdiff can calculate the absolute difference between any two images cv::sum can calculate the sum of an image So.. get frames from the video inside a loop, using cv::videocapture. Compare the previous frame with the current frame, by calculating the difference image using cv::absdiff (you may need to split the images into bgr components using cv::split, and compare them seperately). Calculate the sum using cv::sum. If the sum exceeds a threshold value that you decide, then you can conclude that the car is moving between the two frames. If you want, you can save the values inside an array or vector, and draw a nice plot of the activity.

Keba gravatar imageKeba ( 2013-03-04 21:24:13 -0600 )edit

Question Tools

Stats

Asked: 2013-02-22 14:16:25 -0600

Seen: 585 times

Last updated: Feb 22 '13