以上是源码 我的编程环境是vs2015+opencv3.3.0 选取的图片“LENA”。大家可以自行选取图片作业
//#include "stdafx.h"
#include <opencv2/core/utility.hpp>
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/xfeatures2d.hpp"
#include <iostream>
#include <ctype.h>
using namespace cv;
using namespace std;
using namespace xfeatures2d;
void main()
{
Mat matSrc = imread("e:/cc/lena.jpg");
Mat gray;
Mat draw;
cvtColor(matSrc, gray, CV_RGB2GRAY);
Mat descriptors;
namedWindow("lena");
imshow("lena", matSrc);
std::vector<KeyPoint> keypoints;
// 生产sift结构
Ptr<SiftFeatureDetector> siftFD = SiftFeatureDetector::create();
siftFD->detectAndCompute(gray, Mat(), keypoints, draw);
drawKeypoints(gray, keypoints, gray, Scalar(0, 0, 255), DrawMatchesFlags::DEFAULT);
imshow("gray", gray);
waitKey(0);
return;
};
以下是作业处理的图片,有不足的地方希望大家指正,