Calculating percentage of Bounding box overlap, for image detector evaluation

后端 未结 7 1993
遥遥无期
遥遥无期 2020-12-05 01:17

In testing an object detection algorithm in large images, we check our detected bounding boxes against the coordinates given for the ground truth rectangles.

Accordi

相关标签:
7条回答
  • 2020-12-05 01:40

    A Simple way

    (Image is not drawn to scale)

    from shapely.geometry import Polygon
    
    
    def calculate_iou(box_1, box_2):
        poly_1 = Polygon(box_1)
        poly_2 = Polygon(box_2)
        iou = poly_1.intersection(poly_2).area / poly_1.union(poly_2).area
        return iou
    
    
    box_1 = [[511, 41], [577, 41], [577, 76], [511, 76]]
    box_2 = [[544, 59], [610, 59], [610, 94], [544, 94]]
    
    print(calculate_iou(box_1, box_2))
    

    The result will be 0.138211... which means 13.82%.

    0 讨论(0)
提交回复
热议问题