@@ -39,18 +39,11 @@ def update(self, output_results, img, ori_img):
3939 categories = output_results [:, - 1 ]
4040
4141 remain_inds = scores > self .args .conf_thresh
42- inds_low = scores > 0.1
43- inds_high = scores < self .args .conf_thresh
44-
45- inds_second = np .logical_and (inds_low , inds_high )
46- dets_second = bboxes [inds_second ]
4742 dets = bboxes [remain_inds ]
4843
4944 cates = categories [remain_inds ]
50- cates_second = categories [inds_second ]
5145
5246 scores_keep = scores [remain_inds ]
53- scores_second = scores [inds_second ]
5447
5548 if len (dets ) > 0 :
5649 '''Detections'''
@@ -68,7 +61,7 @@ def update(self, output_results, img, ori_img):
6861 else :
6962 tracked_tracklets .append (track )
7063
71- ''' Step 2: First association, with high score detection boxes '''
64+ ''' Step 2: First association, with small buffer IoU '''
7265 tracklet_pool = joint_tracklets (tracked_tracklets , self .lost_tracklets )
7366
7467 # Predict the current location with Kalman
@@ -89,40 +82,29 @@ def update(self, output_results, img, ori_img):
8982 track .re_activate (det , self .frame_id , new_id = False )
9083 refind_tracklets .append (track )
9184
92- ''' Step 3: Second association, with low score detection boxes'''
93- # association the untrack to the low score detections
94- if len (dets_second ) > 0 :
95- '''Detections'''
96- detections_second = [Tracklet_w_bbox_buffer (tlwh , s , cate , motion = self .motion ) for
97- (tlwh , s , cate ) in zip (dets_second , scores_second , cates_second )]
98- else :
99- detections_second = []
100- r_tracked_tracklets = [tracklet_pool [i ] for i in u_track if tracklet_pool [i ].state == TrackState .Tracked ]
85+ unmatched_tracklets = [tracklet_pool [i ] for i in u_track if tracklet_pool [i ].state == TrackState .Tracked ]
86+ unmatched_detections = [detections [i ] for i in u_detection ]
10187
88+ '''Step 3: Second association, with large buffer IoU'''
10289
103- dists = buffered_iou_distance (r_tracked_tracklets , detections_second , level = 2 )
90+ dists = buffered_iou_distance (unmatched_tracklets , unmatched_detections , level = 2 )
91+
92+ matches , u_track , u_detection = linear_assignment (dists , thresh = 0.5 )
10493
105- matches , u_track , u_detection_second = linear_assignment (dists , thresh = 0.5 )
10694 for itracked , idet in matches :
107- track = r_tracked_tracklets [itracked ]
108- det = detections_second [idet ]
95+ track = unmatched_tracklets [itracked ]
96+ det = unmatched_detections [idet ]
10997 if track .state == TrackState .Tracked :
11098 track .update (det , self .frame_id )
11199 activated_tracklets .append (track )
112100 else :
113101 track .re_activate (det , self .frame_id , new_id = False )
114102 refind_tracklets .append (track )
115103
116- for it in u_track :
117- track = r_tracked_tracklets [it ]
118- if not track .state == TrackState .Lost :
119- track .mark_lost ()
120- lost_tracklets .append (track )
121-
122104 '''Deal with unconfirmed tracks, usually tracks with only one beginning frame'''
123- detections = [detections [i ] for i in u_detection ]
105+ detections = [unmatched_detections [i ] for i in u_detection ]
124106 dists = buffered_iou_distance (unconfirmed , detections , level = 1 )
125-
107+
126108 matches , u_unconfirmed , u_detection = linear_assignment (dists , thresh = 0.7 )
127109
128110 for itracked , idet in matches :
@@ -133,15 +115,15 @@ def update(self, output_results, img, ori_img):
133115 track .mark_removed ()
134116 removed_tracklets .append (track )
135117
136- """ Step 4: Init new tracklets"""
118+ ''' Step 4. Inital new tracks'''
137119 for inew in u_detection :
138120 track = detections [inew ]
139121 if track .score < self .det_thresh :
140122 continue
141123 track .activate (self .frame_id )
142124 activated_tracklets .append (track )
143125
144- """ Step 5: Update state"""
126+ ''' Step 5: Update state'''
145127 for track in self .lost_tracklets :
146128 if self .frame_id - track .end_frame > self .max_time_lost :
147129 track .mark_removed ()
0 commit comments