# 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:

1. At first frame, store all (cx,cy,id)
2. Next frame, calculate distance each new (cx,cy) with each of old (cx,cy)
3. If distance < threshold, update the old (cx,cy) which qualify the formula
4. If distance > 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?

• Looks good. Suggested alternative technique in answer. Jan 18, 2015 at 2:02
• What if the number of centroids increase or decrease? Jan 5, 2017 at 22:03
{"ft_lang_label":"__label__en","ft_lang_prob":0.86422575,"math_prob":0.8731889,"size":706,"snap":"2022-05-2022-21","text_gpt3_token_len":187,"char_repetition_ratio":0.123931624,"word_repetition_ratio":0.0,"special_character_ratio":0.26203966,"punctuation_ratio":0.18125,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96570265,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-23T05:15:34Z\",\"WARC-Record-ID\":\"<urn:uuid:11fde628-9db7-491c-8f10-c3f61b2f46e8>\",\"Content-Length\":\"231534\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eaee82b7-c196-49de-b333-79ae77aa451f>\",\"WARC-Concurrent-To\":\"<urn:uuid:8c43fc5b-ff8a-45a3-99f0-ec66b52647e7>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://dsp.stackexchange.com/questions/20042/is-my-algorithm-about-blob-tracking-for-vehicle-following-correct\",\"WARC-Payload-Digest\":\"sha1:N7F2E3XA7ZTG3N4PLJNO2R5IJZ675OZH\",\"WARC-Block-Digest\":\"sha1:7AVF7ECX7YDDKFQNMIEXJ45WHHW3SFQF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662555558.23_warc_CC-MAIN-20220523041156-20220523071156-00344.warc.gz\"}"}