【问题标题】:HoughLines error: only length-1 arrays can be converted to Python scalarsHoughLines 错误:只能将长度为 1 的数组转换为 Python 标量
【发布时间】:2017-07-19 10:56:54
【问题描述】:

我正在尝试使用 HoughLines 来识别 this image, here it is after the thresholding and other operations shown in the code 中的水平线和垂直线,因此我可以将它们绘制成黑色并移除它们。到目前为止,这是我的代码:

)

src_no_bg = 255 - cv2.absdiff(src, bg)

maxValue = 255
thresh = 240

但是 HoughLines 代码行不断返回此错误

only length-1 arrays can be converted to Python scalars

【问题讨论】:

    标签: python python-2.7 opencv


    【解决方案1】:

    您提供给函数的参数不正确,如 openCV 文档所述:

    cv2.HoughLines(image, rho, theta, threshold[, lines[, srn[, stn]]]) → lines
    

    也不需要包含数学库,因为 numpy 库有自己的 pi 函数。

    函数应该如下使用:

    lines = cv2.HoughLines(edges, 1, np.pi/180, 0, 0, 0)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 1970-01-01
      • 2016-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多