【发布时间】:2014-02-11 12:15:36
【问题描述】:
--见下面的更新/答案。用户错误!--
我正在尝试了解如何在 Imgproc.HoughLines() 中设置参数以查找较短的行。我已经尝试过这样的东西,但根本不起作用:
Imgproc.HoughLines(matSrc, matLines, 1, Math.PI / 180, houghThreshCurrent, 25, 10);
我已经为最后两个参数尝试了几个值,但似乎没有一个有效 - 它找不到任何行。但是,使用没有最后两个参数的方法版本可以很好地找到我想要的行,而不是较短的行,无论阈值有多低。
这是最后两个参数的文档:
srn For the multi-scale Hough transform, it is a divisor for the distance resolution rho. The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these parameters should be positive.
stn For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
有人可以为此翻译或提供示例值吗? :)
我还尝试了概率版本 HoughLinesP()。它似乎不适用于我的用例。如果我无法使线距参数正常工作,另一种选择是将我的图像缩放到默认 HoughLines() 工作的更大尺寸。
答案:我的问题是我没有意识到 HoughLinesP() 返回的 Mat 与 HoughLines() 返回的格式不同。当 HoughLinesP() 已经在 XY 坐标中时,我正在从极坐标转换结果!事实证明 HoughLinesP() 远远优于我们的需求,它的参数非常适合调整线长度。这是帮助我看到我的方式错误的链接:https://dsp.stackexchange.com/questions/10467/influence-of-image-size-to-edge-detection-in-opencv
【问题讨论】:
-
我不确定如何设置这些值,但我可以建议一种不同的方法:使用 line-segment-detector:ipol.im/pub/art/2012/gjmr-lsd
标签: java opencv computer-vision hough-transform