如何使用 python 遍历传递给函数参数的列表?
How to iterate through a list passed to a function parameter with python?
我正在尝试使用 python 在带有 opencv 和 python 的图像上的大量坐标处绘制框。我有 2 个列表,其中包含框的起点和终点的坐标。
startxy = [(0,0), (1,0), (2,0), ...etc.]
endxy = [(1,1), (2,1), (3,1), ...etc.]
cv2.rectangle(img, startxy[0?], endxy[0?], color, thickness)
我知道我需要在递增坐标列表的索引时一遍又一遍地调用矩形函数,但我是 python 的新手,并且正在努力解决如何递增这些值并将这些值传递给矩形函数。
遍历两个列表的 zip:
startxy = [(0,0),(1,0),(2,0),...etc.]
endxy = [(1,1),(2,1),(3,1),...etc.]
for start, end in zip(startxy, endxy):
cv2.rectangle(img, start, end, color, thickness)
我正在尝试使用 python 在带有 opencv 和 python 的图像上的大量坐标处绘制框。我有 2 个列表,其中包含框的起点和终点的坐标。
startxy = [(0,0), (1,0), (2,0), ...etc.]
endxy = [(1,1), (2,1), (3,1), ...etc.]
cv2.rectangle(img, startxy[0?], endxy[0?], color, thickness)
我知道我需要在递增坐标列表的索引时一遍又一遍地调用矩形函数,但我是 python 的新手,并且正在努力解决如何递增这些值并将这些值传递给矩形函数。
遍历两个列表的 zip:
startxy = [(0,0),(1,0),(2,0),...etc.]
endxy = [(1,1),(2,1),(3,1),...etc.]
for start, end in zip(startxy, endxy):
cv2.rectangle(img, start, end, color, thickness)