【发布时间】:2021-11-08 16:47:52
【问题描述】:
我尝试在边界框上添加链接上对象跟踪器的分数:https://github.com/pinczakko/yolov4-deepsort
如何从 track 对象中获取分数?这里是处理检测的方法:
def process_detections(tracker, detections, nms_max_overlap, frame):
"""
Process objects detected by YOLO with deepsort
Returns processed frame
"""
#initialize color map
cmap = plt.get_cmap('tab20b')
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
# run non-maxima supression
boxs = np.array([d.tlwh for d in detections])
scores = np.array([d.confidence for d in detections])
classes = np.array([d.class_name for d in detections])
indices = preprocessing.non_max_suppression(boxs, classes, nms_max_overlap, scores)
detections = [detections[i] for i in indices]
# Call the tracker
tracker.predict()
tracker.update(detections)
# update tracks
for track in tracker.tracks:
if not track.is_confirmed() or track.time_since_update > 1:
continue
bbox = track.to_tlbr()
class_name = track.get_class()
# draw bbox on screen
color = colors[int(track.track_id) % len(colors)]
color = [i * 255 for i in color]
cv2.rectangle(frame, (int(bbox[0]), int(bbox[1])), (int(bbox[2]), int(bbox[3])), color, 1)
cv2.rectangle(frame, (int(bbox[0]), int(bbox[1]-30)),
(int(bbox[0])+(len(class_name)+len(str(track.track_id)))*17, int(bbox[1])), color, -1)
cv2.putText(frame, class_name + "-" + str(track.track_id),(int(bbox[0]),
int(bbox[1]-10)),0, 0.5, (255,255,255), 1)
# if enable info flag then print details about each track
if FLAGS.info:
print("Tracker ID: {}, Class: {}, BBox Coords (xmin, ymin, xmax, ymax): {}".format(str(track.track_id),
class_name, (int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3]))))
return frame
【问题讨论】:
-
所以...您需要弄清楚哪个检测与哪个轨道相匹配?深入研究存储库的代码。 update 函数使用了一个 _match 函数。我建议更改代码,以便它返回匹配项,以便您可以使用信息。
标签: python opencv deep-learning yolo yolov4