Mohamed Ihmeida
Mohamed Ihmeida

Reputation: 11

Run SURF algorithm on colab

I used to run SURF and SIFT on Colab using OpenCV 3.4.2.17. However, I can not use this version of opencv any more. Is there any other way to run SURF on Colab? I can SIFT pantent has expired since 2020. Below is the error

error: OpenCV(4.6.0) /io/opencv_contrib/modules/xfeatures2d/src/surf.cpp:1027: 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'

I have tried to downgrade Opencv version to 4.2.0, 3.4.8.29, 3.4.2.17 and 4.4.0.46. I also tried to downgrade paython to version 3.6 to work with old version opencv library.

Upvotes: 0

Views: 168

Answers (1)

Marty
Marty

Reputation: 1

Don't downgrade. Build OpenCV using your own configuration. See https://docs.opencv.org/4.7.0/d7/d9f/tutorial_linux_install.html.

Here I have downloaded the opencv and the opencv_contrib sources in the "git" subdirectory. I don't want to use IPP, but I want the nonfree libraries to be built:

mkdir -p build && cd build

Then (choose your Python directory):

cmake -DPYTHON_INCLUDE_DIR=/usr/include/python3.9 -DPYTHON_LIBRARY=/usr/lib -DWITH_IPP=OFF -DOPENCV_ENABLE_NONFREE:BOOL=ON -DOPENCV_EXTRA_MODULES_PATH=../git/opencv_contrib/modules ../git/opencv

Then:

cmake --build .

Upvotes: 0

Related Questions