0
我正在开发使用opencv
库的OMR
scanner android应用程序。 我已经在表格中检测到我的圆圈作为轮廓,现在我想从所有获得的轮廓中获得实心圆轮廓 由于java对opencv的支持非常少,我无法弄清楚任何东西,因此请为其提供一些方法。如何计算轮廓内的非零像素opencv
//paramview is my image
Utils.bitmapToMat(paramView, localMat1);
Mat localMat2 = new Mat();
double[] lo;
Imgproc.GaussianBlur(localMat1, localMat2, new Size(5.0D, 5.0D), 7.0D, 6.5D);
Object localObject = new Mat();
Imgproc.cvtColor(localMat2, (Mat)localObject, COLOR_RGB2GRAY);
Mat cloneMat= ((Mat) localObject).clone();
localMat2 = localMat1.clone();
bitwise_not(cloneMat,cloneMat);
Imgproc.threshold(cloneMat,localMat2,127,255,Imgproc.THRESH_OTSU);
Mat thresh=localMat2.clone();
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
List<MatOfPoint> questions = new ArrayList<MatOfPoint>();
List<MatOfPoint> sorted = new ArrayList<MatOfPoint>();
//All contours detected
Mat hierarchy = new Mat();
Imgproc.findContours(localMat2, contours, hierarchy,
Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
Image of Detected circles here
你可以添加你的代码来找到圈子的轮廓。此外,添加您当前的图像输出和所需的结果。最后,请查看[帮助中心](https://stackoverflow.com/help/mcve)。 –