Open ykshitij opened 5 years ago
Hi, track_id is useful for counting. you can count people with a line that you defined with boxes of track_id (x_min,y_min, x_max, y_max) convert to centroid((x_max+x_min)/2, (y_max+y_min)/2)
Hi, Using this I can calculate the position of current centroid, but I also need the position of previous frame centroid. To know that it has crossed the line, I need the previous and current centroid to be on the opposite side of line.
You can calculate the centroid and append to list, get list[-1] with current frame
I tried this, but when there are multiple objects in one frame, you also need to know which previous centroid is related to which object. Bounding Box of each detected objects is calculated inside one loop, so inside that only you need to find the previous centroid. You cannot even use ID to store the list of centroids for each object, as it would not be proper in case of unstable ID's
I should read all knowledge of deep sort and then you can solve it, because Deep sort use euclidean to calculate the centroid to nearest centriod to matching together. each object has a list of centriod of them
Or IOU can be solve your problem
I think this repo can help you https://github.com/guillelopez/python-traffic-counter-with-yolo-and-sort
you can add list
tr = [] #add before main function
for track in tracker.tracks:
if not track.is_confirmed() or track.time_since_update > 1:
continue
if track.track_id not in tr:
tr.append(track.track_id)
I wanted to Use this Code for people Counting. As the person crosses a hypothetical line I want it to be counted, and for the same I want the information for previous centroid. Is there any way I can get the previous memory. Also can you suggest a method to use this code for counting. The ID cannot be used for counting.