物体交叉检测---IoU评价指标的计算

对于物体检测的结果不管是HOG+SVM,还是deep learnning 检测到的结果,我们如何去评价我们检测的好坏?

一、Jason 提出了IoU---Intersection over Union 来评估物体检测的好坏,IoU算法很简单,其计算条件如下:

1、物体的ground truth bounding box

2 、预测的bounding box

如图:

计算公式如下:

def check_box(box):
    x1,y1,x2,y2=box
    if x2>x1 and y2>y1:
        return 1
    else:
        return 0
def compute_IoU(box1,box2):
    if check_box(box1) and check_box(box2):
        x1,y1,x2,y2=box1
        x_1,y_1,x_2,y_2=box2
        xA=max(x1,x_1)
        yA=max(y1,y_1)
        xB=min(x2,x_2)
        yB=min(y2,y_2)
        overlap_area=max(0,xB-xA+1)*max(0,yB-yA+1)
        union_area=max(0,y2-y1+1)*max(0,x2-x1+1)+max(0,y_2-y_1+1)*max(0,x_2-x_1+1)-overlap_area
    return overlap_area/union_area
if __name__=="__main__":
    box1=[39,63,203,112] #左下角,右上角
    box2=[54,66,198,114]
    print(compute_IoU(box1,box2))

二、算出来的IoU,它如何评价尼?

通常情况下,IoU>0.5我们则认为其实好的检测

三、ground truth 从何而来?

我们将数据集分为训练集合测试集以及交叉验证集,我们将手动label的称为ground truth,然后再测试集上计算其IoU

猜你喜欢

转载自blog.csdn.net/qq_15642411/article/details/81662042