Line Detection In Python OpenCV With HoughLines

In this Python OpenCV article we are going to talk about Line Detection With HoughLines algorithm. 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 so the difference is that. HoughLines uses the standard HoughTransForm and HoughLinesP probabilistic Hough Transform.

 

 

 

Also you can check Python GUI Development Tutorials in the below link.

1: PyQt5 GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: Pyside2 GUI Development Tutorials 

4: Kivy GUI Development Tutorials

 

 

 

So now this is the complete code for Line Detection In Python OpenCV With HoughLines

 

 

 

 

So at the top these are our imports that we are going to use in this article.

 

 

 

 

You need to have an image in your directory, iam using this image.

Line Detection Image
Line Detection Image

 

 

 

 

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 , you can check this article on Python OpenCV Canny Edge Detection.

 

 

 

So now 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.

 

 

 

Also we we want to write color lines on the line this code is for that

 

 

 

 

This is for showing of our image

 

 

 

 

So now run the complete code and this will be the result

Line Detection In Python OpenCV With HoughLines
Line Detection In Python OpenCV With HoughLines

 

 

 

 

 

Also you can watch the video for this article

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×