【发布时间】:2017-11-29 17:31:04
【问题描述】:
以下是使用 OpenCV4Android 在 Android 应用中检测到的蓝色斑点的图像。我使用Core.inRange() 和Imgproc.findContours() 方法找到轮廓,并使用Imgproc.drawContours() 绘制它们:
Mat mask = new Mat();
Core.inRange(rgbaMat, lowerThreshold, upperThreshold, mask);
...
contours = new ArrayList<>();
Imgproc.findContours(dilatedMat, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
...
for ( int contourIdx=0; contourIdx < contours.size(); contourIdx++ ) {
Imgproc.drawContours ( rgbaMat, contours, contourIdx, new Scalar(0, 255, 0), 1);
}
轮廓(浅绿色边界)在检测到的形状之外。
因此,如您所见,它还包括检测到的蓝色斑点周围的一些白色区域。我希望轮廓边界位于蓝色斑点/形状的边缘内。
我该怎么做?
【问题讨论】:
标签: android opencv opencv3.0 opencv4android