Filtering line segments by length and magnitude does not seem to do much?

I have a H7, and added the following code to the bottom of the “find_line_segments” sample:

if l.magnitude() > 100: img.draw_line(l.line(), color = (0, 0, 255))
if l.length() <= 35: img.draw_line(l.line(), color = (0, 255, 0))

It runs, but regardless of a change in the magnitude, or length values, the green and blue lines drawn to screen barely change, and I barely get one or two. I would have thought changing magnitude to >1 would produce many blue lines?

Thanks in advance

You should print() the magnitude and length values.

Thank you for the input. I have the H7 camera pointed at an analogue clock youtube video. I am trying to isolate the three hands with this code:

for l in img.find_line_segments(merge_distance = 5, max_theta_diff = 15) :
if l.length() > 15 and l.magnitude() > 7: img.draw_line(l.line(), color = (0, 0, 255))

I am still not able to isolate the hands. I was thinking my next attempt would filter by endpoints, given that all the hands have the same origin? Any suggestions are much appreciated. I should probably try different camera settings?


Bob Callaghan

Yes, basically… you’re going to have to do things like this. This isn’t really that complex. If you’re good with lists and math in python the solution will emerge.

I hate to ask, but where on my frame buffer is x0, y0? or point to a reference would be good. The documentation I looked at didn’t specify this?

Top left. Standard for images.