未实现 OpenCV SURF 功能的可能重复项
我的错误代码是:
错误 LNK2019:函数 _main 中引用的未解析外部符号“public:__thiscall cv::SURF::SURF(double,int,int,bool,bool)”(??0SURF@cv@@QAE@NHH_N0@Z)
我不知道如何解决它。
我的代码是:
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <iostream>
#include <conio.h>
#include <opencv2\nonfree\features2d.hpp>
#include <opencv2\legacy\legacy.hpp>
#include <opencv2\core\core.hpp>
#include <stdio.h>
using namespace cv;
using namespace std;
int main()
{
Mat img_1 = imread("kmu1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_2 = imread("all.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(!img_1.data || !img_2.data)
{
cout << "could not open or find the image" << endl;
return -1;
}
int minHessian = 400;
SURF surf( minHessian );
vector <KeyPoint> keyPoints_1, keyPoints_2;
Mat descriptors_1, descriptors_2;
surf(img_1, Mat(), keyPoints_1, descriptors_1, false);
surf(img_2, Mat(), keyPoints_2, descriptors_2, false);
BFMatcher matcher(NORM_L2, false);
vector<DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
Mat img_matches;
drawMatches(img_1, keyPoints_1, img_2, keyPoints_2, matches, img_matches);
imshow("Matches", img_matches);
waitKey(0);
_getch();
return 0;
}