c语言根据图片轮廓图,c语言通过opencv实现轮廓处理与切割
c語言通過opencv實現(xiàn)輪廓處理與切割
發(fā)布時間:2020-10-14 11:00:33
來源:腳本之家
閱讀:89
作者:Farmwang
注意在尋找輪廓時要選擇中尋找外層輪廓
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,dst,120,255,1);
vector > edgepoint;
vector lclass;
findContours(dst,edgepoint,lclass,RETR_EXTERNAL,CHAIN_APPROX_NONE,Point());
Mat mat[edgepoint.size()];
for(int i=0;i
{
Rect rec=boundingRect(Mat(edgepoint[i]));
mat[i]=dst(rec);
rectangle(dst,rec,Scalar(100,80,90),1,1,0);
drawContours(dst,edgepoint,i,Scalar(200),1,8,lclass);
string str=to_string(i);
imshow(str,mat[i]);
}
imshow("tt",dst);
cout<
waitKey(0);
}
結(jié)果如下:
總結(jié)
以上就是本文關(guān)于c語言通過opencv實現(xiàn)輪廓處理與切割的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
總結(jié)
以上是生活随笔為你收集整理的c语言根据图片轮廓图,c语言通过opencv实现轮廓处理与切割的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mesh 协调器 路由器_关于Mesh网
- 下一篇: python变量类型是动态的_【Pyth