how to use SIFT in opencv

前端 未结 4 774
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 18:58

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

4条回答
  •  孤城傲影
    2021-02-05 19:37

    See the example from Sift implementation with OpenCV 2.2

    #include 
    #include 
    #include  //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 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

提交回复
热议问题