我需要从 CSV 文件中绘制轮廓,我单独获取每个 x,y 列表,但我需要创建元组以将它们用于折线函数,但我得到了'int' object is not iterable
!
代码:
import numpy as np
import cv2
import matplotlib.pyplot as plt
image5= cv2.imread("C:/Users/Pc/Desktop/code prjt/5_Vesicule.jpg")
cv2.imshow("im",image5)
cv2.waitKey()
centrev5 = pd.read_csv("C:/Users/Pc/Desktop/code prjt/centrev5.csv",sep=";")
print(centrev5)
cx=int(centrev5.get(['centreX'][0]) )
cy =int(centrev5.get(['centreY'][0]))
image = cv2.circle(image5, (cx,cy), radius=0, color=(255, 0, 0), thickness=10)
cv2.imshow("centre",image)
cv2.waitKey()
point5 = pd.read_csv("C:/Users/Pc/Desktop/code prjt/point5.csv",sep=";")
print(point5)
for i in range(len(point5)):
x=int(point5.values[i][1])
y=int(point5.values[i][2])
# transform x,y vectors to tuples
c = [tuple(x), tuple(y)]
img = cv2.polylines(image5, c, 1, (0,0,255),4)
cv2.imshow("contour",image5)
cv2.waitKey()
#print(c)
#c = [i for i in zip(x, y)]
#c = list(zip(x,y))
#[(x[i],y[i]) for i in range(min(len(x),len(y)))]