I'm working on a project where i have to detect colored cars form video frames taken from Bird's eye view.
For detection i used Histogram backprojection to obtain a binary image that suppose to contain only the target region of interest.
The process works fine until i tried to generalize the detection by testing it on video that contains object with similar color distribution ( like me crawling under the table and parts of my T-shirts are visible)
As you can see, both car and irrelevant objects are moving and the detection results are:
As you see irrelevant objects that share similar color distribution are shown in the binary images. However, thanks to Stack overflow experts i could improve the detection by telling the algorithm to choose the blob that represents the target object by adding the following constraints:
1-Rectangularity check 2-area and ratio check
with above constraints i could get rid of large irrelevant objects that are detected. However, for small object (see binary images), it doesn't work that much as the rectangularity for the target object (small red car) ranges between (0.72 and 1) and the small irrelevant objects do fall in this range. So i decided to add another constraint which calculating the distance between centroids of the car moving every 5 successive frames and threshold depending on that distance by doing the flowing:
import scipy.spatial.distance
from collections import deque
#defining the Centroid
centroids=deque(maxlen=40) #double ended queue containing the detected centroids
.
.
.
centroids.appendleft(center)
#center comes from detection process. e.g centroids=[(120,130), (125,132),...
Distance = scipy.spatial.distance.euclidean(pts1_red[0], pts1_red[5])
if D<=50:
#choose that blob
So tested that on different videos and turns out the the distance between the centroids ranges between 0 and 50 (0 when the car stops).
So my question is:
Is there a way i can invest this property so that it helps enhancing the detection in such a way so that the detection ignores the T-shirt?, Since when the car is no longer visible and the irrelevant object stays it will calculate the distance difference of the irrelevant object and this distance will get small till it is less than 50!
Thanks in Advance



















