When SIFT algorithm is used for matching, an error is reported during compilation:
fatal error: opencv2/nonfree/nonfree.hpp: Not having that file or directory
#include <opencv2/nonfree/nonfree.hpp>
When you go online, you basically say to download opencv nonfree:
sudo apt-get update
sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
sudo apt-get update
sudo apt-get install libopencv-nonfree-dev
As a result, a new error is reported when the second instruction is run:
sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
Cannot add PPA: 'ppa:~xqms/ubuntu/opencv-nonfree'.
ERROR: '~xqms' user or team does not exist.
After careful review, it is found that the opencv2. X version is still very good to install under the Ubuntu system. You only need to install it through the above instructions
opencv-3.4.0/opencv_contrib-3.4.0/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp
Put #include < opencv2/nonfree/nonfree.hpp> Change to absolute path and solve it.