Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to crop all the rectangles as bitmap and store those ?

you can use submat() like this:

if ((rect.height > 30 && rect.height < 120) && (rect.width > 120 && rect.width < 500))
{
     Rect rec = new Rect(rect.x, rect.y, rect.width, rect.height);
     Mat roi = imageMat.submat(rec);
     String filename = ???
     Imgcodecs.imwrite(filename, roi);
}

How to crop all the rectangles as bitmap and store those ?

you can use submat() like this:

if ((rect.height > 30 && rect.height < 120) && (rect.width > 120 && rect.width < 500))
{
     Rect rec = new Rect(rect.x, rect.y, rect.width, rect.height);
     Mat roi = imageMat.submat(rec);
     String filename = Environment.getExternalStorageDirectory() + ???
     Imgcodecs.imwrite(filename, roi);
}

How to crop all the rectangles as bitmap and store those ?

you can use submat() like this:

if ((rect.height > 30 && rect.height < 120) && (rect.width > 120 && rect.width < 500))
{
     Rect rec = new Rect(rect.x, rect.y, rect.width, rect.height);
     Mat roi = imageMat.submat(rec);
     String filename = Environment.getExternalStorageDirectory() + ???
??? + ".png";
     Imgcodecs.imwrite(filename, roi);
roi); // no need for bitmap conversion here.
}