Android : Blur Image detection with OpenCV results into heavy APK size
I am working on one android app where I need to detect whether the image is blur. I implemented OpenCV with following Code:
private void opencvProcess() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = true;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap image = decodeSampledBitmapFromFile(imageurl, 2000, 2000);
int l = CvType.CV_8UC1; //8-bit grey scale image
Mat matImage = new Mat();
Utils.bitmapToMat(image, matImage);
Mat matImageGrey = new Mat();
Imgproc.cvtColor(matImage, matImageGrey, Imgproc.COLOR_BGR2GRAY);
Bitmap destImage;
destImage = Bitmap.createBitmap(image);
Mat dst2 = new Mat();
Utils.bitmapToMat(destImage, dst2);
Mat laplacianImage = new Mat();
dst2.convertTo(laplacianImage, l);
Imgproc.Laplacian(matImageGrey, laplacianImage, CvType.CV_8U);
Mat laplacianImage8bit = new Mat();
laplacianImage.convertTo(laplacianImage8bit, l);
Bitmap bmp = Bitmap.createBitmap(laplacianImage8bit.cols(), laplacianImage8bit.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(laplacianImage8bit, bmp);
int[] pixels = new int[bmp.getHeight() * bmp.getWidth()];
bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
int maxLap = -16777216; // 16m
for (int pixel : pixels) {
if (pixel > maxLap)
maxLap = pixel;
}
int soglia = -6118750;
if (maxLap <= soglia) {
System.out.println("is blur image");
Toast.makeText(Document_upload.this, "Blur Image", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(Document_upload.this, "Clear Image", Toast.LENGTH_LONG).show();
}
}
Though it works nicely, it resulted into heavy app size, almost 8 MB increased. I am using opencv3.0 sdk and all unused files as per my knowledge have been removed. Can anyone help me with some guidelines for reducing apk size.