OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 2529|回复: 1

新手求教怎样获得轮廓的坐标

[复制链接]
发表于 2016-6-2 15:46:44 | 显示全部楼层 |阅读模式
本帖最后由 aaaakaaaa 于 2016-6-2 15:48 编辑

            List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
            List<MatOfPoint> matchedContours = new ArrayList<MatOfPoint>();
            Mat hierarchy = new Mat();
            Imgproc.findContours(erMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);//提取轮廓

            for(MatOfPoint contour : contours){                    
                double actualArea = Imgproc.contourArea(contour);//轮廓包含区域大小  
                double xx,yy;//坐标
                if (actualArea>maxarea) //获取最大区域
                {  
                    maxarea = actualArea;  
                    matchedContours.add(contour);                     
                    xx=?;
                    yy=?;
                    continue;                  
                 }      

            }
            Imgproc.drawContours(rgbMat, matchedContours, -1, new Scalar(0,255,0));//画轮廓
回复

使用道具 举报

发表于 2016-6-19 17:03:49 | 显示全部楼层
点坐标都在MatOfPoint里啊,这个Mat每个元素都是一个point,含x和y分量,具体可以查看相关源码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-16 22:17 , Processed in 0.008329 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表