以下是使用OpenCV4Android
在Android应用中检测到的蓝色斑点图像。我用Core.inRange()
和Imgproc.findContours()
方法来查找轮廓,并Imgproc.drawContours()
绘制这些:使用OpenCV,如何绘制轮廓内部检测到的形状/斑点的边缘?
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);
}
轮廓(浅绿色边界)是检测到的形状之外。
因此,正如您所看到的,它还包含检测到的蓝色斑点周围的一些白色区域。我希望轮廓边界位于蓝色斑点/形状的边缘内。
我该怎么做?