The opencv_nonfree module provides very useful features such as two prominent image features SIFT and SURF (including the CUDA’s implementation). In this tutorial, I demonstrate how to install this module into OpenCV 3 on Ubuntu.

Prerequisites

Installation

  1. Download opencv git clone https://github.com/opencv/opencv

  2. Do not download the source from homepage.

  3. Download the opencv_contrib : git clone https://github.com/opencv/opencv_contrib

  4. Check both opencv and opencv_contrib are the latest versions otherwise we can not compile them.

  5. Extract the source.

  6. cd path/to/opencv-source

  7. Run Cmake: cmake-gui

  8. In the textbox Where is the source code, it should be the path of OpenCV

  9. Where to build the binaries : path to your build directory, e.g, ~/opencv/build

  10. Select Configure

  11. When the dialog CMakeSetup pops up, configure the compiler according to your system. (Most of the time is to select Unix Makefiles as the generator and Use default native compilers as well.)

  12. After automatically generating Makefiles, CMake will show all available settings.

  13. Select OPENCV>OPENCV_ENALBLE_NONFREE

  14. On OPENCV>OPENCV_EXTRA_MODULES_PATH , give the path to folder modules inside opencv_contrib

  15. Select Configure the project again. On the output window, check whether it produces Non-free algorithms are enabled .

  16. On BUILD , make sure that you have selected the appropriate modules for features extraction, e.g, BUILD_opencv_xfeatures2d.

  17. Configure the project again.

  18. Select Generate

  19. cd /path/to/opencv/build

  20. make all (To speed up : make all -j8 )

  21. make install

Done.