Python OpenCV Line Detection

In this Python OpenCV lesson we are going to learn about Python OpenCV Line Detection, so line detection has it own technique that is called the Hough transform, it was  invented by Richard Duda and Peter Hart, who extended the work done by Paul Hough in the early 1960s. so now we are using HoughLines and HoughLinesP for detecting lines,  the difference is this that HoughLines uses the standard HoughTransForm and HoughLinesP probabilistic Hough Transform.

 

 

This is the complete code for this lesson.

 

 

 

 

In here we have loaded our image and we have converted the image to gray scale.

 

 

Also in this line of code we have created our Canny algorithm.

 

 

This is our HoughLine algorithm for Line Detection, in here the first parameter is the image that we want to process, another parameter is the geometrical representations of the lines, rho and theta, which are usually 1 and np.pi/180.

 

 

 

Run the complete code and this is the result.

Python OpenCV Line Detection
Python OpenCV Line Detection
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.