分享

[转载]OpenCV中特征点提取和匹配的通用方法_dzh_漫漫修行路

 昵称30114049 2016-01-11
OpenCV在新版本中把很多C语言的代码都重新整理成了C++代码,让我们在使用的时候更加方便灵活。其中对于特征点的提取和匹配,充分体现了C++的强大。下面直接用例子来说明。假设我们有两幅图:1.bmp和2.bmp,要从中提取体征点并匹配,代码如下:
// 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); // Do not copy
Mat matRightImage = Mat(pRightImage, false);
// Key point and its descriptor
vector LeftKey;
vector RightKey;
Mat LeftDescriptor;
Mat RightDescriptor;
vector 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描述向量
pE

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多