.txt坐标保存格式:分行保存,每行为一点的(x,y)坐标,每四行(四对坐标)构成一个矩形框的四个点。

.txt坐标保存格式:分行保存,每行为一点的(x,y)坐标,每四行(四对坐标)构成一个矩形框的四个点。

rec=[]
r=[]
with open(path,'r') as file:
i=0
for line in file:
s=line.split()
x=float(s[0])
y=float(s[1])
r.append([x,y])
i+=1
if i==4:
rec.append(r)
r=[]
i=0