Probabilistic Hough transform in OpenCV 2.4.9 (Python)

女生的网名这么多〃 提交于 2019-12-23 15:25:37

问题


My question is about Hough transform in OpenCV 2.4.9 (Python).

Here is an extract from tutorial:

cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) → lines

I do not really understand what "lines[," means. I use the function in the following manner:

lines = cv2.HoughLinesP(edges, 1, np.pi/180, 25, 2,25,115)

But what does parameter "2" here really mean? Seems nothing change when I assign different values for that parameter.

Tnanks..


回答1:


You have to use it like this

lines = cv2.HoughLinesP(edge_image, rho=1.0, theta=math.pi/180.0,
                                    threshold=thresholdVal,
                                    minLineLength=minlinelengthVal,
                                    maxLineGap=maxlinegapVal)

If you read up about Hough Transforms and probabilistic hough transforms, you'd realize that an accumulator is used to accumulate all the edge points. rho is the distance resolution of the accumulator in pixels and theta is the angle resolution of the accumulator in radians.

And as far as cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) → lines docs is concerned, it is sort of function overloading but since python provides optional arguments, this is used. lines[ just means that you can pass a numpy array where the lines will be stored. So now, if you want pass other parameters and skip lines, you'd have to pass them by the parameter name.



来源:https://stackoverflow.com/questions/25582548/probabilistic-hough-transform-in-opencv-2-4-9-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!