小编mag*_*gle的帖子

如何在 Python 3 中使用 OpenCV4 的 FastLineDetector?

我试图在 Python 3 中使用 OpenCV4 库中的 FastLineDetector 来检测图像中的线条和段,但似乎没有办法让它工作。我在这里阅读了文档:https : //docs.opencv.org/3.4/df/d4c/classcv_1_1ximgproc_1_1FastLineDetector.html对我来说仍然没有什么清楚。我已经安装了 OpenCV 4.1.0,并且在 Ubuntu 18.0.4 中运行 Python 3.6。

这是我单独尝试过的代码:

img = cv2.imread('/tmp/output0.png', cv2.CV_8UC1)
fld = cv2.ximgproc_FastLineDetector.detect(img)
Run Code Online (Sandbox Code Playgroud)
fld = cv2.ximgproc_FastLineDetector.detect(cv2.ximgproc_FastLineDetector(img))
fld.detect(img)
Run Code Online (Sandbox Code Playgroud)

以下是输出错误:

fld = cv2.ximgproc_FastLineDetector.detect(img)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: descriptor 'detect' requires a 'cv2.ximgproc_FastLineDetector' object but received a 'numpy.ndarray'
Run Code Online (Sandbox Code Playgroud)
fld = cv2.ximgproc_FastLineDetector.detect(cv2.ximgproc_FastLineDetector(img))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: Incorrect type of self (must be 'ximgproc_FastLineDetector' or …
Run Code Online (Sandbox Code Playgroud)

python opencv detection segment python-3.x

4
推荐指数
1
解决办法
3846
查看次数

标签 统计

detection ×1

opencv ×1

python ×1

python-3.x ×1

segment ×1