See an example from the Sift implementation with OpenCV 2.2.
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/nonfree/features2d.hpp> //Thanks to Alessandro int main(int argc, const char* argv[]) { const cv::Mat input = cv::imread("input.jpg", 0); //Load as grayscale cv::SiftFeatureDetector detector; std::vector<cv::KeyPoint> keypoints; detector.detect(input, keypoints); // Add results to image and save. cv::Mat output; cv::drawKeypoints(input, keypoints, output); cv::imwrite("sift_result.jpg", output); return 0; }
Tested on OpenCV 2.4.8
Liam McInroy
source share