opencv学习笔记三十三:FLANN匹配

FLANN库全称是Fast Library for Approximate Nearest Neighbors,它是目前最完整的(近似)最近邻开源库。不但实现了一系列查找算法,还包含了一种自动选取最快算法的机制。

OpenCV提供了 两种Matching方式 : 
BFMatcher
FlannBasedMatcher
BF(Brute Force)就是用暴力方法找到点集一中每个descriptor在点集二中距离最近的 descriptor; 
FLANN(Fast Library for Approximate Nearest Neighbors) 使用快速近似最近邻搜索算法寻找。 

#include
#include

using namespace cv;
using namespace xfeatures2d;
using namespace std;
int main(int arc, char** argv) 
{ 
	Mat src1 = imread("1.jpg",IMREAD_GRAYSCALE);
	Mat src2 = imread("2.jpg", IMREAD_GRAYSCALE);
	namedWindow("input1", CV_WINDOW_AUTOSIZE);
	imshow("input1", src1);
	imshow("input2", src2);

	//surf features extraction
	int minHessian = 400;
	Ptrsurf = SURF::create(minHessian);
	vectorkeypoints1, keypoints2;
	Mat descriptors1, descriptors2

你可能感兴趣的:(opencv)