注意在寻找轮廓时要选择中寻找外层轮廓
?
1
|
RETR_EXTERNAL
|
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#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<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,1,0);
drawContours(dst,edgepoint,i,Scalar(200),1,8,lclass);
string str=to_string(i);
imshow(str,mat[i]);
}
imshow( "tt" ,dst);
cout<<edgepoint.size()<<endl;
waitKey(0);
}
|
结果如下:
总结
以上就是本文关于c语言通过opencv实现轮廓处理与切割的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站其他相关专题,如有不足之处,欢迎留言指出。感谢朋友们对本站的支持!
相关文章
猜你喜欢
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
- 64M VPS建站:能否支持高流量网站运行? 2025-06-10
- 64M VPS建站:怎样选择合适的域名和SSL证书? 2025-06-10
- 64M VPS建站:怎样优化以提高网站加载速度? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-26 77
-
2025-05-29 50
-
2025-05-27 52
-
2025-05-29 39
-
2025-06-04 96
热门评论