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)。 –