Finding tangent line to edge of a feature

I am new to OpenMV and just got my OpenMV H7. I want o find tangent lines to the edge curve at specific points in the ROI. As an example, I have uploaded a snapshot of a crack in the cement or wall. On the right side it is the same image with three examples of ROI shown by yellow rectangle. Assume a horizontal green line in the middle of the ROI. This line intersects with the crack edges at two points. I want to find tangent lines to the crack edges right at those two intersections, which are shown by red lines. I thought of doing an edge detection, then finding the intersecting points. I know the y of those points, since we know the location of the green line. I want to know what approach should I take to find the x points for intersections and then how to find the tangent lines equations. Is find_blobs an option too for this application?

Thank you!

No, just use the fin_line_segments() method or the get_regression() method. Get regression with the robust flag set basically does what you want.

1 Like

Thank you for the direction!
I could not get a satisfactory results from find_line_segments() but I think get_regression() with robust flag works better. I use the following instructions:

img = sensor.snapshot().binary([THRESHOLD]) if BINARY_VISIBLE else sensor.snapshot()

line = img.get_regression([(255,255) if BINARY_VISIBLE else THRESHOLD], robust = True)

img.laplacian(1)

It shows me the edges of the crack. Should I examine all the pixels along one horizontal line (Y = constant) to find the X values of edges?

image

I am also thinking of another approach by shining a line e.g. red laser line to the object; capture the image; then filter the image to show only RED objects but, not using find_blobs.
Does OpenMV has color filter, something similar to what is shown in the attached picture?
Ref. link:

Yeah, just use the binary method. This will get you the second image. For the third image you can mask out the color you just want to see by passing a mask into some of the methods in the library.