Я реализую сканер именных карт с Android, OpenCV. Тем не менее, он показывает несколько областей, как показано на рисунке ниже. Не могли бы вы дать мне совет, чтобы избежать этого? ![enter image description here](https://i.stack.imgur.com/otBaC.jpg)
Я также добавляю код из моего метода onCameraFrame.
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
Mat gray = inputFrame.gray();
Mat dst = inputFrame.rgba();
Imgproc.Canny(gray, bwIMG, 0, threshold);
Imgproc.dilate(bwIMG, bwIMG, new Mat(), new Point(-1, 1), 1);
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
cIMG = bwIMG.clone();
Imgproc.findContours(cIMG, contours, hovIMG, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
double maxVal=0;
MatOfPoint maxContour=new MatOfPoint();
MatOfPoint2f maxContour_ =new MatOfPoint2f();
int numberVertices=0;
for (MatOfPoint cnt : contours) {
MatOfPoint2f curve = new MatOfPoint2f(cnt.toArray());
Imgproc.approxPolyDP(curve, approxCurve, 0.02 * Imgproc.arcLength(curve, true), true);
double contourArea = Imgproc.contourArea(approxCurve);
MatOfPoint approxCurve_ = new MatOfPoint();
if (maxArea< contourArea) {
maxArea = contourArea;
approxCurve.convertTo(approxCurve_, CvType.CV_32S);
maxContour = approxCurve_;
Rect r = Imgproc.boundingRect(maxContour);
Point left = new Point(r.x, r.y);
Point right = new Point(r.x+r.width, r.y);
Point up = new Point(r.x, r.y+r.height);
Point down = new Point(r.x+r.width, r.y+r.height);
Imgproc.circle(dst,left,10,new Scalar(255,0,0),50);
Imgproc.circle(dst,right,10,new Scalar(255,0,0),50);
Imgproc.circle(dst,up,10,new Scalar(255,0,0),50);
Imgproc.circle(dst,down,10,new Scalar(255,0,0),50);
maxArea = 10000;
}
}
return dst;
}