如何解决在使SORT适应mp4视频的实时检测时遇到问题
我正在使用SORT算法的开源版本https://github.com/abewley/sort来跟踪mp4视频上的对象。
我在sort.py
中遇到了与此功能有关的问题
def associate_detections_to_trackers(detections,trackers,iou_threshold=0.3):
"""
Assigns detections to tracked object (both represented as bounding boxes)
Returns 3 lists of matches,unmatched_detections and unmatched_trackers
"""
if (len(trackers) == 0):
return np.empty((0,2),dtype=int),np.arange(len(detections)),np.empty((0,5),dtype=int)
iou_matrix = np.zeros((len(detections),len(trackers)),dtype=np.float32)
for d,det in enumerate(detections):
for t,trk in enumerate(trackers):
iou_matrix[d,t] = iou(det,trk)
matched_indices = linear_assignment(-iou_matrix)
unmatched_detections = []
for d,det in enumerate(detections):
if (d not in matched_indices[0]):
unmatched_detections.append(d)
unmatched_trackers = []
for t,trk in enumerate(trackers):
if (t not in matched_indices[1]):
unmatched_trackers.append(t)
# filter out matched with low IOU
matches = []
for m in matched_indices:
if (iou_matrix[m[0],m[1]] < iou_threshold):
unmatched_detections.append(m[0])
unmatched_trackers.append(m[1])
else:
#THIS LINE
matches.append(m.reshape(1,2))
if (len(matches) == 0):
matches = np.empty((0,dtype=int)
else:
matches = np.concatenate(matches,axis=0)
return matches,np.array(unmatched_detections),np.array(unmatched_trackers)
我遇到以下错误ValueError: cannot reshape array of size 14 into shape (1,2)
。将匹配的索引附加到匹配的数组时,会发生这种情况。我知道为什么会发生这种情况,但是我不明白为什么作者将数组改形为1、2,因为匹配索引的大小未知?由于我不熟悉状态估计算法或数据关联,因此在调试该程序并真正了解该算法的功能时遇到了问题。有什么建议吗?
我要适应的项目在这里https://github.com/sftwre/ObjectDetection。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。