特征检测器 FeatureDetector
OpenCV提供FeatureDetector实现特征检测及匹配
- class CV_EXPORTS FeatureDetector
- {
- public:
- virtual ~FeatureDetector();
- void detect( const Mat& image, vector<KeyPoint>& keypoints,
- const Mat& mask=Mat() ) const;
- void detect( const vector<Mat>& images,
- vector<vector<KeyPoint> >& keypoints,
- const vector<Mat>& masks=vector<Mat>() ) const;
- virtual void read(const FileNode&);
- virtual void write(FileStorage&) const;
- static Ptr<FeatureDetector> create( const string& detectorType );
- protected:
- ...
- };
FeatureDetetor是虚类,通过定义FeatureDetector的对象可以使用多种特征检测方法。通过create()函数调用:
- Ptr<FeatureDetector> FeatureDetector::create(const string& detectorType);
OpenCV 2.4.3提供了10种特征检测方法:
- "FAST" – FastFeatureDetector
- "STAR" – StarFeatureDetector
- "SIFT" – SIFT (nonfree module)
- "SURF" – SURF (nonfree module)
- "ORB" – ORB
- "MSER" – MSER
- "GFTT" – GoodFeaturesToTrackDetector
- "HARRIS" – GoodFeaturesToTrackDetector with Harris detector enabled
- "Dense" – DenseFeatureDetector
- "SimpleBlob" – SimpleBlobDetector
- initModule_nonfree();
- int main()
- {
- initModule_nonfree();//if use SIFT or SURF
- Ptr<FeatureDetector> detector = FeatureDetector::create( "SIFT" );
- Ptr<DescriptorExtractor> descriptor_extractor = DescriptorExtractor::create( "SIFT" );
- Ptr<DescriptorMatcher> descriptor_matcher = DescriptorMatcher::create( "BruteForce" );
- if( detector.empty() || descriptor_extractor.empty() )
- throw runtime_error("fail to create detector!");
- Mat img1 = imread("images\\box_in_scene.png");
- Mat img2 = imread("images\\box.png");
- //detect keypoints;
- vector<KeyPoint> keypoints1,keypoints2;
- detector->detect( img1, keypoints1 );
- detector->detect( img2, keypoints2 );
- cout <<"img1:"<< keypoints1.size() << " points img2:" <<keypoints2.size()
- << " points" << endl << ">" << endl;
- //compute descriptors for keypoints;
- cout << "< Computing descriptors for keypoints from images..." << endl;
- Mat descriptors1,descriptors2;
- descriptor_extractor->compute( img1, keypoints1, descriptors1 );
- descriptor_extractor->compute( img2, keypoints2, descriptors2 );
- cout<<endl<<"Descriptors Size: "<<descriptors2.size()<<" >"<<endl;
- cout<<endl<<"Descriptor's Column: "<<descriptors2.cols<<endl
- <<"Descriptor's Row: "<<descriptors2.rows<<endl;
- cout << ">" << endl;
- //Draw And Match img1,img2 keypoints
- Mat img_keypoints1,img_keypoints2;
- drawKeypoints(img1,keypoints1,img_keypoints1,Scalar::all(-1),0);
- drawKeypoints(img2,keypoints2,img_keypoints2,Scalar::all(-1),0);
- imshow("Box_in_scene keyPoints",img_keypoints1);
- imshow("Box keyPoints",img_keypoints2);
- descriptor_extractor->compute( img1, keypoints1, descriptors1 );
- vector<DMatch> matches;
- descriptor_matcher->match( descriptors1, descriptors2, matches );
- Mat img_matches;
- drawMatches(img1,keypoints1,img2,keypoints2,matches,img_matches,Scalar::all(-1),CV_RGB(255,255,255),Mat(),4);
- imshow("Mathc",img_matches);
- waitKey(10000);
- return 0;
- }
特征检测结果如图:
- Mat image = imread("images\\features.jpg");
- Mat descriptors;
- vector<KeyPoint> keypoints;
- SimpleBlobDetector::Params params;
- //params.minThreshold = 10;
- //params.maxThreshold = 100;
- //params.thresholdStep = 10;
- //params.minArea = 10;
- //params.minConvexity = 0.3;
- //params.minInertiaRatio = 0.01;
- //params.maxArea = 8000;
- //params.maxConvexity = 10;
- //params.filterByColor = false;
- //params.filterByCircularity = false;
- SimpleBlobDetector blobDetector( params );
- blobDetector.create("SimpleBlob");
- blobDetector.detect( image, keypoints );
- drawKeypoints(image, keypoints, image, Scalar(255,0,0));
以下是SimpleBlobDetector按颜色检测的图像特征:
(转载请注明作者和出处:http://blog.csdn.net/xiaowei_cqu 未经允许请勿用于商业用途)
特征检测器 FeatureDetector相关推荐
- OpenCV2.4.4中调用SIFT特征检测器进行图像匹配
OpenCV中一些相关结构说明: 特征点类: [cpp] view plain copy class KeyPoint { Point2f pt; //坐标 float size; //特征 ...
- 【图像处理】——特征匹配(SIFT特征检测器+FLANN特征匹配方法+KNN近邻最优匹配筛选)——cv.xfeatures2d.SIFT_create()sift.detectAndCompute
转载请注明地址 目录 1.特征检测和特征匹配方法 (1)特征检测算法 (2)特征匹配算法 (3)各种特征检测算法的比较 2.特征匹配的基本步骤(附带主要的函数) (1)图像预处理--灰度化(模板--查 ...
- 非刚性人脸跟踪 —— 面部特征检测器
本节将用一种表示方法来建立人脸特征检测器,该方法也许是人们认为最简单的模型,即:线性图像模型.由于该算法需表示一个图象块,因此这种面部特征检测器称为块模型( patch model ).该模型在 pa ...
- OpenCV —— 特征点检测之 SIFT 特征检测器
SIFT 原理详解 尺度空间的表示 高斯金字塔的构建 高斯差分金字塔 空间极值点检测 尺度变化的连续性 特征点定位 特征点的精确定位 剔除不稳定的边缘响应点 特征点方向赋值 生成特征描述 SIFT的缺 ...
- 目标检测 - 特征检测器比较
定量比较表明,特征检测器描述符检测大量特征的能力的一般顺序为: ORB>BRISK>SURF>SIFT>AKAZE>KAZE 每个特征点的特征检测描述计算效率的算法顺序为 ...
- VLfeat学习(1)——Covariant feature detectors(协变特征检测器)
VLfeat是一个开源BSD的轻量级的计算机视觉库算法,主要实现了SIFT.MSER.K-means.hierarchical.agglomerative information bottleneck ...
- scikit-image库----CENSURE特征检测器(二十二)
CENSURE特征检测器是一种尺度不变的中心环绕检测器(CENSURE),其性能优于其他检测器,并且能够实时实现. from skimage import data from skimage impo ...
- OpenCV3学习(11.5) FAST特征检测器FastFeatureDetector
简介 FAST特征检测的特点是简单.快速.有效.作者为了在实时帧速率情况下进行高速特征检测,提出FAST特征检测. 相比SIFT.DoG.Harris.SUSAN等比较耗时的特征检测方法,FAST只利 ...
- OpenCV3学习(11.7) BRISK特征检测器及BRISK描述符
BRISK算法一种特征提取算法,也是一种二进制的特征描述算子. 它具有较好的旋转不变性.尺度不变性,较好的鲁棒性等.在图像配准应用中,速度比较:SIFT<SURF<BRISK<FR ...
最新文章
- linux下的rman自动备份脚本,LINUX上RMAN自动备份脚本
- 迁移学习简介(tranfer learning)
- Caffe: Faster-RCNN Python版本配置 (Windows)
- python中threading模块详解
- JavaWeb:XML总结
- linux drbd同步,DRBD数据镜像主备节点同步数据
- SQL Server:查找表的生成或顺序
- 官方配置要求_电脑配置不够玩赛博朋克?租电脑一个月只要百来元就能玩!
- 单层的神经网络使用自定义的损失函数
- java 算法基础之三合并排序法
- rubyOnRails 开发以及风格指南
- Python漫画下载器V2,进行更好的封装,更高效的多线程与刷新机制
- 基于asp.net大学生就业管理系统#毕业设计
- 高尔顿钉板 matlab,高尔顿钉板试验模拟
- 国内云服务器提供商排名(仅供参考)
- vscode:解决按英文感叹号!+tab,无法生成html模板框架的问题
- hdu2028java-Lowest Common Multiple Plus
- PTA 7-80 水仙花数 (20分)
- C++ 小白 学习记录15
- linux barrier,Linux文件系统的barrier:启用还是禁用
热门文章
- 58同城创始人姚劲波:未来十年是中国创业最好机会
- 深入理解分布式技术 - 消息队列知识点回顾总结
- 深入理解分布式技术 - 消息幂等性如何保障不重复消费
- 深入理解分布式技术 - 微服务为什么需要API 网关
- 数据存储之SharedPreferences
- 信息提醒之对话框(AlertDialog + ProgressDialog)-更新中
- Android Q适配
- sql 判断分钟是偶数数据_使用SQL交换座位(奇偶数的用法)
- anguarjs 上传图片预览_MIUI12 20.10.29更新,新版「模糊预览图」
- javascript 数组以及对象的深拷贝方法