I'm writing in a stripped down version of python, micro python.
I'm doing some image processing and am trying to find the longest line returned from a method called, "find_line_segments" (it does Canny Edge and Hough Lines transforms).
BUT! I keep getting an error.
Code
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)
Error:
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.
That error points to the line if rl is not None:
... and I don't understand why it is causing an error. If the max() function doesn't return a value (in the case that a line isn't found), the "if statement" should never execute.
What am I not understanding?
Edit:
Accidentally removed some code.