头文件
#include <opencv2/features2d.hpp>
opencv类型
| |
---|
FastFeatureDetector | |
SurfFeatureDetector | |
SiftFeatureDetector | |
GFTTDetector | |
FAST
例子
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
using namespace cv;
int main(void)
{
int thre = 40;
Ptr<FastFeatureDetector> fast = FastFeatureDetector::create(thre);
std::vector<KeyPoint> keypoints;
Mat src, dst;
src = imread("image/lena.jpg");
dst = src.clone();
if (!src.empty()) {
imshow("src", src);
for (int iter = 0; iter < 10; iter++){
fast->detect(src, keypoints);
drawKeypoints(dst, keypoints, dst, Scalar::all(-1), DrawMatchesFlags::DRAW_OVER_OUTIMG);
}
if (!dst.empty()) {
imshow("dst", dst);
waitKey(0);
}
}
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200809163028674.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTEzMTAzODM=,size_16,color_FFFFFF,t_70)
GFTT
例子
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
using namespace cv;
int main(void)
{
int thre = 40;
Ptr<GFTTDetector> gftt = GFTTDetector::create(thre);
std::vector<KeyPoint> keypoints;
Mat src, dst;
src = imread("image/lena.jpg");
dst = src.clone();
if (!src.empty()) {
imshow("src", src);
for (int iter = 0; iter < 10; iter++){
gftt ->detect(src, keypoints);
drawKeypoints(dst, keypoints, dst, Scalar::all(-1), DrawMatchesFlags::DRAW_OVER_OUTIMG);
}
if (!dst.empty()) {
imshow("dst", dst);
waitKey(0);
}
}
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200809165435578.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTEzMTAzODM=,size_16,color_FFFFFF,t_70)