I am trying to do feature extraction using C++ API. For this, I am using http://docs.opencv.org/ref/master/dd/dd4/tutorial_detection_of_planar_objects.html as reference.
The code I have written is :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/calib3d.hpp>
using namespace cv;
#include <iostream>
#include <stdio.h>
using namespace std;
Mat img; Mat templ;
int main(int, char** argv)
{
templ = cv::imread("C:/Users/.../workspace/FeatureDetectionCPP/src/temp.jpg", IMREAD_GRAYSCALE);
img = cv::imread("C:/Users/.../workspace/FeatureDetectionCPP/src/image.jpg", IMREAD_GRAYSCALE);
if(templ.empty())
{
cout<<"Empty template";
}
if(img.empty())
{
cout<<"Empty image";
}
Ptr<Feature2D> surf = SURF::create();
vector<KeyPoint> keypoints1;
Mat descriptors1;
surf->detectAndCompute(img, Mat(), keypoints1, descriptors1);
Ptr<Feature2D> surf1 = SURF::create();
vector<KeyPoint> keypoints2;
Mat descriptors2;
surf1->detectAndCompute(templ, Mat(), keypoints2, descriptors2);
// matching descriptors
BruteForceMatcher<L2<float> > matcher;
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
// drawing the results
namedWindow("matches", 1);
Mat img_matches;
drawMatches(templ, keypoints1, img, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
return 0;
}
During compilation, I got this:
error: 'SURF' has not been declared Ptr<feature2d> surf1 = SURF::create();
error: 'BruteForceMatcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;
error: expected primary-expression before '>' token BruteForceMatcher<l2<float> > matcher;
error: 'matcher' was not declared in this scope BruteForceMatcher<l2<float> > matcher;
On searching, I found that #include "opencv2/nonfree/features2d.hpp" should be added. However, I don't have any folder nonfree or misc in the opencv2 folder. I am using opencv 3.0.0. And, have compiled it using mingw.
Can anyone help in telling as if why this error is appearing. And, how can I resolve it.