尺度不变特征的检测
SURF特征(加速稳健特征Speeded Up Robust Feature)
参考博文
surf算法原理
示例程序
#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include </home/jlm/3rdparty/opencv/opencv_contrib/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
int main(int argc, char** argv) {
if(argc != 2)
{
cerr << "don't get the right numbers of image" << endl;
return -1;
}
cv::Mat image = cv::imread(argv[1],cv::IMREAD_GRAYSCALE);
if(image.empty())
{
cout << "don't get the data of the argv[1]" << endl;
return -1;
}
cv::imshow("Original", image);
cv::waitKey(0);
cv::Ptr<cv::xfeatures2d::SurfFeatureDetector> ptrSURF =
cv::xfeatures2d::SurfFeatureDetector::create(2000.0);
vector<cv::KeyPoint> Keypoints;
ptrSURF -> detect(image, Keypoints);
cv::Mat outImage;
cv::drawKeypoints(image,
Keypoints,
outImage,
cv::Scalar(255,255,255),
cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS
);
cv::imshow("OutImage",outImage);
cv::waitKey(0);
return 0;
}
多尺度FAST特征检测
示例程序
#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include </home/jlm/3rdparty/opencv/opencv_contrib/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
int main(int argc, char** argv) {
if(argc != 2)
{
cerr << "don't get the right numbers of image" << endl;
return -1;
}
cv::Mat image = cv::imread(argv[1],cv::IMREAD_GRAYSCALE);
if(image.empty())
{
cout << "don't get the data of the argv[1]" << endl;
return -1;
}
cv::imshow("Original", image);
cv::waitKey(0);
cv::Ptr<cv::BRISK> ptrBRISK =
cv::BRISK::create();
vector<cv::KeyPoint> Keypoints;
ptrBRISK -> detect(image, Keypoints);
cv::Mat outImage;
cv::drawKeypoints(image,
Keypoints,
outImage,
cv::Scalar(255,255,255),
cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS
);
cv::imshow("OutImage",outImage);
cv::waitKey(0);
return 0;
}