Project - Robot stay within two lines

Hello,

My current project is using the OpenMV M7 to stay between two lines, at the moment it works sort of well by using line segments and RIO (region of interest) to look and create lines only in a certain frame. The problem is the find_line_segments will find too many lines from random stuff around, do you have any recommendations on how to remove these lines and only find the two most dominant lines?

This is quite time sensitive so anything can help.
Thanks so much!

Sure, the find_line_segments() method returns a list of line segments. Use the Filter() method in python then to execute a callback function on the list of returned line segments and remove the ones that aren’t vertical by looking at their rotation angle and also remove the segments that are very short in length, etc. The line segments have a bunch of different properties you can ignore them by.

So beyond what you said which I am currently looking into, say i’m on a white surface with black tape for the lines, the line segments will find the left and right edges of each lines. Is there a proper way to create 1 line from this significantly contrasted line on either side? Thanks again!

Hmm, in this situation I’d recommend you use the robust linear regression method. Please see the example script for it under feature detection. You should execute it twice on the left and right side of the image. Then you’ll get two lines to use to drive with. Make sure to use the robust linear regression method.