Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

omr in java or c++ ?

image description

Please help me to detect the mark of this paper? anyone please

omr in java or c++ ?

image description

Please help me to detect the mark of improve this paper? code for wrapping? anyone please

This is my code for wrapping this image

Mat img = Imgcodecs.imread(getImg().getPath()); if (img.empty()) { Log.e("FragmentMain", "Empty Image"); } Mat gray = new Mat(); Mat blurred = new Mat(); Mat edged = new Mat(); Imgproc.cvtColor(img, gray, Imgproc.COLOR_BGR2GRAY); Imgproc.GaussianBlur(gray, blurred, new Size(5, 5), 0); Imgproc.Canny(blurred, edged, 75, 200);

    Mat clone = edged.clone();
    Mat hierarchy= new Mat();
    List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Imgproc.findContours(clone, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
    List<Point> curves = new ArrayList<>();
    hierarchy.release();
    Mat corners = new Mat(4, 1,

omr in java or c++ ?

image description

Please help me to improve this code for wrapping? anyone please

This is my code for wrapping this image .

       Mat gray = new Mat();
            Mat blurred = new Mat();
            Mat edged = new Mat();
           Mat img = Imgcodecs.imread(getImg().getPath());
         if (img.empty()) {
             Log.e("FragmentMain", "Empty Image");
         }
        Mat gray = new Mat();
        Mat blurred = new Mat();
        Mat edged = new Mat();
        Imgproc.cvtColor(img, gray, Imgproc.COLOR_BGR2GRAY);
        Imgproc.GaussianBlur(gray, blurred, new Size(5, 5), 0);
        Imgproc.Canny(blurred, edged, 75, 200);

200);
            Mat clone = edged.clone();
     Mat hierarchy= new Mat();
     List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
     Imgproc.findContours(clone, contours, hierarchy, Imgproc.RETR_EXTERNAL,  Imgproc.CHAIN_APPROX_SIMPLE);
     List<Point> curves = new ArrayList<>();
     hierarchy.release();
     Mat corners = new Mat(4, 1,
1, CvType.CV_32FC2);
            for (int idx = 0; idx < contours.size(); idx++) {
                MatOfPoint contour = contours.get(idx);
                MatOfPoint2f contour_points = new MatOfPoint2f(contour.toArray());
                RotatedRect minRect = Imgproc.minAreaRect(contour_points);
                Point[] rect_points = new Point[4];
                minRect.points(rect_points);
                if (minRect.size.height > img.width() / 2) {
                    List<Point> srcPoints = new ArrayList<Point>(4);
           srcPoints.add(rect_points[1]);
                    srcPoints.add(rect_points[2]);
                    srcPoints.add(rect_points[3]);
                    srcPoints.add(rect_points[0]);

                    corners = Converters.vector_Point_to_Mat(
                            srcPoints, CvType.CV_32F);
                }

            }
 Mat results = new Mat();
        List<Point> dstPoints = new ArrayList<Point>(4);
        dstPoints.add(new Point(0, 0));
        dstPoints.add(new Point(1000, 0));
        dstPoints.add(new Point(1000, 1920));
        dstPoints.add(new Point(0, 1920));
        Mat quad_pts = Converters.vector_Point_to_Mat(
                dstPoints, CvType.CV_32F);
        Mat transmtx = Imgproc.getPerspectiveTransform(corners, quad_pts);
        Imgproc.warpPerspective(img, results, transmtx, new Size(1000, 1920));

        Imgcodecs.imwrite("results.png", results);
        showImage(results);