질문 1 : 무엇을 시도 했습니까? 저는 문서 인식 및 원근 보정 기능을 갖춘 문서 스캐너 응용 프로그램을 만들고 있습니다. 이를 위해 저는 OpenCV를 사용하고 있습니다. 다음 단계는 다음과 같습니다OpenCV로 최대 윤곽 검출
는- 는 크기 조정 이미지
Bitmap bitmap = CameraImageUtils.decodeSampledBitmapFromResource(data[0], CameraConfigurationUtils.MIN_FRAME_WIDTH, CameraConfigurationUtils.MIN_FRAME_HEIGHT);
캐니 에지 검출
Mat srcMat = new Mat(height, width, CvType.CV_8UC3); Utils.bitmapToMat(sourceBitmap, srcMat); Mat imgSource = new Mat(srcMat.size(), CvType.CV_8UC1); Imgproc.cvtColor(srcMat, imgSource, Imgproc.COLOR_RGB2GRAY, 4); Imgproc.GaussianBlur(imgSource, imgSource, new org.opencv.core.Size(5, 5), 5); Imgproc.Canny(imgSource, imgSource, 50, 50); //find the contours List<MatOfPoint> contours = new ArrayList<>(); Imgproc.findContours(imgSource, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); double maxArea = -1; int maxAreaIdx = -1; Log.d("size", Integer.toString(contours.size())); MatOfPoint temp_contour = contours.get(0); //the largest is at the index 0 for starting point MatOfPoint2f approxCurve = new MatOfPoint2f(); MatOfPoint largest_contour = contours.get(0); for (int idx = 0; idx < contours.size(); idx++) { temp_contour = contours.get(idx); double contourarea = Imgproc.contourArea(temp_contour); //compare this contour to the previous largest contour found if (contourarea > maxArea) { //check if this contour is a square MatOfPoint2f new_mat = new MatOfPoint2f(temp_contour.toArray()); int contourSize = (int) temp_contour.total(); MatOfPoint2f approxCurve_temp = new MatOfPoint2f(); Imgproc.approxPolyDP(new_mat, approxCurve_temp, contourSize * 0.05, true); if (approxCurve_temp.total() == 4) { maxArea = contourarea; maxAreaIdx = idx; approxCurve = approxCurve_temp; largest_contour = temp_contour; } } }
문제는 무엇인가 신청을 문서
여기서 내가 뭘 잘못하고 있니? 이 응용 프로그램의 주요 목표는 라이브 카메라 미리보기에서 문서를 감지하고 사용자가 사진을 찍을 때 크기가 줄어든 (< 160kb) 문서 만 표시하고 그림을 업로드합니다.
질문 2 : OpenCv 용 정적 초기화 프로그램을 사용하여 응용 프로그램 크기를 늘리고 싶지 않습니다. OpenCV를위한 대안이 있습니까?