Wenyin 的拾萃园
OpenCV CMake Configure

OpenCV 4.5 has released the copyright-expired SIFT implementation, so developers now can enjoy the performance brought by the SIFT algorithm.

There are some points that need to be paid attention to which would cause lots of waste of time if the developer is not careful during CMake configure step.

Install GTK on Ubuntu

If you are new to OpenCV, such an error is common.

OpenCV Error: Unspecified error (The function is not implemented. 
Rebuild the library with Windows, GTK+ 2.x or Carbon support. 
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file 
/home/hristov/workspace/opencv/modules/highgui/src/window.cpp, line 534
terminate called after throwing an instance of 'cv::Exception'
  what():  
/home/hristov/workspace/opencv/modules/highgui/src/window.cpp:534: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
sudo apt install libgtk2.0-dev
sudo apt install pkg-config
  •  WITH_GTK_2_X

Mark the WITH_GTK_2_X option in CMake, otherwise, developers would feel inconvenient while trying to view their processed image in RAM during runtime.

OpenCV Extra Modules

  • Set OPENCV_EXTRA_MODULES_PATH to <path to your opencv-contrib>/modules.

If you don't want to cost too much time compiling all of the modules, choosing the several modules you need in CMake by -DBUILD_opencv_<module_name> is also okay. For example, if you need to use the xfeatures2d module, simply mark option BUILD_opencv_xfeatures2d in CMake-GUI or -DBUILD_opencv_xfeatures2d in CMake command line.

GPU Acceleration

  •  WITH_CUDA

Remember to Mark WITH_CUDA option in CMake, I have not yet managed to use the CUDA-accelerated algorithms. Here are some materials that might be helpful.

Run SURF_CUDA against multiple images in parallel

opencv/samples/gpu/surf_keypoint_matcher.cpp

This page is OpenCV documentation OpenCV SURF_CUDA class reference