Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Include non-free algorithms #126
with the recent update, in Opencv 3.4.3, the non-free algorithms such as SIFT and SURF are no more available.
>>> import cv2 >>> cv2.__version__ '3.4.3' >>> cv2.xfeatures2d.SIFT_create() Traceback (most recent call last): File "<stdin>", line 1, in <module> cv2.error: OpenCV(3.4.3) /io/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1207: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create' >>> cv2.xfeatures2d.SURF_create() Traceback (most recent call last): File "<stdin>", line 1, in <module> cv2.error: OpenCV(3.4.3) /io/opencv_contrib/modules/xfeatures2d/src/surf.cpp:1016: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'
As the error messages say, the library should be recompiled with
referenced this issue
Sep 16, 2018
referenced this issue
Oct 9, 2018
I understand your concern. The problem is that SIFT is the gold standard algorithm, it is highly used in research and other non-commercial applications.
The SIFT implementation is anyway available from the C++ repository of opencv, and I am sure that if the patent owner wanted to ban SIFT from opencv they would have done it before.
Removing SIFT from this repo is first probably breaking a lot of scripts that were relying on the previous version, and prevent people to test this solution for their problem.
What about adding a warning when a SIFT detector/descriptor object is created ? Like for deprecated stuff but here mentioning the patent.
I know that both SIFT and SURF are used widely. I agree that the programmer or a company is responsible for checking that the patents and licenses of the software are respected.
However, "probably does not matter" is not enough. These pre-built packages are freely available around the world so everything must be considered even if it concerns only USA. There have been other interesting discussions about this very same matter: https://answers.ros.org/question/34557/opencv-patent/
I didn't remove anything from this repo. OpenCV developers moved SIFT and SURF behind the non-free build flag in the most recent release which is the way they should have been always but, for some reason, weren't. If I turn the non-free build flag on, it's not only SIFT and SURF that get included in the wheels. There are other non-free modules in OpenCV.
I can't add any warnings in this repository to the OpenCV code (without very cumbersome patches) since this repository just pulls a certain vanilla OpenCV version from the upstream and builds it.
If you need the non-free modules you can build the Python bindings yourself and flip the non-free flag on. After all, that's the official way. These packages are unofficial and not endorsed by OpenCV.
Best solution would be probably to create proper support for sdist for these packages and allow users to force the rebuild of the packages themselves. This requires of course compilers and other tools to be installed on the target system and the installation would take about ~10-15 minutes.
I'm afraid it does matter. Or to be more precise, it's not in the "definitely doesn't matter" category, or even in the "probably does not matter" category. More like in the "might well matter" category! Here's some background on the interesting question of why distributing source code might be in the "probably does not matter" category, but distributing built binaries isn't:
(which in turn answers why the code is still in the upstream OpenCV repository, just guarded with a compiler flag)
More like 2 hours on a Pi :)
Still, as the person who builds the wheels for opencv-python on the piwheels platform (with the relevant bits from skvark's repo here), I'm entirely in agreement with skvark here and will be following upstream's lead. IANAL (too), and while it's interesting (to some?) to read patent-related SE posts and the odd legal paper I wouldn't trust my conclusions to defend me from a pack of rabid patent attorneys.
@Jindil http://answers.opencv.org/question/18259/is-surf-algorithm-used-in-opencv-patented/ <- it says there are better, free alternatives. Judging by https://www.quora.com/Computer-Vision-They-dont-use-SIFT-at-Microsoft-they-use-MOPS-Meaning, they seem to only differ by some reference dataset or something.
http://answers.opencv.org/question/73877/opencv-free-for-commercial-use/ <- this says they are free for non-commercial use only, so if they are included,
@ubaierbhat you can tweak CMake command line (