AKAZE局部匹配
AKAZE局部匹配介绍
AOS 构造尺度空间
Hessian矩阵特征点检测
方向指定基于一阶微分图像
描述子生成
与SIFT、SUFR比较
更加稳定
非线性尺度空间
AKAZE速度更加快
比较新的算法,只有OpenCV新版本才可以用
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat src = imread("D:/vcprojects/images/test.png", IMREAD_GRAYSCALE);
if (src.empty()) {
printf("could not load image…\n");
return -;
}
imshow("input image", src);
// kaze detection
Ptr<AKAZE> detector = AKAZE::create();
vector<KeyPoint> keypoints;
double t1 = getTickCount();
detector->detect(src, keypoints, Mat());
double t2 = getTickCount();
double tkaze = \* (t2 - t1) / getTickFrequency();
printf("KAZE Time consume(ms) : %f", tkaze);
Mat keypointImg;
drawKeypoints(src, keypoints, keypointImg, Scalar::all(-), DrawMatchesFlags::DEFAULT);
imshow("kaze key points", keypointImg);
waitKey();
return ;
}
#include
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat img1 = imread("D:/vcprojects/images/box.png", IMREAD_GRAYSCALE);
Mat img2 = imread("D:/vcprojects/images/box_in_scene.png", IMREAD_GRAYSCALE);
if (img1.empty() || img2.empty()) {
printf("could not load images…\n");
return -;
}
imshow("box image", img1);
imshow("scene image", img2);
// extract akaze features
Ptr<AKAZE> detector = AKAZE::create();
vector<KeyPoint> keypoints\_obj;
vector<KeyPoint> keypoints\_scene;
Mat descriptor\_obj, descriptor\_scene;
double t1 = getTickCount();
detector->detectAndCompute(img1, Mat(), keypoints\_obj, descriptor\_obj);
detector->detectAndCompute(img2, Mat(), keypoints\_scene, descriptor\_scene);
double t2 = getTickCount();
double tkaze = \* (t2 - t1) / getTickFrequency();
printf("AKAZE Time consume(ms) : %f\\n", tkaze);
// matching
FlannBasedMatcher matcher(new flann::LshIndexParams(, , ));
//FlannBasedMatcher matcher;
vector<DMatch> matches;
matcher.match(descriptor\_obj, descriptor\_scene, matches);
// draw matches(key points)
Mat akazeMatchesImg;
drawMatches(img1, keypoints\_obj, img2, keypoints\_scene, matches, akazeMatchesImg);
imshow("akaze match result", akazeMatchesImg);
/\*
vector<DMatch> goodMatches;
double minDist = 100000, maxDist = 0;
for (int i = 0; i < descriptor\_obj.rows; i++) {
double dist = matches\[i\].distance;
if (dist < minDist) {
minDist = dist;
}
if (dist > maxDist) {
maxDist = dist;
}
}
printf("min distance : %f", minDist);
for (int i = 0; i < descriptor\_obj.rows; i++) {
double dist = matches\[i\].distance;
if (dist < max( 1.5\*minDist, 0.02)) {
goodMatches.push\_back(matches\[i\]);
}
}
drawMatches(img1, keypoints\_obj, img2, keypoints\_scene, goodMatches, akazeMatchesImg, Scalar::all(-1),
Scalar::all(-1), vector<char>(), DrawMatchesFlags::NOT\_DRAW\_SINGLE\_POINTS);
imshow("good match result", akazeMatchesImg);
\*/
waitKey();
return ;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章