To check whether an image is blurred or not in Android, selecting image via Gallery
To check whether an image is blurred or not in Android. Image should be selected from Gallery.
OpenCV library is used for Blur detection.
Download OpenCV by selecting a stable version of Android pack from here. Integrating OpenCV to studio-project is quite a long procedure. Please refer this awesome article.
If the sharpness of image is lesser than this value, then that image is marked as blurred.
Blurred Image | Not Blurred Image |
---|---|
APK size is the main concern when we want to integrate with OpenCV.
splits {
abi {
enable true
reset()
include "armeabi-v7a","x86"
universalApk true
}
}
ext.versionCodes = ['armeabi-v7a': 4, 'x86': 5]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def abiFilter = output.getFilter(OutputFile.ABI)
def abiMultiplier = 0
if (abiFilter != null) {
abiMultiplier = project.ext.versionCodes.get(abiFilter)
}
output.versionCodeOverride = abiMultiplier * 1000 + android.defaultConfig.versionCode
}
}
Problem with this approach is we have to upload all the apks separately for google play console, including univeral apk. Credits
Threshold is a critical parameter to verify the blurriness of image.
It all depends on the dataset of images. Currently we are keeping it as 500.
According to stats, armv7 is the most commonly used android architectures.