没有合适的资源?快使用搜索试试~ 我知道了~
opencv 中模板匹配的完整例子
4星 · 超过85%的资源 需积分: 43 285 下载量 69 浏览量
2014-09-12
17:55:40
上传
评论 2
收藏 6KB TXT 举报
温馨提示
试读
6页
特征点提取和匹配的通用方法 在opencv中应用 并做了大量的翻译和多中算法的结合 基于这个就可以做项目开发了!
资源推荐
资源详情
资源评论
Mat object = imread( "chicky_512.png", CV_LOAD_IMAGE_GRAYSCALE );
Mat img_1 = imread( "chicky_512.png", CV_LOAD_IMAGE_GRAYSCALE );
Mat img_2 = imread( "chicky_c.png", CV_LOAD_IMAGE_GRAYSCALE );
if( !object.data )
{
std::cout<< "Error reading object " << std::endl;
return -1;
}
if( !img_1.data || !img_2.data )
{ return -1; }
//-- Step 1: Detect the keypoints using SURF Detector
//Detect the keypoints using SURF Detector
int minHessian = 500;
/*1 FeatureDetector
FeatureDetector是关键点检测类的抽象基类,其已经实现的具体类有:
class FastFeatureDetector
class GoodFeaturesToTrackDetector
class MserFeatureDetector
class StarFeatureDetector
class SiftFeatureDetector
class SurfFeatureDetector
要使用某一种检测器,可以直接调用FeatureDetector的工厂来创建,该工厂是一个静态方法,如下:
// Create feature detector by detector name.
static Ptr<FeatureDetector> create( const string& detectorType );
也可以像我的示例代码中那样显式的创建,如下:
FeatureDetector *pDetector = new SurfFeatureDetector;
可以用swich实现在多种方法中切换。*/
SurfFeatureDetector detector( minHessian );// 这里我们用了SURF特征点
std::vector<KeyPoint> kp_object;
Mat img_1 = imread( "chicky_512.png", CV_LOAD_IMAGE_GRAYSCALE );
Mat img_2 = imread( "chicky_c.png", CV_LOAD_IMAGE_GRAYSCALE );
if( !object.data )
{
std::cout<< "Error reading object " << std::endl;
return -1;
}
if( !img_1.data || !img_2.data )
{ return -1; }
//-- Step 1: Detect the keypoints using SURF Detector
//Detect the keypoints using SURF Detector
int minHessian = 500;
/*1 FeatureDetector
FeatureDetector是关键点检测类的抽象基类,其已经实现的具体类有:
class FastFeatureDetector
class GoodFeaturesToTrackDetector
class MserFeatureDetector
class StarFeatureDetector
class SiftFeatureDetector
class SurfFeatureDetector
要使用某一种检测器,可以直接调用FeatureDetector的工厂来创建,该工厂是一个静态方法,如下:
// Create feature detector by detector name.
static Ptr<FeatureDetector> create( const string& detectorType );
也可以像我的示例代码中那样显式的创建,如下:
FeatureDetector *pDetector = new SurfFeatureDetector;
可以用swich实现在多种方法中切换。*/
SurfFeatureDetector detector( minHessian );// 这里我们用了SURF特征点
std::vector<KeyPoint> kp_object;
detector.detect( object, kp_object );
FeatureDetector *pDetector = new SurfFeatureDetector; // 这里我们用了SURF特征点
std::vector<KeyPoint> keypoints_1, keypoints_2;
pDetector->detect(img_1, keypoints_1);
pDetector->detect(img_2, keypoints_2);
delete pDetector;
/*2 DescriptorExtractor
DescriptorExtractor是提取关键点的描述向量类抽象基类,其具体类有:
class SiftDescriptorExtractor
class SurfDescriptorExtractor
class CalonderDescriptorExtractor
class BriefDescriptorExtractor
class OpponentColorDescriptorExtractor
要使用某一种描述向量,可以调用DescriptorExtractor的工厂来创建,静态方法如下:
static Ptr<DescriptorExtractor> create( const string& descriptorExtractorType );
也可以像我的示例代码中那样显式的创建,如下:
DescriptorExtractor *pExtractor = new SurfDescriptorExtractor;
可以用swich实现在多种方法中切换。*/
//Calculate descriptors (feature vectors)
////-- Step 2: Calculate descriptors (feature vectors)// 提取SURF描述向量
SurfDescriptorExtractor extractor;
Mat des_object;
extractor.compute( object, kp_object, des_object );
///////////////////////////
DescriptorExtractor *pExtractor = new SurfDescriptorExtractor; // 提取SURF描述向量
Mat descriptors_1, descriptors_2;
pExtractor->compute(img_1, keypoints_1, descriptors_1);
pExtractor->compute(img_2, keypoints_2, descriptors_2);
FeatureDetector *pDetector = new SurfFeatureDetector; // 这里我们用了SURF特征点
std::vector<KeyPoint> keypoints_1, keypoints_2;
pDetector->detect(img_1, keypoints_1);
pDetector->detect(img_2, keypoints_2);
delete pDetector;
/*2 DescriptorExtractor
DescriptorExtractor是提取关键点的描述向量类抽象基类,其具体类有:
class SiftDescriptorExtractor
class SurfDescriptorExtractor
class CalonderDescriptorExtractor
class BriefDescriptorExtractor
class OpponentColorDescriptorExtractor
要使用某一种描述向量,可以调用DescriptorExtractor的工厂来创建,静态方法如下:
static Ptr<DescriptorExtractor> create( const string& descriptorExtractorType );
也可以像我的示例代码中那样显式的创建,如下:
DescriptorExtractor *pExtractor = new SurfDescriptorExtractor;
可以用swich实现在多种方法中切换。*/
//Calculate descriptors (feature vectors)
////-- Step 2: Calculate descriptors (feature vectors)// 提取SURF描述向量
SurfDescriptorExtractor extractor;
Mat des_object;
extractor.compute( object, kp_object, des_object );
///////////////////////////
DescriptorExtractor *pExtractor = new SurfDescriptorExtractor; // 提取SURF描述向量
Mat descriptors_1, descriptors_2;
pExtractor->compute(img_1, keypoints_1, descriptors_1);
pExtractor->compute(img_2, keypoints_2, descriptors_2);
剩余5页未读,继续阅读
seayezi
- 粉丝: 7
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页