Here's what I had to do to compile OpenCV with xfeatures2d:
- Download opencv_contrib (I took a release from the releases page). This step is what gives us xfeatures2d.
- Unpack the tarball somewhere, e.g.,
~/src/opencv_contrib-4.5.5
- When configuring OpenCV (the main OpenCV source like
opencv-4.5.2
) with CMake, add the following option to cmake command line (adjusting the value to be your actual path to the modules
subdirectory of the opencv_contrib
tarball):
-DOPENCV_EXTRA_MODULES_PATH=$HOME/src/opencv_contrib-4.5.5/modules/
- Now just build as you normally would and install.
The above actions gave me the expected file (among others): /usr/include/opencv4/opencv2/xfeatures2d.hpp
.