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?