简体   繁体   中英

PyCharm: Installation of non-free OpenCV modules for operations like SIFT, SURF

I want to use functions like SIFT, SURF,etc. I am using Ubuntu 16.04 on a virtual machine with OpenCV 3.4.1 and using PyCharm as the IDE.

I can open Pycharm, create a project, go to file - settings - Project interpreter and download the modules I need.I have downloaded opencv-python and opencv-contrib-python.

But I still am not able to use the above mentioned fucntions.

Please help. Thanks.

With OpenCV 3, the non-free modules, namely SIFT and SURF , which are patented by their respective creators, were moved out of the default OpenCV install and into the opencv_contrib package. The implementations in opencv_contrib are not installed by default and you need to explicitly enable them when compiling and installing OpenCV to obtain access to them.

To get access to the original SIFT and SURF implementations found in OpenCV 2.4.X (versions with these implementations installed by default), you will need to pull down both the opencv and the opencv_contrib repositories from GitHub and then compile and install OpenCV3 from source.

As much as I would like to provide you with the steps to do this, I want to give credit to one tutorial available online to do this instead. So, follow this sweet tutorial - Install OpenCV 3.0 and Python 3.4+ on Ubuntu and you should be able to work with these implementations. Additionally, I would suggest looking at ORB which is a faster, free alternative to SIFT and SURF, but not sure if it will serve your purpose.

If you really don't want to work with the terminal, open a new project, Go to ->

Settings -> Project -> Project Interpreter -> +

Add the modules that you want by searching for them and you should be able to use them.

I was having the same problem with opencv trying to use SIFT and SURF. I try so many ways including adding opencv-contrib and even compiling opencv using visual studio but none of those options worked for me. I would recommend to use anaconda and install opencv using the method show in this post.

How do I install Python OpenCV through Conda?

After installing it using

conda install -c menpo opencv

I was able to use without the annoying massage of "set OPENCV_ENABLE_NONFREE"

Edit: I needed to install in on my raspberry pi and Anaconda does not work the same on raspberry pi. I do some research and I found that if you run the command below, should fix the "NON_FREE /Patent protected" error.

pip install opencv-contrib-python==3.4.0.12

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM