OpenCV 2.4.9(Python)中的概率Hough变换 [英] Probabilistic Hough transform in OpenCV 2.4.9 (Python)

查看:195
本文介绍了OpenCV 2.4.9(Python)中的概率Hough变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是有关OpenCV 2.4.9(Python)中的Hough变换的.

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

以下是本教程的摘录:

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

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

我不太了解"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)

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

但是参数"2"在这里到底是什么意思?当我为该参数分配不同的值时,似乎什么都没有改变.

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

谢谢.

推荐答案

您必须像这样使用它

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

如果您阅读了有关霍夫变换和概率霍夫变换的信息,您将意识到累加器用于累加所有边缘点. rho是累加器的距离分辨率(以像素为单位),theta是累加器的角度分辨率(以弧度为单位).

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.

cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) → lines文档而言,这是一种函数重载,但是由于python提供了可选参数,因此可以使用它. lines[只是意味着您可以传递将存储行的numpy数组.因此,现在,如果要传递其他参数并跳过lines,则必须通过参数名称传递它们.

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.

这篇关于OpenCV 2.4.9(Python)中的概率Hough变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆