I am using CameraX for capturing images then feeding into mlkit scanner to scan barcodes, I have created a crop rect and applied to the media.image but it doesn't seem cropping the frame...
@androidx.camera.core.ExperimentalGetImage
override fun analyze(imageProxy: ImageProxy) {
imageProxy.image ?. let {
val rotationDegrees = imageProxy.imageInfo.rotationDegrees
val imageHeight = it.height
val imageWidth = it.width
val cropRect = Rect(0, 0, imageWidth, imageHeight)
cropRect.inset(
(imageWidth/ 2),
(imageHeight/ 2)
)
it.cropRect = cropRect
val image = InputImage.fromMediaImage(it, imageProxy.imageInfo.rotationDegrees)
}
}
I tried saving the media.Image fed to scanner to a bitmap and that is not cropped too.. Let me know what I am doing wrong.
I checked this answer but it is explaining with bitmaps and I am working with media.Image