Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv 4.x 去除了lsd 模块 #8

Open
lix19937 opened this issue Feb 22, 2024 · 1 comment
Open

opencv 4.x 去除了lsd 模块 #8

lix19937 opened this issue Feb 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@lix19937
Copy link
Owner

lix19937 commented Feb 22, 2024

在opencv 4.2.0.34版本下调用 lsd = cv2.createLineSegmentDetector(0) 运行报错

cv2.error: OpenCV(4.2.0) C:\Users\lix\AppData\Local\Temp\1\pip-req-build-wbmte9m7\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’

源码许可证问题而删除了实现

在opencv contrib扩展中的ximgproc模块中给出了一个LineSegmentDetector类,来替代LSD算法。

该算法来自于2014年ICRA的一篇论文《Outdoor place recognition in urban environments using straight lines》

ref https://blog.csdn.net/Zhaoxi_Li/article/details/106844821

@lix19937 lix19937 added the bug Something isn't working label Feb 22, 2024
@lix19937
Copy link
Owner Author

lsd

# coding=utf-8
import cv2
import numpy as np

img0 = cv2.imread("test3.jpg")
img = cv2.cvtColor(img0,cv2.COLOR_BGR2GRAY)

lsd = cv2.createLineSegmentDetector(0)

dlines = lsd.detect(img)

for dline in dlines[0]:
    x0 = int(round(dline[0][0]))
    y0 = int(round(dline[0][1]))
    x1 = int(round(dline[0][2]))
    y1 = int(round(dline[0][3]))
    cv2.line(img0, (x0, y0), (x1,y1), (0,255,0), 1, cv2.LINE_AA)

cv2.imwrite('test3_r.jpg', img0)
cv2.imshow("LSD", img0)
cv2.waitKey(0)
cv2.destroyAllWindows()

fsd

# coding=utf-8
import cv2
import numpy as np

img0 = cv2.imread("test3.jpg")
img = cv2.cvtColor(img0,cv2.COLOR_BGR2GRAY)

fld = cv2.ximgproc.createFastLineDetector()
dlines = fld.detect(img)

for dline in dlines:
    x0 = int(round(dline[0][0]))
    y0 = int(round(dline[0][1]))
    x1 = int(round(dline[0][2]))
    y1 = int(round(dline[0][3]))
    cv2.line(img0, (x0, y0), (x1,y1), (0,255,0), 1, cv2.LINE_AA)


cv2.imwrite('test3_r.jpg', img0)
cv2.imshow("LSD", img0)
cv2.waitKey(0)
cv2.destroyAllWindows()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant