How to find the angle of the line going through the partial circles

I have a problem find the angle of the line going through the circles, the image is as follows as left


Here we can see a line going through the partial circles my problem is to find the angle of the line from both left and right. Mostly I need to get some thing like right side of above image
Where point “A” is static and point “B” and point “C” are dynamic. And “D” is the line going through the circles. And I need to find the angles “X” and “Y”.
This is my idea of approach, But I don’t know how to? So, anyone please help me with this!!

I am using OpenCV python.

You can detect the endpoints of the circles using the Harris corner detector, so it can be used to get points B and C (as the rightmost and leftmost maximum).

The line can be found using a linear Hough transform, to get A and D.

Then, getting the angles is just a question of trigonometry.

1 Like