Install OpenCV 3 non-free module on Ubuntu

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

  • Remove the old version which has been installed in the system.
  • Do not install opencv via apt-get
  • Install cmake : sudo apt-get install cmake

Installation

  1. Download opencv git clone https://github.com/opencv/opencv
    1. Do not download the source from homepage.
  2. Download the opencv_contrib : git clone https://github.com/opencv/opencv_contrib
    1. Check both opencv and opencv_contrib are the latest versions otherwise we can not compile them.
  3. Extract the source.
  4. cd path/to/opencv-source
  5. Run Cmake: cmake-gui
  6. In the textbox Where is the source code, it should be the path of OpenCV
  7. Where to build the binaries : path to your build directory, e.g, ~/opencv/build
  8. Select Configure
  9. 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.)
  10. After automatically generating Makefiles, CMake will show all available settings.

  11. Select OPENCV>OPENCV_ENALBLE_NONFREE

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

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

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

  15. Configure the project again.

  16. Select Generate

  17. cd /path/to/opencv/build

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

  19. make install

Done.

comments powered by Disqus