如何修复 python 中的'TypeError: cannot unpack non-iterable numpy.float64 object'错误


9         break
10     else:
---> 11         result = pipeline(frame)
12         cv2.imshow("Frame", result)
13         key = cv2.waitKey(1) & 0xFF
<ipython-input-2-d9c587a1d603> in pipeline(image)

90     ### Draw lines and return final image
91     line_img = np.copy((image)*0)
---> 92     draw_lines(line_img, lines, thickness=10)
93 
94     line_img = region_of_interest(line_img, v)
<ipython-input-2-d9c587a1d603> in draw_lines(image, lines, color, thickness)

26 def draw_lines(image, lines, color=[255, 0, 0], thickness=4):
27     for line in lines:
---> 28         for x1, y1, x2, y2 in line:
29             cv2.line(image, (x1, y1), (x2, y2), color, thickness)
30 

类型错误:无法解压缩不可迭代的 numpy.float64 对象

我想从车道列表中获得车道起点和终点的坐标,这些坐标被提及为 x1、y1、x2、y2。而且当我打印该行时,它有 8 个浮点数包含。

x1, y1, x2, y2  = line

将行列表解压缩为变量。引擎盖下发生的事情是

(x1, y1, x2, y2) = (0, 0, 5, 5)

因此

x1 = 0
y1 = 0 and so on...

删除for x1, y1, x2, y2 in line循环。

相关内容

最新更新