c# opencv 轮廓检测_opencv再学习之路(八)---轮廓检测

1.  例程

1 //轮廓寻找

2

3 #include "stdafx.h"

4 #include

5 #include

6 #include

7 #include

8 #include

9 #include

10 #include

11

12 using namespacestd;13 using namespacecv;14

15

16 voidmain()17 {18

19 Mat image = imread("03.jpg");20

21 Mat gray;22 cvtColor( image, gray, CV_RGB2GRAY);23

24 Mat binary;25 threshold( gray, binary, 150, 255, CV_THRESH_BINARY_INV);26

27 vector>contours;28 Mat binary_copy;29 binary.copyTo(binary_copy);30 findContours( binary_copy, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //CV_RETR_EXTERNAL 获取外轮廓 CV_CHAIN_APPROX_NONE 获取每个轮廓的像素31

32 //遍历每一个轮廓,把多余的轮廓去掉

33 vector>::iterator it =contours.begin();34 while (it !=contours.end())35 {36 if (it->size() < 500)37 {38 it =contours.erase(it);39 }40 else</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值