#排序操作
def compare(a, b):
# 计算中心点
a_center_x = a[1]["x"] + a[1]["w"] / 2
a_x = a[1]["x"]
a_center_y = a[1]["y"] + a[1]["h"] / 2
a_y = a[1]["y"]
b_center_x = b[1]["x"] + b[1]["w"] / 2
b_x = b[1]["x"]
b_center_y = b[1]["y"] + b[1]["h"] / 2
b_y = b[1]["y"]
a_height = a[1]["h"] / 2
# a_height = 2*a[1]["h"] / 3
if abs(a_center_y - b_center_y) < a_height:
# 同行:返回-1,代表排序保持不变
# 返回1,代表交换顺序
if a_x < b_x:
return -1
elif a_x > b_x:
return 1
else:
if a_y > b_y :
return 1
else:
return -1
handwrite=[('FB009', {'w': 96, 'h': 70, 'x': 134, 'y': 200}), ('果国道支行', {'w': 132, 'h