# Get line values for cvHoughLines2

Is it possible to find line values for cvHoughLines2? By using only threshold, I get 150 to 6000 lines, depending on the input image. If I increase the threshold, I get reasonable number for the image for which I previously got 6000 lines, but in this case I get too few lines for the less contrasting image.

Is it possible to either:

• get the line values?

• get only specified number of strongest lines?

edit retag close merge delete

I'm detecting a lattice-like shape consisting of 32 lines, but under different light conditions and the original object colours and contrast I get very high variations in the number of lines using constant threshold. During testing, 200 strongest lines do the work, but I can't use this function because the results are already postprocessed and information discarded. I want to know, if it is possible to get the accumulator matrix, or postprocess the matrix into lines in a different way. I'm interested in the CV_HOUGH_STANDARD version. (Editing question causes Internal server error...)

( 2013-02-25 04:03:25 -0500 )edit

Sort by » oldest newest most voted

cvHoughLines2 returns the lines sorted by the accumulator value descendingly, thus taking first lines of the returned array solves the problem, even though I don't get the accumulator values.

Thanks to this message: http://tech.groups.yahoo.com/group/OpenCV/message/55201

more

Your question is not completely clear I assume that with low threshold you got too much lines while not enough lines with high threshold.

I do not think that there is an automated optimal value for the threshold that will suit your needs. You have experiment with all the parameters of the function to get the result what you want. You may even try different methods of Hough (e.g. probabilistic). Here is a description on what the parameters mean (for an older OpenCV version and here for the latest). There are longer tutorials on the algorithm behind like this and this.

Anyway it is better to opt for larger number of lines because you could postprocess the result and leave out unwanted lines and merge groups of similar ones. With small number of lines you have not so much option.

more

I want the accumulator values. If I get 6000 lines, I'm not able to postprocess them, because lines cross the image all the way around. Iteratively adapting the threshold to get desired number of lines is just wasting CPU time.

( 2013-02-25 03:59:34 -0500 )edit

I suggested that you make your experiment once and use the resulting parameters from that time. No on-line search for parameters.

( 2013-02-25 04:29:07 -0500 )edit

Official site

GitHub

Wiki

Documentation