Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Find rectangle from image in android?

hello,

i want to find rectangle from below image

C:\fakepath\sample3_blue_answers-compressor (1).png

how to find those four border rectangle from this image?

Thanks in advance

Find rectangle from image in android?

hello,

i want to find rectangle from below image

C:\fakepath\sample3_blue_answers-compressor (1).png image description

how to find those four border rectangle from this image?

Thanks in advance

Find rectangle from image in android?

hello,

i want to find rectangle from below image

image description

how to find those four border rectangle from this image?

Thanks in advance

Find rectangle from image in android?

hello,

i want to find rectangle from below image

image descriptionimage description

how to find those four border rectangle from this image?

Thanks in advance

Find rectangle from image in android?

hello,

i want to find rectangle from below image

image description

how to find those four border rectangle from this image?

i have tried with this code

Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

        Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1));
        Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2);
        Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY);
        Core.bitwise_not(grayMat, grayMat);

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        List<Point> pointList=new ArrayList<Point>();
        for(int i=0; i<contours.size(); i++)
        {
            Rect rect = Imgproc.boundingRect(contours.get(i));
            double k = (rect.height+0.0)/rect.width;
            if (0.9<k && k<1.1 && rect.area() > 100)
            {
                Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3);
            }
        }

        resultBitmap = ImageUtils.matToBitmap(rgbMat);

Thanks in advance

Find rectangle from image in android?

hello,

i want to find four black cornered rectangle from below image

image description

how to find those four border rectangle from this image?

i have tried with this code

Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

        Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1));
        Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2);
        Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY);
        Core.bitwise_not(grayMat, grayMat);

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        List<Point> pointList=new ArrayList<Point>();
        for(int i=0; i<contours.size(); i++)
        {
            Rect rect = Imgproc.boundingRect(contours.get(i));
            double k = (rect.height+0.0)/rect.width;
            if (0.9<k && k<1.1 && rect.area() > 100)
            {
                Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3);
            }
        }

        resultBitmap = ImageUtils.matToBitmap(rgbMat);

Thanks in advance

Find rectangle from image in android?

hello,

i want to find four black cornered rectangle from below image

image description

how to find those four border rectangle from this image?

i have tried with this code

Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

        Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1));
        Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2);
        Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY);
        Core.bitwise_not(grayMat, grayMat);

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        List<Point> pointList=new ArrayList<Point>();
        for(int i=0; i<contours.size(); i++)
        {
            Rect rect = Imgproc.boundingRect(contours.get(i));
            double k = (rect.height+0.0)/rect.width;
            if (0.9<k && k<1.1 && rect.area() > 100)
            {
                Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3);
            }
        }

        resultBitmap = ImageUtils.matToBitmap(rgbMat);

Please help me ..

Thanks in advance

Find rectangle from image in android?

hello,

i want to find four black cornered rectangle from below image

image descriptionimage description

how to find those four border rectangle from this image?

i have tried with this code

Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

 Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

        Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1));
        Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2);
        Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY);
        Core.bitwise_not(grayMat, grayMat);

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        List<Point> pointList=new ArrayList<Point>();
        for(int i=0; i<contours.size(); i++)
        {
            Rect rect = Imgproc.boundingRect(contours.get(i));
            double k = (rect.height+0.0)/rect.width;
            if (0.9<k && k<1.1 && rect.area() > 100)
            {
                Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3);
            }
        }

        resultBitmap = ImageUtils.matToBitmap(rgbMat);

Please help me ..

Thanks in advance

Find rectangle from image in android?

hello,

i want to find four black cornered rectangle from below image

image description

how to find those four border rectangle from this image?

i have tried with this code

 Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap);

        Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1));
        Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2);
        Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY);
        Core.bitwise_not(grayMat, grayMat);

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        List<Point> pointList=new ArrayList<Point>();
        for(int i=0; i<contours.size(); i++)
        {
            Rect rect = Imgproc.boundingRect(contours.get(i));
            double k = (rect.height+0.0)/rect.width;
            if (0.9<k && k<1.1 && rect.area() > 100)
            {
                Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3);
            }
        }

        resultBitmap = ImageUtils.matToBitmap(rgbMat);

Please help me ..

Thanks in advance