基于opencv的裂纹纹检测系统c源代码内容摘要:

ist_height / max_val)。 //要绘制的高度 rectangle(hist_img, Point(i*scale, hist_height 1), Point((i + 1)*scale 1, hist_height intensity), CV_RGB(255, 255, 255))。 } dstImg = hist_img。 } int CrackDetection::FilterContours(Mat amp。 imgSrc, Mat amp。 imgDst, bool isSpecify = true, int numContours = 100, double ratioThreshold = 2) { Mat imgTmp = Mat::zeros((), CV_8UC1)。 vectorvectorPoint contoursToKeep。 vectorvectorPoint contoursAll。 本文中代码为作者参考网络相关资料 基础上 的 开发成果 , 仅供参考学习 ,如有其他机器视觉领域算法和软件定制需要, 请联系作者 Email: vectorVec4i hierarchy。 /// 寻找轮廓 findContours(imgSrc, contoursAll, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_TC89_KCOS, Point(0, 0))。 if (() = 0) { return 0。 } double thresholdPARatio = ratioThreshold。 double thresholdArea = 0, thresholdSpan = 0。 sort((), (), ContoursSortByArea)。 double tmpSpan = GetContourSpan(contoursAll[0])。 double tmpArea = contourArea(contoursAll[0])。 //if the biggest shadow has the crack features if (tmpSpan ( + )*) { //isSpecify=false: so we just filter the img with no specifications if (false == isSpecify) { for (int i = 0。 i () amp。 amp。 i numContours。 i++) { tmpSpan = GetContourSpan(contoursAll[i])。 if (tmpSpan ( + )*) 本文中代码为作者参考网络相关资料 基础上 的 开发成果 , 仅供参考学习 ,如有其他机器视觉领域算法和软件定制需要, 请联系作者 Email: { (contoursAll[i])。 } } } else { thresholdArea += contourArea(contoursAll[0])。 sort((), (), ContoursSortBySpan)。 thresholdSpan += GetContourSpan(contoursAll[0])。 for (int i = 0。 i () amp。 amp。 i numContours。 i++) { tmpArea = contourArea(contoursAll[i])。 tmpSpan = GetContourSpan(contoursAll[i])。 if ((tmpSpan / 2)*(tmpSpan / 2)* / tmpArea ratioThreshold amp。 amp。 tmpSpan / thresholdSpan amp。 amp。 tmpArea / thresholdArea ) { //删除面积小于设定值的轮廓 (contoursAll[i])。 } 本文中代码为作者参考网络相关资料 基础上 的 开发成果 , 仅供参考学习 ,如有其他机器视觉领域算法和软件定制需要, 请。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。