Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box)
function DecideOberlap(BBox_x1, BBox_y1, BBox_x2, BBox_y2, BBox_gt_x1, BBox_gt_y1, BBox_gt_x2, BBox_gt_y2) x1 = BBox_x1;
y1 = BBox_y1;
width1 = BBox_x2 - BBox_x1;
height1 = BBox_y2 - BBox_y1; x2 = BBox_gt_x1;
y2 = BBox_gt_y1;
width2 = BBox_gt_x2 - BBox_gt_x1;
height2 = BBox_gt_y2 - BBox_gt_y1; endx = math.max(x1+width1, x2+width2);
startx = math.min(x1, x2);
width = width1 + width2 - (endx - startx); endy = math.max(y1 + height1, y2 + height2);
starty = math.min(y1, y2);
height = height1 + height2 - (endy - starty); if width<= or height<= then
ratio = ;
else
Area = width*height;
Area1 = width1*height1;
Area2 = width2*height2;
ratio = Area/Area1;
end return ratio end