Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement LSD in opencv 4.1.0

Tags:

python

opencv

I had implemented LSD in my open CV project. Every thing worked well until I upgraded opencv version from 4.0.0 to 4.1.0. Now I get error as

cv2.error: OpenCV(4.1.0) /io/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 'LineSegmentDetectorImpl'

It seems that due to some liscense issue this feature has been removed. How do I address this problem.

The error is shown in the following part of code :

cv2.createLineSegmentDetector(0)
like image 687
Abhijet Avatar asked May 07 '19 06:05

Abhijet


1 Answers

In opencv 4, it is now called FastLineDetector. You need to first install opencv-contrib-python by using pip install opencv-contrib-python and then you can use the following implementation

img = cv2.imread(test_image, 0)
fld = cv2.ximgproc.createFastLineDetector()
lines = fld.detect(img)
result_img = fld.drawSegments(img,lines)
like image 139
Malgo Avatar answered Nov 09 '22 21:11

Malgo