I'm trying to create an app with a TensorFlow Lite model for recognising handwritten digits. I created a simple canvas for the user to draw on, which returns the Bitmap for whatever the user has drawn. The initial size of the bitmap is 523 x 1024 which I'm trying to scale down to 28 x 28 to pass in as an input to my model. However, the scaled-down image is almost to the point of unrecognizable.
I even tried to rescale the bitmap with https://stackoverflow.com/a/7468636/6712486 but to no avail. Attaching screenshots for reference Scaled Down Image. Uncompressed Image
Any insight would be greatly appreciated. Thanks
fun classify(bitmap: Bitmap) {
check(isInterpreterInitialized) {"TFLite interpreter is not initialised"}
val resizedImage = Bitmap.createScaledBitmap(bitmap, inputImageWidth, inputImageHeight, true)
val bitmapByteBuffer = resizedImage?.toByteBuffer()
getCompressedBitmap(bitmap)
bitmapByteBuffer?.let {
interpreter?.run(it, resultArray)
}
}