1

I am trying to implement a Barcode scanner by using the Google ML Kit latest SDK and passing captured barcode bitmap image inside the below method. However, the ML kit keeps throwing errors like below. Does anyone have a solution to resolve this error?

StreamingFormatChecker: ML Kit has detected that you seem to pass camera frames to the detector as a Bitmap object. This is inefficient. Please use YUV_420_888 format for camera2 API or NV21 format for (legacy) camera API and directly pass down the byte array to ML Kit.

val image = InputImage.fromBitmap(bitmap, 0)

implementation 'com.google.mlkit:barcode-scanning:16.2.0'

Following this doc: https://developers.google.com/ml-kit/vision/barcode-scanning/android

I am passing below cropped bitmap image to ML Kit for the process.

enter image description here

Faldu Jaldeep
  • 545
  • 2
  • 15
  • This is actually warning rather error to remind you that you use Bitmap format in the live camera scenario. It won't prevent you from using this feature, but might indicate a non ideal input processing at your side. May I know why do you use Bitmap instead of YUV_420_888 or NV21 format? For image cropping? – zhouyi Jul 20 '21 at 18:31
  • 1
    @zhouyi Bitmap should work, right? Currently, it's not working properly and taking too much time to process. And they have already mentioned ML Kit support bitmap as well. Do you know how to convert color bitmap to NV21 or YUV_420_888 format byte array? – Faldu Jaldeep Jul 21 '21 at 04:04
  • Bitmap could work but may not be very suitable for live camera case. How do you get your input? Via camera or something else? – zhouyi Jul 24 '21 at 23:06
  • @zhouyi Yes, I am using a live camera preview. – Faldu Jaldeep Jul 26 '21 at 10:56
  • If that, shouldn'y you be able to get input in NV21 (camera1) or YUV_420_888 (camera2 & cameraX) format already? – zhouyi Jul 28 '21 at 00:51

0 Answers0