Corner detection methods

Hello OpenMV,
I’m new to the scene here, new to micropython, but an experience programmer. I’m trying to determine the best method to use/pursue to use the OpenMV camera to detect two corners.

Essentially the camera view will always have two partial rectangles in view (basically like this ] [ ).
I expect to have two vertical and two horizontal lines in the image. If the lines are not perfect 90, 0, then I’d like to know their angles as well as the corner point locations. I’d like to use the best resolution as possible with the stock camera and detect these features as reliably as possible.

I started using find_lines, tried find_line_segments. I also tried find_blobs. I think any of them can work. With find_line_segments I was able to draw crosses on the corners, so I felt that was a pretty good start. What I’m looking for advise on is what seems to be the best function to use/pursue?

I do have one question with regards to micropython. At one point, I was trying to create a variable of type line to store a line in. I tried creating a list variable and then assigning a line to it. When I’d ask for myvar.x1() the compiler said that x1 wasn’t an object of myvar. looking for a little advise on this as well.

Thank you.

Hi, find_line_segments() would be the best for this. Alternatively, any of the keypoints trackers will pull out corners. We should have a find_corners() method… but, haven’t gotten around to writing it.

Just assign list = find_lines()

Then when you iterate through the list each element in the list will be a line object.

Thank you for the advice. Find line segments seems to be working well for my needs and I think your Idea to store lines in a list is great. I went the round about way of creating a Class myline with all the attributes of a line which worked as well, but your advice is much more elegant.

One further question: the partial rectangles that I am detecting the corners of, have line segments that are dark and nearly black. There are other lines that the camera can have in it’s view which I want to filter out. One quality of the “bad” lines is that they are Red. Is there a way you could recommend to guide me on how to filter out the “bad” lines?

Thank you in advance,

Use get_stats() with an Roi equal to the line segment bounding box and look at the color stats for the area around the line segment.