I am learning C++ and OpenCV these days. Given an image, I want to extract its SIFT features. From http://docs.opencv.org/modules/nonfree/doc/feature_detection.html, we can know
Update for OpenCV 4.2.0 (don’t forget to link opencv_xfeatures2d420.lib, of course)
#include
#include
#include
int main(int argc, char** argv)
{
const cv::Mat input = cv::imread("input.jpg", 0); //Load as grayscale
cv::Ptr siftPtr = cv::xfeatures2d::SIFT::create();
std::vector keypoints;
siftPtr->detect(input, keypoints);
// Add results to image and save.
cv::Mat output;
cv::drawKeypoints(input, keypoints, output);
cv::imwrite("sift_result.jpg", output);it.
return 0;
}