Is my algorithm about blob tracking for vehicle following correct? I'm doing vehicles tracking project. The video is a one-way, no vehicles occlusion.
After doing background subtraction, erosion and dilation, I get bounding box objects for each frame, and I can find $centroid(c_x,c_y)$ from that.
So, the next thing I want to do is blobs tracking. Here is what I'm thinking on how to do the blobs tracking:


At first frame, store all (cx,cy,id)
Next frame, calculate distance each new (cx,cy) with each of old (cx,cy)
If distance &lt; threshold, update the old (cx,cy) which qualify the formula
If distance &gt; threshold, check if the cx,cy is near the entry coordinate (e.g. around x,y=0-640,0-40), if yes store new (cx,cy).


Is it right and possible to apply to tracking?
You might want to consider tracking using MeanShift &amp; Cam Shift:

http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_meanshift/py_meanshift.html#meanshift