Search code examples
opencvsift

Sift implementation with OpenCV 2.2


Does someone know the link of example of SIFT implementation with OpenCV 2.2. regards,


Solution

  • Below is a minimal example:

    #include <opencv/cv.h>
    #include <opencv/highgui.h>
    
    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.3