代码拉取完成,页面将自动刷新
distance_x = 0
distance_y = 0
old_list = []
add_points = []
old_,new_ = [],[]
class PointList:
def __init__(self):
self.baseline = []
def get_baseline(self):
return self.baseline
def old2new_list(self,new_list):
global old_list
tmp = []
if not old_list:
old_list = self.baseline
print("not old_list")
else:
tmp = old_list
old_list = new_list
return tmp
def get_xy_change(self,old_list,new_list):
global distance_x,distance_y
x,y=0,0
# old2new_lists = self.old2new_list(new_list)
print("len",len(old_list))
for i in range(len(old_list)):
x += abs(old_list[i][0] - new_list[i][0] )
y += abs(old_list[i][1] - new_list[i][1] )
xx = round(x/len(old_list),1)
yy = round(y/len(old_list),1)
distance_x += xx
distance_y += yy
# self.old2new_list(new_list)
return xx,yy#保留两位小数
#新旧点比较,目前实现添加新点,但是没有删除旧点和更新x,y值
def old2new_points(self,old_list,new_list):
# i = []
# j=0
old_lists = self.old2new_list(old_list)
# x,y = self.get_xy_change(old_list,new_list)
# print("old_lists\n",old_lists)
# print("new_list",new_list)
global add_points,old_,new_
for points in new_list:
# j += 1
key = list(tuple(points))
is_old_point = False
for existing_key in old_lists:
if abs(existing_key[0] - key[0]) < 100 and abs(existing_key[1] - key[1]) < 100:
old_.append([existing_key[0],existing_key[1]])
new_.append([key[0],key[1]])
is_old_point = True
break
if (not is_old_point) :#如果有新点出现,则将新点加上偏差值,其余保持不变
# x,y = self.get_xy_change(old_,new_)
# key[0] += distance_x
# key[1] += distance_y
# self.baseline.append(key)
add_points.append(key)
x,y = self.get_xy_change(old_,new_)
if len(add_points):
for i in range(len(add_points)):
add_points[i][0] += distance_x
add_points[i][1] += distance_y
self.baseline.extend(add_points)
add_points ,old_,new_ = [], [], []
return x,y
# self.baseline = self.baseline
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。