White lines detection

Hi,

I want to detect white lines in my camera’s images, using this code:

img = sensor.snapshot()

blackImage = img.to_grayscale(copy = True).binary([(190, 255)])

segments = blackImage.find_line_segments(merge_distance = 10, max_theta_diff = 5)
    
for segment in segments:
    img.draw_line(segment.line(), color = (255, 0, 0))

I’m calling to_grayscale() and binary() to detect the lines in a black and white image, to be more accurate.
But the last call (img.draw_line) doesn’t draw the lines in the displayed image (in the IDE), why?

(If I put to_grayscale(copy = False), I see grey lines in the displayed image)

Mmm… things can get confusing when using copy and the dot operation.

img = sensor.snapshot()
black_img = img.to_grayscale(copy = True)
black_img.binary([(190, 255)])
segments = black_img.find_line_segments(merge_distance = 10, max_theta_diff = 5)
    
for segment in segments:
    img.draw_line(segment.line(), color = (255, 0, 0))

Does the above work? Otherwise it’s a bug in the library breaking pointers.

no, same issue…

Please file a bug ticket here. I’ll get this fixed over the weekend and have a new firmware for you: Issues · openmv/openmv · GitHub

1 Like

Thanks!

Found the issue: bug with to_grayscale(copy = True) · Issue #1811 · openmv/openmv · GitHub