@@ -75,7 +75,8 @@ def detect(save_img=False):
7575
7676 #........Rand Color for every trk.......
7777 rand_color_list = []
78- for i in range (0 ,5005 ):
78+ amount_rand_color_prime = 5003 # prime number
79+ for i in range (0 ,amount_rand_color_prime ):
7980 r = randint (0 , 255 )
8081 g = randint (0 , 255 )
8182 b = randint (0 , 255 )
@@ -204,7 +205,7 @@ def detect(save_img=False):
204205 int (track .centroidarr [i ][1 ])),
205206 (int (track .centroidarr [i + 1 ][0 ]),
206207 int (track .centroidarr [i + 1 ][1 ])),
207- rand_color_list [track .id ], thickness = 2 )
208+ rand_color_list [track .id % amount_rand_color_prime ], thickness = 2 )
208209 for i ,_ in enumerate (track .centroidarr )
209210 if i < len (track .centroidarr )- 1 ]
210211 #draw same color tracks
@@ -234,8 +235,10 @@ def detect(save_img=False):
234235 identities = tracked_dets [:, 8 ]
235236 categories = tracked_dets [:, 4 ]
236237 draw_boxes (im0 , bbox_xyxy , identities , categories , names , save_with_object_id , txt_path )
237- #........................................................
238-
238+ else : #SORT should be updated even with no detections
239+ tracked_dets = sort_tracker .update ()
240+ #........................................................
241+
239242 # Print time (inference + NMS)
240243 print (f'{ s } Done. ({ (1E3 * (t2 - t1 )):.1f} ms) Inference, ({ (1E3 * (t3 - t2 )):.1f} ms) NMS' )
241244
0 commit comments