最近在学习C++和OpenCV。给定一张图片,我想提取它的 SIFT 特征。来自 http://docs.opencv.org/modules/nonfree/doc/feature_detection.html ,我们可以知道OpenCV 2.4.8有SIFT模块。 看这里:
但是我不知道怎么用。目前,要使用 SIFT,我需要先调用 SIFT 类来获取 SIFT 实例。然后,我需要使用 SIFT::operator()()
来进行 SIFT。
但是什么是OutputArray
、InputArray
、KeyPoint
?任何人都可以演示如何使用 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/