opencv圆心提取--findCirlesGrid
- findCirlesGrid–标定圆心
有大佬看过opencv检测圆心这个函数吗?看不懂啊!求源码分析
bool findCirclesGrid( InputArray _image, Size patternSize,OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector,const CirclesGridFinderParameters& parameters_)
{CV_INSTRUMENT_REGION();CirclesGridFinderParameters parameters = parameters_; // parameters.gridType is amended belowbool isAsymmetricGrid = (flags & CALIB_CB_ASYMMETRIC_GRID) ? true : false;bool isSymmetricGrid = (flags & CALIB_CB_SYMMETRIC_GRID ) ? true : false;CV_Assert(isAsymmetricGrid ^ isSymmetricGrid);std::vector<Point2f> centers;std::vector<Point2f> points;if (blobDetector) //斑点检测{std::vector<KeyPoint> keypoints;blobDetector->detect(_image, keypoints);for (size_t i = 0; i < keypoints.size(); i++){points.push_back(keypoints[i].pt);}}else{CV_CheckTypeEQ(_image.type(), CV_32FC2, "blobDetector must be provided or image must contains Point2f array (std::vector<Point2f>) with candidates");_image.copyTo(points); //把image的内容粘贴到points}if(flags & CALIB_CB_ASYMMETRIC_GRID)parameters.gridType = CirclesGridFinderParameters::ASYMMETRIC_GRID;if(flags & CALIB_CB_SYMMETRIC_GRID)parameters.gridType = CirclesGridFinderParameters::SYMMETRIC_GRID;if(flags & CALIB_CB_CLUSTERING){CirclesGridClusterFinder circlesGridClusterFinder(parameters);circlesGridClusterFinder.findGrid(points, patternSize, centers);Mat(centers).copyTo(_centers);return !centers.empty();}bool isValid = false;const int attempts = 2;const size_t minHomographyPoints = 4;Mat H;for (int i = 0; i < attempts; i++){centers.clear();//斑点变量清零//根据CirclesGridFinder 类(几何特征),检测相关圆形,并排序输出。CirclesGridFinder boxFinder(patternSize, points, parameters); try{bool isFound = boxFinder.findHoles();if (isFound){switch(parameters.gridType){case CirclesGridFinderParameters::SYMMETRIC_GRID:boxFinder.getHoles(centers);break;case CirclesGridFinderParameters::ASYMMETRIC_GRID:boxFinder.getAsymmetricHoles(centers);break;default:CV_Error(Error::StsBadArg, "Unknown pattern type");}isValid = true;break; // done, return result}}catch (const cv::Exception& e){CV_UNUSED(e);CV_LOG_DEBUG(NULL, "findCirclesGrid2: attempt=" << i << ": " << e.what());// nothing, next attempt}boxFinder.getHoles(centers);if (i != attempts - 1){if (centers.size() < minHomographyPoints)break;H = CirclesGridFinder::rectifyGrid(boxFinder.getDetectedGridSize(), centers, points, points);}}if (!centers.empty() && !H.empty()) // undone rectification{Mat orgPointsMat;transform(centers, orgPointsMat, H.inv());convertPointsFromHomogeneous(orgPointsMat, centers);}Mat(centers).copyTo(_centers);return isValid;
}
opencv圆心提取--findCirlesGrid相关推荐
- 图像处理库(fbc_cv):源自OpenCV代码提取
在实际项目中会经常用到一些基本的图像处理操作,而且经常拿OpenCV进行结果对比,因此这里从OpenCV中提取了一些代码组织成fbc_cv库.项目fbc_cv所有的代码已放到GitHub中,地址为 ...
- OpenCV PCA提取对象的方向的实例(附完整代码)
OpenCV PCA提取对象的方向的实例 OpenCV PCA提取对象的方向的实例 OpenCV PCA提取对象的方向的实例 #include "opencv2/core.hpp" ...
- python图片保存为txt文件_python + opencv实现提取png图像的像素信息并存储到txt文件中(附安装指导)...
相关库安装指导: 这里我们需要 opencv_python,numpy,matplotlib库,另外我用的是python3.6.1版本. 一般库大家都是用pip install命令安装的,不过不知道为 ...
- OpenCV python 提取图像内的三色
OpenCV python 提取图像内的三色 原图 [opencv.jpg] import cv2 import numpy as npdef main():# 1.导入图片img_src = cv2 ...
- OpenCV实战——提取视频中的前景对象
OpenCV实战--提取视频中的前景对象 0. 前言 1. 提取视频中的前景对象 2. 混合高斯方法 3. 完整代码 相关链接 0. 前言 当固定摄像机观察场景时,背景基本保持不变.在这种情况下,我们 ...
- matlab圆心提取【你想要的方法这里都有】
0 引言 圆已经成为了生活中最常见的几何图形,抬头望去,就能看见非常多由圆构成的东西,如水杯.碗.汤圆.鸡蛋等.离开生活,在各种各样的光学系统中,圆也是最常见的,照相机的光圈,望远镜的物镜,显微镜的 ...
- 计算机视觉--opencv圆点提取
参考资料 https://blog.csdn.net/app_12062011/article/details/51953030 https://blog.csdn.net/gggttt222/art ...
- OpenCV代码提取:Windows上通过DShow获取Camera视频
在OpenCV 3.1中获取视频的模块在videoio(video input and output module)中,调用VideoCapture类接口,除了videoio模块外还依赖core.hi ...
- OpenCV代码提取:cvtColor函数的实现
OpenCV中的cvtColor函数包括了很多颜色格式之间的转换,用起来很方便,这里对cvtColor函数的code进行了提取,经测试,和OpenCV3.1结果完全一致. 实现代码cvtColor.h ...
最新文章
- 配置tomcat8数据源(采用局部数据源方式)
- rp-provide-from-last
- 笔记本如何与其他计算机共享,笔记本电脑怎么和手机共享文件
- 南阳32--组合数(Dfs)
- 记忆碎片---搭建php+apache+eclipse中的问题
- HarmonyOS 编译系统源码
- shell脚本基础 循环机构
- 面向对象,局部变量和成员变量
- JAVA-反射面试题及答案
- error LNK2005: 已经在*.obj中定义
- 最新最全论文合集——CCS 历年最佳论文汇总
- 五金冲压模具设计分享pressCAD外挂使用小窍门
- 农历24节气日期计算公式
- 使用websocket实现协同编辑
- 用Nodejs爬取Matrix67的博客
- DOM元素 DAY17
- 小白兔写话_小白兔写话二年级作文
- 多场景双师课堂解决方案
- 妖魔复苏:天师下山!开局传承天师度(二)
- R语言画个中国地图使用shp文件