我正在写一个精简版的python,micro python。
我正在做一些图像处理,并试图找到从名为“find_line_segments”的方法返回的最长线(它执行 Canny Edge 和 Hough Lines 变换)。
但!我不断收到错误消息。
代码
rl = max(img.find_line_segments(roi = r_r, threshold = 1000, theta_margin = 15, rho_margin = 15, segment_threshold = 100), key = lambda x: x.length())
if rl is not None:
if rl[6] > 0 :
img.draw_line(rl.line(), color = 155)
print("RL")
print(rl)
错误:
Traceback (most recent call last):
File "<stdin>", line 77, in <module>
ValueError: arg is an empty sequence
MicroPython d23b594 on 2017-07-05; OPENMV3 with STM32F765
Type "help()" for more information.
该错误指向该行if rl is not None:
......我不明白为什么它会导致错误。如果 max() 函数没有返回值(在没有找到行的情况下),则永远不应该执行“if 语句”。
我不明白什么?
编辑:
意外删除了一些代码。