OpenCV中特征点提取和匹配的通用方法
来源:互联网 发布:移动网络波动怎么解决 编辑:程序博客网 时间:2024/05/21 05:37
// Load image from file
IplImage *pLeftImage = cvLoadImage("1.bmp",CV_LOAD_IMAGE_GRAYSCALE);
IplImage *pRightImage = cvLoadImage("2.bmp",CV_LOAD_IMAGE_GRAYSCALE);
// Convert IplImage to cv::Mat
Mat matLeftImage = Mat(pLeftImage, false);
Mat matRightImage = Mat(pRightImage, false);
// Key point and its descriptor
vector<KeyPoint> LeftKey;
vector<KeyPoint> RightKey;
Mat LeftDescriptor;
Mat RightDescriptor;
vector<DMatch> Matches;
// Detect key points from image
FeatureDetector *pDetector = new SurfFeatureDetector; //这里我们用了SURF特征点
pDetector->detect(matLeftImage, LeftKey);
pDetector->detect(matRightImage, RightKey);
delete pDetector;
// Extract descriptors
DescriptorExtractor *pExtractor = new SurfDescriptorExtractor;// 提取SURF描述向量
pExtractor->compute(matLeftImage, LeftKey,LeftDescriptor);
pExtractor->compute(matRightImage, RightKey,RightDescriptor);
delete pExtractor;
// Matching features
DescriptorMatcher *pMatcher = new FlannBasedMatcher; //使用Flann匹配算法
pMatcher->match(LeftDescriptor, RightDescriptor,Matches);
delete pMatcher;
// Show result
Mat OutImage;
drawMatches(matLeftImage, LeftKey, matRightImage, RightKey,Matches, OutImage);
cvNamedWindow( "Match features", 1);
cvShowImage("Match features",&(IplImage(OutImage)));
cvWaitKey( 0 );
cvDestroyWindow( "Match features" );
1 FeatureDetector
要使用某一种检测器,可以直接调用FeatureDetector的工厂来创建,该工厂是一个静态方法,如下:
// Create feature detector by detector name.
static Ptr<FeatureDetector> create(const string& detectorType );
也可以像我的示例代码中那样显式的创建,如下:
FeatureDetector *pDetector = new SurfFeatureDetector;
可以用swich实现在多种方法中切换。
2 DescriptorExtractor
要使用某一种描述向量,可以调用DescriptorExtractor的工厂来创建,静态方法如下:
static Ptr<DescriptorExtractor>create( const string& descriptorExtractorType);
也可以像我的示例代码中那样显式的创建,如下:
DescriptorExtractor *pExtractor = newSurfDescriptorExtractor;
可以用swich实现在多种方法中切换。
3 DescriptorMatcher
匹配器可以由静态工厂方法直接创建,如下:
static Ptr<DescriptorMatcher>create( const string& descriptorMatcherType );
也可以像我的示例代码中那样显式的创建,如下:
DescriptorMatcher *pMatcher = new FlannBasedMatcher;
可以用swich实现在多种方法中切换。
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- 【opencv】特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方…
- OpenCV中特征点提取和匹配的通用方…
- 摘自知乎上的一段话
- Freemaker_入门+深入+开发指南+学习笔记
- linux bash shell中,单引号、 双引号,反引号(``)的区别及各种括号的区别
- IOS系列——自定义tableVIew
- 在ArcGIS10中AO编辑操作
- OpenCV中特征点提取和匹配的通用方法
- Android 深入ViewPager补间动画,实现类京东商城首页广告Banner切换效果
- SQL2000数据库学习地图
- php pearmail 发送邮件(windows环境)
- Java数组(初学者必看)
- Ubuntu安装为知笔记
- 在ArcGlobe三维环境中进行数据查询(.net)
- dg主备库切换步骤
- ORB算法