1

I am using OpenCV on android to manipulate bitmap and I get out of memory error when I want to manipulate with the original, not scale image, e.g. 1500 x 2048 resolution. When I scale the image, then everything is ok, but I need to operate with original image, because the quality of image is for me very important. This happens when I want to convert Mat to bitmap using that code:

private Bitmap convertMatToBitmap(Mat image) {
    Bitmap bitmap = null;

    try {
        bitmap = Bitmap.createBitmap(image.width(), image.height(), Config.ARGB_8888);

        org.opencv.android.Utils.matToBitmap(image, bitmap);
    } catch (OutOfMemoryError e) {
        Log.e(TAG, "Out of memory exception in convertMatToBitmap: " + e.getMessage());
    } catch(Exception e) {
        Log.e(TAG, "convertMatToBitmap throws an exception: " + e.getMessage());
    }

    return bitmap;
}

Has someony an idea how should I do it?

Bartosz Bialecki
  • 4,391
  • 10
  • 42
  • 64
  • 1
    i think this error because your bitmap has a large size see this [post](http://stackoverflow.com/questions/2928002/outofmemoryerror-bitmap-size-exceeds-vm-budget-android) – HforHisham Dec 13 '12 at 17:05
  • Also check http://stackoverflow.com/a/823966/1085483 and http://stackoverflow.com/q/3956702/1085483. – Rui Marques Dec 14 '12 at 23:46

0 Answers0