def IouDo(box,boxs,mode='UNIUM'):
#获得这一批建议框的坐标
_x1 = boxs[:,0]
_y1 = boxs[:,1]
_x2 = boxs[:,2]
_y2 = boxs[:,3]
#获取交集的坐标
x1 = np.maximum(box[0],_x1)
y1 = np.maximum(box[1],_y1)
x2 = np.minimum(box[2],_x2)
y2 = np.minimum(box[3],_y2)
#计算交集的宽和高
w = np.maximum(0,x2-x1)
h = np.maximum(0,y2-y1)
#计算交集的面积
area = w*h
#计算并集的面积
Area = (box[2]-box[0])*(box[3]-box[1])+(_x2-_x1)*(_y2-_y1)-area
#计算交并比
if mode == 'UNIUM':
unium_area = np.true_divide(area,Area)
return unium_area
#计算最小值除以并集
else:
min_area = np.true_divide(np.minimum((box[2] - box[0]) * (box[3] - box[2]), (_x2 - _x1) * (_y2 - _y1)),Area)
return min_area
IOU的计算
猜你喜欢
转载自blog.csdn.net/weixin_38241876/article/details/91849693
今日推荐
周排行