大佬教程收集整理的这篇文章主要介绍了c语言通过opencv实现轮廓处理与切割,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
RETR_EXTERNAL
#include "opencv/cv.h" #include "opencv/highgui.h" using namespace std; using namespace cv; int main() { Mat srcimg=imread("./22.jpg"); Mat dst; cvtcolor(srcimg,dst,Cv_bGR2GRAY); threshold(dst,120,255,1); vector<vector<Point> > edgepoint; vector<Vec4i> lclass; findContours(dst,edgepoint,lclass,RETR_EXTERNAL,CHAIN_APPROX_NONE,Point()); Mat mat[edgepoint.size()]; for(int i=0;i<edgepoint.size();i++) { Rect rec=boundingRect(Mat(edgepoint[i])); mat[i]=dst(rec); rectangle(dst,rec,Scalar(100,80,90),1,0); drawContours(dst,i,Scalar(200),8,lclass); String str=to_String(i); imshow(str,mat[i]); } imshow("tt",dst); cout<<edgepoint.size()<<endl; waitKey(0); }
以上是大佬教程为你收集整理的c语言通过opencv实现轮廓处理与切割全部内容,希望文章能够帮你解决c语言通过opencv实现轮廓处理与切割所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。