Qidian213 / deep_sort_yolov3

Real-time Multi-person tracker using YOLO v3 and deep_sort with tensorflow
GNU General Public License v3.0
1.66k stars 596 forks source link

Problem In Object Counting #116

Open ykshitij opened 5 years ago

ykshitij commented 5 years ago

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.

primepake commented 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)

ykshitij commented 5 years ago

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.

primepake commented 5 years ago

You can calculate the centroid and append to list, get list[-1] with current frame

ykshitij commented 5 years ago

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

primepake commented 5 years ago

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

primepake commented 5 years ago

Or IOU can be solve your problem

hongsamvo commented 4 years ago

I think this repo can help you https://github.com/guillelopez/python-traffic-counter-with-yolo-and-sort

alexmihalyk23 commented 4 years ago

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)