An error occurred when running the program - the included file could not be opened: "opencv2/xfeatures2d.hpp": No such file or directory
Reference: blogger 1 , blogger 2
downloads the opencv_contrib that is consistent with the opencv version from this link , and the opencv I installed is 3.4 .15, downloaded opencv_contrib-3.4.
The following code can view the installed opencv version
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main(){
cout << CV_VERSION;
}
打开opencv_contrib-3.4\modules\xfeatures2d \include\opencv2
Copy the file here to the installation location of opencv opencv\build\include\opencv2
Create the folder xfeatures2d here, copy both xfeatures2d.hpp and the two files in xfeatures2d to avoid errors in the future because there is no nonfree.hpp file .
Reference #include<opencv2/xfeatures2d/xfeatures2d.hpp>
If no folder is created, place xfeatures2d.hpp directly under opencv2, and directly write as when referencing #include<opencv2/xfeatures2.hpp>
.