#include #include "opencv2/core.hpp" #ifdef HAVE_OPENCV_XFEATURES2D #include "opencv2/highgui.hpp" #include "opencv2/features2d.hpp" #include "opencv2/xfeatures2d.hpp" using namespace cv; using namespace cv::xfeatures2d; using std::cout; using std::endl; int main( int argc, char* argv[] ) { CommandLineParser parser( argc, argv, "{@input | box.png | input image}" ); Mat src = imread( samples::findFile( parser.get( "@input" ) ), IMREAD_GRAYSCALE ); if ( src.empty() ) { cout << "Could not open or find the image!\n" << endl; cout << "Usage: " << argv[0] << " " << endl; return -1; } //-- Step 1: Detect the keypoints using SURF Detector int minHessian = 400; Ptr detector = SURF::create( minHessian ); std::vector keypoints; detector->detect( src, keypoints ); //-- Draw keypoints Mat img_keypoints; drawKeypoints( src, keypoints, img_keypoints ); //-- Show detected (drawn) keypoints imshow("SURF Keypoints", img_keypoints ); waitKey(); return 0; } #else int main() { std::cout << "This tutorial code needs the xfeatures2d contrib module to be run." << std::endl; return 0; } #endif