It is called the “Hough Transform”
You could experiment using something like Mathlab, and then implement it using opencv houghtransform.
https://github.com/Itseez/opencv/blob/master/samples/cpp/houghlines.cpp
1
solved How to search segment in picture