c++ - 如何在opencv中使用SIFT

标签 c++ opencv sift

最近在学习C++和OpenCV。给定一张图片,我想提取它的 SIFT 特征。来自 http://docs.opencv.org/modules/nonfree/doc/feature_detection.html ,我们可以知道OpenCV 2.4.8有SIFT模块。 看这里: enter image description here

但是我不知道怎么用。目前,要使用 SIFT,我需要先调用 SIFT 类来获取 SIFT 实例。然后,我需要使用 SIFT::operator()() 来进行 SIFT。

但是什么是OutputArrayInputArrayKeyPoint?任何人都可以演示如何使用 SIFT 类进行 SIFT 吗?

最佳答案

请参阅 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;
}

在 OpenCV 2.4.8 上测试

关于c++ - 如何在opencv中使用SIFT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22722772/

相关文章:

python - 在opencv python中分解单应矩阵

python - 不能使用来自opencv的SIFT算法

c++ - 根据类(Class)输入 boost spirit 业力生成

c++ - cv::Max 中的错误?

c++ - 是否可以使用 openmp 对数组进行缩减?

c++ - SIFT detectAndCompute 抛出 ipp 异常

python - 删除对象边缘的关键点

c++ - 使用 Valgrind 调试程序 - 检测段错误

c++ - 从直方图中获取颜色 vector maxValue

opencv - 使用opencv计算外部矩阵