how to associating the detections corresponding to the same object over time

hi everyone I have a project that I want to calculate speed and counting vehicle in a video. I have done the Background subtraction step, now I want to associating the detections corresponding to the same object over time. I read this tutorial http://www.mathworks.com/help/vision/examples/motion-based-multiple-object-tracking.html and the result of that code is what I want to but in the first step, I want to replace the foreground detection step that code by my background subtraction. may you help me?

 Accepted Answer

Hi Hai,
you can put your own background subtraction code into the detectObjects replacing the code that computes the mask.

3 Comments

hi Dima Lisin thanks for you answer. I try to do that but It alway error. can you tell me why after I run that code, I don't see any variables appear in workspace. I read video by using "vid = VideoReader('HVT_2.avi');" and I use "for loop" to read to end video, while they use obj.reader = vision.VideoFileReader('HVT_2.avi'); and "while ~isDone" to read to end video. when I replace it by my code, It ERROR.
Hard to say without seeing your entire code. The reason you do not see any variables, is because this example is a function, not a script. If you want to use VideoReader instead of vision.VideoFileReader, then you have to use the readFrame method to read a frame, and the hasFrame method to check if there are any frames left. Look at the documentation for VideoReader. By the way, is there any reason you don't want to use vision.VideoFileReader? Can you run the example as is?
Thanks Dima Lisin. I don't use vision.VideoFileReader just because I used VideoReader from I started with Image processing and I want to keep my background subtraction method. I am a amatuer so It will tale me along time to restart with computer vision toolbox ( It is a little bit complicated with me ).
I tried to replaced detectObjects by my background subtraction, but I can't. I attached my code, can you help me to replace my code by detectObjects of the code in the link.
if you can, may you help me to revise the code in the link become a script that can easier to learn from that.

Sign in to comment.

More Answers (0)

Categories

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

Asked:

on 8 Sep 2014

Commented:

on 22 Sep 2014

Community Treasure Hunt

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

Start Hunting!