简介
python实现目标检测矩形框合并,将同一类相邻的目标物合并到一起
代码实现
def rect_distance(x1, y1, x1b, y1b, x2, y2, x2b, y2b):
"""
计算两个矩形框的距离
input:两个矩形框,分别左上角和右下角坐标
return:像素距离
"""
left = x2b < x1
right = x1b < x2
bottom = y2b < y1
top = y1b < y2
if top and left:
return dist(x1, y1b, x2b, y2)
elif left and bottom:
return dist(x1, y1, x2b, y2b)
elif bottom and right:
return dist(x1b, y1, x2, y2b)
elif right and top:
return dist(x1b, y1b, x2, y2)

最低0.47元/天 解锁文章
121





