http://www.cnblogs.com/dengxiaojun/p/5302778.html
#include "stdafx.h"
#include <opencv2/core/core.hpp>#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "cv.h" // OpenCV 文件头
#include "highgui.h"
#include "cvaux.h"
#include "cxcore.h"
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc.hpp"
#include <vector>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat srcImage = imread("../gugong.jpg");
Mat srcGrayImage;
if (srcImage.channels() == 3)
{
cvtColor(srcImage, srcGrayImage, CV_RGB2GRAY);
}
else
{
srcImage.copyTo(srcGrayImage);
}
vector<KeyPoint>detectKeyPoint;
Mat keyPointImage1, keyPointImage2;
Ptr<FastFeatureDetector> fast = FastFeatureDetector::create(100);
fast->detect(srcGrayImage, detectKeyPoint);
drawKeypoints(srcImage, detectKeyPoint, keyPointImage1, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
drawKeypoints(srcImage, detectKeyPoint, keyPointImage2, Scalar(0, 0, 255), DrawMatchesFlags::DEFAULT);
imshow("src image", srcImage);
imshow("keyPoint image1", keyPointImage1);
imshow("keyPoint image2", keyPointImage2);
//imwrite("F:\\opencv\\OpenCVImage\\FeatureDetectSrc1FASTKeyPointImageDefault.jpg", keyPointImage2);
waitKey(0);
return 0;
}