OpenCV-Document-Scanner icon indicating copy to clipboard operation
OpenCV-Document-Scanner copied to clipboard

Implementation has been removed due to original code license issues

Open akkitech opened this issue 5 years ago • 12 comments

I am receiving below error while executing python scan.py --images imageDirectory

Traceback (most recent call last): File "scan.py", line 335, in scanner.scan(im_dir + '/' + im) File "scan.py", line 284, in scan screenCnt = self.get_contour(rescaled_image) File "scan.py", line 198, in get_contour test_corners = self.get_corners(edged) File "scan.py", line 95, in get_corners lsd = cv2.createLineSegmentDetector() cv2.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'

Python version : 3.7.3 OpenCV version : 4.1.0

Is there any workaround for this issue?

Thanks.

akkitech avatar Apr 17 '19 10:04 akkitech

I got the same issue. Some solution here?

AchuThanFinstreet avatar Apr 23 '19 11:04 AchuThanFinstreet

After uninstalling current opencv-version and reinstalling old one (3.1.0.0) it works now without this error.

AchuThanFinstreet avatar Apr 25 '19 09:04 AchuThanFinstreet

I got the same issue even if i choosed 'OPENCV_ENABLE_NONFEE' ! Someone told me his solution----re-run CMAKE with WITH_WIN32UI, since you are on Windows, and eventually with WITH_QT.

tangjie77wd avatar May 08 '19 01:05 tangjie77wd

It looks like LSD detector had been removed completely from the source tree since 4.1.0 release (see https://github.com/opencv/opencv/commit/3ba49ccecc773592a3e8d68ad9f5b06196dae6b6) =(

barabanus avatar May 13 '19 20:05 barabanus

@akkitech @AchuThanFinstreet @barabanus I have solved my problem with the following solution : #include <opencv2/ximgproc.hpp> #include <opencv2/line_descriptor/descriptor.hpp> using namespace cv::ximgproc; { ... vector<Vec4f> lines; Ptr<cv::ximgproc::FastLineDetector> detector = cv::ximgproc::createFastLineDetector(); detector->detect(roi, lines); } I have test it succeessfully.BTW,LSD detector has not been removed from opencv 4.10 but removed to cv::ximgproc from cv !

tangjie77wd avatar May 14 '19 01:05 tangjie77wd

Thanks, @tangjie77wd, but it seems like it was removed completely from OpenCV 4.1.0 (see https://github.com/opencv/opencv/commit/3ba49ccecc773592a3e8d68ad9f5b06196dae6b6). I have found LSD line detector classes within contrib line_descriptor module, but if you try to call real detect() method the program will be terminated with "unimplemented" error. You use FastLineDetector, but it's not LSD: it's based on Canny edges detector (see http://vision.ucsd.edu/~jwlim/files/icra14linerec.pdf)

barabanus avatar May 14 '19 06:05 barabanus

@barabanus Opencv shows an example https://docs.opencv.org/4.1.0/d1/d9e/fld_lines_8cpp-example.html which supports both LSD and FastLineDetector.How could they draw lines in the example if they did not imcomplete LSD ? `// Because of some CPU's power strategy, it seems that the first running of // an algorithm takes much longer. So here we run both of the algorithmes 10 // times to see each algorithm's processing time with sufficiently warmed-up // CPU performance. for(int run_count = 0; run_count < 10; run_count++) { lines_lsd.clear(); int64 start_lsd = getTickCount(); lsd->detect(image, lines_lsd); // Detect the lines with LSD double freq = getTickFrequency(); double duration_ms_lsd = double(getTickCount() - start_lsd) * 1000 / freq; std::cout << "Elapsed time for LSD: " << duration_ms_lsd << " ms." << std::endl;

    lines_fld.clear();
    int64 start = getTickCount();
    // Detect the lines with FLD
    fld->detect(image, lines_fld);
    double duration_ms = double(getTickCount() - start) * 1000 / freq;
    std::cout << "Ealpsed time for FLD " << duration_ms << " ms." << std::endl;
}
// Show found lines with LSD
Mat line_image_lsd(image);
lsd->drawSegments(line_image_lsd, lines_lsd);
imshow("LSD result", line_image_lsd);

// Show found lines with FLD
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines_fld);
imshow("FLD result", line_image_fld);

` Well ,I will try once i am free. Maybe we can not use LSD but FLD in the future.

tangjie77wd avatar May 17 '19 09:05 tangjie77wd

After uninstalling current opencv-version and reinstalling old one (3.1.0.0) it works now without this error.

this is works to me. thanks!

nyamba avatar Jun 11 '19 05:06 nyamba

Same issue here on Ubuntu 19.04.

frohro avatar Sep 02 '19 18:09 frohro

I had the same issue with opencv-contrib-python==4.1.1.26 and opencv-python==4.1.1.26.
The solutions I ended to are:

  • Downgrade to opencv-contrib-python==4.0.0.21 and opencv-python==4.0.0.21.

  • According to this question on Stakoverflow, to replace the missing LineSegmentDetectorImpl, install pylsd using pip install pylsd. For more details about how to use it with opencv, please check the documentation.

maky-hnou avatar Oct 16 '19 08:10 maky-hnou

It work with opencv-python version 4.1.1.26 too.

Tsypaev avatar Oct 31 '19 10:10 Tsypaev

I suggest you all add a thumbs-up to this issue!
"Restore LineSegmentDetector LSD & avoid license conflict": #2524

jeanchristopheruel avatar May 09 '20 19:05 jeanchristopheruel