Torch calculation of overlapping area of two rectangular frames (IoU between tow bounding box)
1 function Decideoberlap (bbox_x1, Bbox_y1, bbox_x2, Bbox_y2, bbox_gt_x1, Bbox_gt_y1, bbox_gt_x2, Bbox_gt_y2)2 3X1 =bbox_x1;4Y1 =bbox_y1;5Width1 = bbox_x2-bbox_x1;6height1 = Bbox_y2-bbox_y1;7 8x2 =bbox_gt_x1;9y2 =bbox_gt_y1;TenWidth2 = bbox_gt_x2-bbox_gt_x1; OneHeight2 = Bbox_gt_y2-bbox_gt_y1; A -EndX = Math.max (x1+width1, x2+width2); -StartX =math.min (x1, x2); thewidth = width1 + width2-(EndX-startx); - -Endy = Math.max (y1 + height1, y2 +height2); -Starty =math.min (y1, y2); +Height = height1 + height2-(Endy-starty); - + ifwidth<=0or height<=0 Then ARatio =0; at Else -Area = width*height; -AREA1 = width1*height1; -AREA2 = width2*height2; -Ratio = area/Area1; - End in - returnratio to +End
Torch calculation of overlapping area of two rectangular frames (IoU between tow bounding box)