public void Process(Mat rgbaImage) { Log.Info(TAG, "Process rgbaImages"); Imgproc.PyrDown(rgbaImage, mPyrDownMat); Imgproc.PyrDown(mPyrDownMat, mPyrDownMat); Imgproc.CvtColor(mPyrDownMat, mHsvMat, Imgproc.ColorRgb2hsvFull); Core.InRange(mHsvMat, mLowerBound, mUpperBound, mMask); Imgproc.Dilate(mMask, mDilatedMask, new Mat()); IList <MatOfPoint> contours = new JavaList <MatOfPoint>(); Imgproc.FindContours(mDilatedMask, contours, mHierarchy, Imgproc.RetrExternal, Imgproc.ChainApproxSimple); // Find max contour area double maxArea = 0; foreach (var each in contours) { MatOfPoint wrapper = each; double area = Imgproc.ContourArea(wrapper); if (area > maxArea) { maxArea = area; } Log.Info(TAG, "Process rgbaImages\t-- Imgproc.ContourArea(wrapper)"); } // Filter contours by area and resize to fit the original image size mContours.Clear(); foreach (var each in contours) { MatOfPoint contour = each; if (Imgproc.ContourArea(contour) > mMinContourArea * maxArea) { Core.Multiply(contour, new Scalar(4, 4), contour); mContours.Add(contour); Log.Info(TAG, "Process rgbaImages\t-- mContours.Add(contour)"); } } }