The Mlkit barcode scanning library has an issue with scanning Code 39 barcodes. So I have to replace it with the zxing library that seems to have no issues.
However CameraX is giving me back an ImageProxy object, and the zxing MultiFormatReader accepts a BinaryBitmap object.
I'm having trouble converting from one to the other, and it's giving me an index out of bounds exception. Here's my code:
private fun createBinaryBitmap(imageProxy: ImageProxy): BinaryBitmap {
val data = ImageUtil.yuvImageToJpegByteArray(imageProxy, imageProxy.cropRect, 100)
val source = PlanarYUVLuminanceSource(
data,
imageProxy.width,
imageProxy.height,
0,
0,
imageProxy.width,
imageProxy.height,
false
)
return BinaryBitmap(HybridBinarizer(source))
}
I've looked at other places and questions, but I honestly can't find the right approach.