注意:
python2对于除法的规则是取整
python3则会保留小数点后的位数。
如果你在使用python2执行下列代码出现结果为0的情况,请对除数或被除数使用float()函数转换为浮点型即可。见代码
# encoding:utf-8
# this file is used to calculate IOU
# rec = [left,right,bottom,top]
def calculateIOU(rec1,rec2):
intersect_l = max(rec1[0],rec2[0])
intersect_r = min(rec1[1],rec2