Ask Your Question
0

Android : Blur Image detection with OpenCV results into heavy APK size

asked 2016-11-10 07:10:17 -0600

ravina gravatar image

updated 2016-11-11 01:27:53 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-20 22:54:01 -0600

Split apk's according to architectures that are being supported.

Please refer this

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-11-10 07:08:56 -0600

Seen: 2,831 times

Last updated: Nov 11 '16