首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用opencv LineSegmentDetector查找图像的线条

使用opencv LineSegmentDetector查找图像的线条
EN

Stack Overflow用户
提问于 2019-05-31 05:31:50
回答 2查看 3.9K关注 0票数 0

我有一个彩色图像,我应该使用opencv LineSegmentDetector算法来检测图像中矩形的线条。

这是我的形象:

我用的是这个代码:

代码语言:javascript
复制
import cv2
img = cv2.imread("rectangles.jpg",0)

#Create default parametrization LSD
lsd = cv2.createLineSegmentDetector(0)

#Detect lines in the image
lines = lsd.detect(img)[0] 

#Draw detected lines in the image
drawn_img = lsd.drawSegments(img,lines)

#Show image
cv2.imshow("LSD",drawn_img )
cv2.waitKey(0)

我得到了这个差事:

代码语言:javascript
复制
<ipython-input-18-93ae667b0648> in <module>()
      3 
      4 #Create default parametrization LSD
----> 5 lsd = cv2.createLineSegmentDetector(0)
      6 
      7 #Detect lines in the image

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\lsd.cpp:143: error: (-213:The function/feature is not implemented) Implementation has been removed due original code license issues in function 'cv::LineSegmentDetectorImpl::LineSegmentDetectorImpl'

我检查了Open-cvVersion4.1文档来使用这个方法,这是页面,但是我不明白该如何使用这个方法。

任何帮助都是非常感谢的。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-05-31 05:42:03

你读过错误信息了吗?

错误: C:\projects\opencv-python\opencv\modules\imgproc\src\lsd.cpp:143:错误:(-213:函数/特性未实现) 函数'cv::LineSegmentDetectorImpl::LineSegmentDetectorImpl‘中的原代码许可问题已被删除。

由于许可证问题,该类不可用。

您可以在原始源中看到这个这里

票数 2
EN

Stack Overflow用户

发布于 2019-09-08 11:30:40

您还可以使用OpenCV 4.1中提供的快速线路检测器。

代码语言:javascript
复制
import cv2
img = cv2.imread("rectangles.jpg",0)

#Create default Fast Line Detector (FSD)
fld = cv2.ximgproc.createFastLineDetector()

#Detect lines in the image
lines = fld.detect(img)

#Draw detected lines in the image
drawn_img = fld.drawSegments(img,lines)

#Show image
cv2.imshow("FLD", drawn_img)
cv2.waitKey(0)

结果:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56389167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档