|
本帖最后由 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));//画轮廓
|
|