Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More accurate houghline OpenCV

I have been working with houghlines in OpenCV and I cant seem to get a more accurate line reading, sometimes there are two duplicate lines on top of each other. I have looked at tutorial on the opencv website but it gives a similar result.

like image 236
user3130151 Avatar asked Dec 20 '22 19:12

user3130151


1 Answers

To remove those duplicate lines, there are two things that may help you:

  1. Double edges may appear that may lead to duplicate lines. A sequence of blurring/dilating the input image would solve these issues.
  2. Close lines that have almost same slope can be removed by using lower angle resolutions for the theta argument of Hough Line method. For example using π/180 would result in finding lines that differ only by one degree in their slope. You may use 5*π/180 to find lines in 5 degree resolution.

As an example, the following lines are detected by using the raw image and a 1-degree resolution: triple

After a bit of blurring and using a 3-degree resolution you can get a result like the following: fixed

By changing the threshold, you can get more or less lines.
About fitting curves you pointed in the comments section, yes you can fit curves, but not with hough lines method. You need to find a parametric definition of that shape and try to run the voting procedure in hough transform yourself. The only other shape that opencv helps you to find is circle.

like image 118
Kamyar Infinity Avatar answered Dec 28 '22 11:12

Kamyar Infinity