How to use SIFT in opencv

I am currently studying C ++ and OpenCV. Given the image, I want to extract its SIFT functions. From http://docs.opencv.org/modules/nonfree/doc/feature_detection.html we can know that OpenCV 2.4.8 has a SIFT module. Take a look here: enter image description here

But I do not know how to use it. Currently, to use SIFT, I need to first call the SIFT class to get an SIFT instance. Then I need to use SIFT::operator()() to execute SIFT.

But what is OutputArray , InputArray , KeyPoint ? Can someone give a demo to show how to use the SIFT class to execute SIFT?

+8
c ++ opencv sift
source share
2 answers

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

+13
source share

I had the same question for opencv3, but I found this . This explains why SIFT and SURF are removed from the standard OpenCV 3.0 installation and how to use SIFT and SURF in OpenCV 3.

+1
source share

All Articles