介绍
多目标跟踪(MOT)技术在视频分析和计算机视觉领域扮演着至关重要的角色,它的主要任务是在视频序列中跟踪多个对象。MOT通常涉及两个主要阶段:目标检测和数据关联。
首先,目标检测阶段通过图像处理技术识别视频中的多个对象,比如识别出路上的行人。然后,在数据关联阶段,算法需要将连续帧中检测到的对象正确关联起来,形成对象的运动轨迹。如下图所示:
常用的常用的跟踪方法包括基于卡尔曼滤波的追踪、深度学习方法等。深度学习方法在处理大量复杂数据时显示出强大的性能,比如用ResNet对行人图片进行特征提取。
接下来的内容主要介绍如何以下两个核心评价指标:多目标跟踪准确率(Multiple Object Tracking Accuracy, MOTA)和IDF1(ID F1 Score, IDF1)。
评价指标公式
Multiple Object Tracking Accuracy, MOTA
MOTA是一种广泛使用的评价指标,用于衡量多目标跟踪算法的整体性能。它综合考虑了三种错误类型:误检(false positives)、漏检(false negatives)和身份交换(identity switches)。MOTA的计算公式如下:
M
O
T
A
=
1
−
∑
t
(
F
N
t
+
F
P
t
+
I
D
S
W
t
)
∑
t
G
T
t
MOTA = 1-\frac{\sum_t (FN_t+FP_t+IDSW_t)}{\sum_t GT_t}
MOTA=1−∑tGTt∑t(FNt+FPt+IDSWt)
其中, F N t FN_t FNt 是第 t t t 帧的漏检数量,FP是误检数量,IDSW是身份交换的次数,而 GT是实际的目标数量。
# ref: https://github.com/cheind/py-motmetrics/blob/7210fcce0be1b76c96a62f6fe4ddbc90d944eacb/motmetrics/metrics.py#L563
def mota(df, num_misses, num_switches, num_false_positives, num_objects):
"""Multiple object tracker accuracy."""
del df # unused
return 1.0 - math_util.quiet_divide(
num_misses + num_switches + num_false_positives, num_objects
)
IDF1
IDF1是评估多目标跟踪中身份保持一致性的重要指标。 F1分数是精确度(precision)和召回率(recall)的调和平均。在多目标跟踪的背景下,精确度是指正确识别的身份占所有识别身份的比例,而召回率是指正确识别的身份占所有实际身份的比例。IDF1的计算公式如下:
I
D
F
1
=
2
×
I
D
T
P
2
×
I
D
T
P
+
I
D
F
P
+
I
D
F
N
IDF1=\frac{2\times IDTP}{2\times IDTP + IDFP + IDFN}
IDF1=2×IDTP+IDFP+IDFN2×IDTP
其中,IDTP(True Positives)是正确匹配的身份数量,IDFP(False Positives)是错误匹配的身份数量,而 IDFN(False Negatives)是漏检的身份数量。
# ref: https://github.com/cheind/py-motmetrics/blob/7210fcce0be1b76c96a62f6fe4ddbc90d944eacb/motmetrics/metrics.py#L743
def idf1(df, idtp, num_objects, num_predictions):
"""ID measures: global min-cost F1 score."""
del df # unused
return math_util.quiet_divide(2 * idtp, num_objects + num_predictions)
计算评价指标
可以使用py-motmetrics
库。这个库提供了一个简单API来计算多目标跟踪指标。
py-motmetrics定义了以下几种事件类别:
'MATCH'
a match between a object and hypothesis was found'SWITCH'
a match between a object and hypothesis was found but differs from previous assignment (hypothesisid != previous)'MISS'
no match for an object was found'FP'
no match for an hypothesis was found (spurious detections)'RAW'
events corresponding to raw input'TRANSFER'
a match between a object and hypothesis was found but differs from previous assignment (objectid != previous)'ASCEND'
a match between a object and hypothesis was found but differs from previous assignment (hypothesisid is new)'MIGRATE'
a match between a object and hypothesis was found but differs from previous assignment (objectid is new)
参考资料:
https://github.com/cheind/py-motmetrics/blob/develop/motmetrics/mot.py