#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include "opencv2/xfeatures2d/nonfree.hpp"
using namespace std;
using namespace cv;
int main()
{
Mat image = imread("D:/house.jpg", 0);
vector<KeyPoint> keypoints;
//cv::FastFeatureDetector fast(40);
//fast.detect(image, keypoints); 版本问题这两句不好使,用下面代替
Ptr<FeatureDetector> fast = FastFeatureDetector::create(40);
fast->detect(image, keypoints);
drawKeypoints(image, keypoints, image, Scalar(255, 255, 255), DrawMatchesFlags::DRAW_OVER_OUTIMG);
namedWindow("FAST Features");
imshow("FAST Features", image);
keypoints.clear();
// cv::SurfFeatureDetector surf(2500);
// Detect the SURF features
//surf.detect(image, keypoints); //不好使用下面的代替
Ptr<FeatureDetector> surf = xfeatures2d::SurfFeatureDetector::create(2500);
surf->detect(image, keypoints);
cv::Mat featureImage;
cv::drawKeypoints(image, keypoints, featureImage, cv::Scalar(255, 255, 255), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
// Display the corners
cv::namedWindow("SURF Features");
cv::imshow("SURF Features", featureImage);
waitKey(0);
return 0;
}
文章标题
最新推荐文章于 2022-05-12 11:32:07 发布