To detect a moving object in a video feed with constantly changing background

My intention is to capture real time video sequence from a camera fixed atop a moving car, and scan continuously for any intrusion (object) on the road. On detecting the object,there are some inputs to be provided to a micro controller for further action.
My question is, Since the background of the image is constantly changing (ie the road) , how does my camera know that the object entering the frame is the intrusion and not my changing landscape?
how do I start exactly? Please help. Any pointers would be appreciated.

 Accepted Answer

Did you search the forum and mathworks.com for "tracking"? There are numerous discussions and examples.

4 Comments

Image Analyst,
I am new at this so please do forgive me if my comment seems senseless.
Let me just explain my question further.
There is a fixed camera which is taking in the video feed for the whole time the vehicle is moving. As long as the roads are empty, I do not want the driver to be able to honk. So all I want to do is detect if there is a foreign object in my frame apart from the background (which is ,another vehicle) . Tracking would imply that I am interested in the motion of the foreign object right?
(I did search for it though and there's a lot of topics out there which sound similar yet are different so basically my mind is boggled and confused more than what it was before posting this question)
This is not my field, but think through how you separate what you see when you are driving into "harmless background road" and "intruding object of concern". That tells you what your algorithm should do. Perhaps the object's color is different from the pavement color averaged over the last several frames, or perhaps it casts a shadow that creates a sharper edge in the image compared to the smoother variations of the pavement, or...? I am assuming the object is stationery, like a rock in the road.
Well you might just have to spend some time learning about it. One simple way to find background is to take the mode gray level over a long time. But I think most sophisticated methods use Gaussian Mixture Models, though it's not my filed so I'm not really sure of the advantages and disadvantages of the various ways. Once you have the background, you can cast both the image and your background image to single (so subtracting won't clip at zero), and then subtract the images and look for pixels above some threshold value. Then clean it up some using bwareaopen() to get rid of small noise specks or tiny objects you don't care about. Then call regionprops() to measure things about the objects that are left. I'm sure you'll learn more and make that general algorithm better once you get into it.
This sort of helps! Thresholding , subtracting and cleaning it up. Will try it out on a smaller video .

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!