Android पर एमएल किट से बारकोड स्कैन करें

एमएल किट का इस्तेमाल, बारकोड को पहचानने और डिकोड करने के लिए किया जा सकता है.

सुविधाबंडल न किए गएबंडल किए गए
लागू करने का तरीकामॉडल को Google Play services की मदद से डाइनैमिक तौर पर डाउनलोड किया जाता है.बिल्ड के समय, मॉडल को आपके ऐप्लिकेशन से स्टैटिक रूप से लिंक किया जाता है.
ऐप्लिकेशन का साइज़करीब 200 केबी का साइज़ बढ़ाया जाता है.साइज़ करीब 2.4 एमबी बढ़ गया.
शुरू करने का समयपहली बार इस्तेमाल करने से पहले मॉडल के डाउनलोड होने का इंतज़ार करना पड़ सकता है.मॉडल तुरंत उपलब्ध है.

इसे आज़माएं

शुरू करने से पहले

  1. प्रोजेक्ट-लेवल की build.gradle फ़ाइल में, अपने buildscript और allprojects, दोनों सेक्शन में Google की Maven रिपॉज़िटरी को शामिल करना न भूलें.

  2. अपने मॉड्यूल की ऐप्लिकेशन-लेवल की ग्रेडल फ़ाइल में, ML Kit Android लाइब्रेरी के लिए डिपेंडेंसी जोड़ें. आम तौर पर, यह app/build.gradle होती है. अपनी ज़रूरत के हिसाब से, इनमें से कोई एक डिपेंडेंसी चुनें:

    अपने ऐप्लिकेशन के साथ मॉडल को बंडल करने के लिए:

    dependencies {
      // ...
      // Use this dependency to bundle the model with your app
      implementation 'com.google.mlkit:barcode-scanning:17.2.0'
    }
    

    Google Play Services में मॉडल इस्तेमाल करने के लिए:

    dependencies {
      // ...
      // Use this dependency to use the dynamically downloaded model in Google Play Services
      implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:18.3.0'
    }
    
  3. अगर इस मॉडल को Google Play Services में इस्तेमाल किया जाता है, तो अपने ऐप्लिकेशन को इस तरह कॉन्फ़िगर किया जा सकता है कि Play Store से ऐप्लिकेशन इंस्टॉल होने के बाद, मॉडल आपके डिवाइस पर अपने-आप डाउनलोड हो जाए. ऐसा करने के लिए, अपने ऐप्लिकेशन की AndroidManifest.xml फ़ाइल में यह एलान जोड़ें:

    <application ...>
          ...
          <meta-data
              android:name="com.google.mlkit.vision.DEPENDENCIES"
              android:value="barcode" >
          <!-- To use multiple models: android:value="barcode,model2,model3" -->
    </application>
    

    इसके अलावा, मॉडल की उपलब्धता की जानकारी भी देखी जा सकती है. साथ ही, Google Play services के ModuleInstallClient API की मदद से, मॉडल को डाउनलोड करने का अनुरोध किया जा सकता है.

    अगर इंस्टॉल के समय मॉडल डाउनलोड करने की सुविधा चालू नहीं की जाती है या अश्लील कॉन्टेंट डाउनलोड करने का अनुरोध नहीं किया जाता है, तो पहली बार स्कैनर चलाने पर मॉडल को डाउनलोड किया जाएगा. डाउनलोड पूरा होने से पहले किए गए अनुरोधों का कोई नतीजा नहीं मिलता.

इनपुट इमेज के लिए दिशा-निर्देश

  • एमएल किट, बारकोड को सही तरीके से पढ़ने के लिए, इनपुट इमेज में ऐसे बारकोड शामिल होने चाहिए जिन्हें ज़रूरत के मुताबिक पिक्सल डेटा के तौर पर दिखाया गया हो.

    पिक्सल के डेटा से जुड़ी ज़रूरी शर्तें, बारकोड के टाइप और उनमें कोड में बदले गए डेटा की मात्रा, दोनों पर निर्भर करती हैं, क्योंकि कई बारकोड, वैरिएबल साइज़ वाले पेलोड के साथ काम करते हैं. आम तौर पर, बारकोड की सबसे छोटी इकाई, कम से कम 2 पिक्सल चौड़ी होनी चाहिए. साथ ही, 2-डाइमेंशन वाले कोड के लिए, उसकी लंबाई 2 पिक्सल होनी चाहिए.

    उदाहरण के लिए, EAN-13 बारकोड में बार और एक या चार इकाई चौड़ी खाली जगह होती है. इसलिए, EAN-13 बारकोड इमेज में बार और खाली जगह होती है, जिसकी चौड़ाई कम से कम 2, 4, 6, और 8 पिक्सल होती है. EAN-13 बारकोड की कुल चौड़ाई 95 यूनिट होती है. इसलिए, बारकोड कम से कम 190 पिक्सल चौड़ा होना चाहिए.

    PDF417 जैसे डेंसर फ़ॉर्मैट में, एमएल किट के लिए ज़्यादा पिक्सल डाइमेंशन की ज़रूरत होती है, ताकि वे सही तरीके से पढ़े जा सकें. उदाहरण के लिए, PDF417 कोड की एक पंक्ति में ज़्यादा से ज़्यादा 34 17 यूनिट चौड़ी "शब्द" हो सकते हैं, जो आम तौर पर कम से कम 1156 पिक्सल चौड़ी होती है.

  • खराब इमेज फ़ोकस, स्कैनिंग के सटीक होने पर असर डाल सकता है. अगर आपके ऐप्लिकेशन को सही नतीजे नहीं मिल रहे हैं, तो उपयोगकर्ता से इमेज को फिर से कैप्चर करने के लिए कहें.

  • आम तौर पर इस्तेमाल किए जाने वाले ऐप्लिकेशन के लिए, यह सुझाव दिया जाता है कि ज़्यादा रिज़ॉल्यूशन वाली इमेज दें, जैसे कि 1280x720 या 1920x1080. इससे बारकोड को कैमरे से ज़्यादा दूर से स्कैन किया जा सकता है.

    हालांकि, जिन ऐप्लिकेशन में इंतज़ार का समय बहुत ज़रूरी होता है, वहां कम रिज़ॉल्यूशन वाली इमेज कैप्चर करके परफ़ॉर्मेंस बेहतर बनाई जा सकती है. हालांकि, इनपुट इमेज के ज़्यादातर हिस्से में बारकोड को शामिल करना ज़रूरी है. रीयल-टाइम में परफ़ॉर्मेंस को बेहतर बनाने के बारे में सलाह भी देखें.

1. बारकोड स्कैनर को कॉन्फ़िगर करें

अगर आपको पता है कि आपको बारकोड के कौनसे फ़ॉर्मैट पढ़ने हैं, तो बारकोड डिटेक्टर को सिर्फ़ उन फ़ॉर्मैट का पता लगाने के लिए कॉन्फ़िगर करके, उसकी स्पीड को बेहतर बनाया जा सकता है.

उदाहरण के लिए, सिर्फ़ Aztec कोड और क्यूआर कोड का पता लगाने के लिए, नीचे दिए गए उदाहरण की तरह BarcodeScannerOptions ऑब्जेक्ट बनाएं:

Kotlin

val options = BarcodeScannerOptions.Builder()
        .setBarcodeFormats(
                Barcode.FORMAT_QR_CODE,
                Barcode.FORMAT_AZTEC)
        .build()

Java

BarcodeScannerOptions options =
        new BarcodeScannerOptions.Builder()
        .setBarcodeFormats(
                Barcode.FORMAT_QR_CODE,
                Barcode.FORMAT_AZTEC)
        .build();

ये फ़ॉर्मैट काम करते हैं:

  • कोड 128 (FORMAT_CODE_128)
  • कोड 39 (FORMAT_CODE_39)
  • कोड 93 (FORMAT_CODE_93)
  • कोडाबार (FORMAT_CODABAR)
  • EAN-13 (FORMAT_EAN_13)
  • EAN-8 (FORMAT_EAN_8)
  • आईटीएफ़ (FORMAT_ITF)
  • यूपीसी-ए (FORMAT_UPC_A)
  • यूपीसी-ई (FORMAT_UPC_E)
  • क्यूआर कोड (FORMAT_QR_CODE)
  • PDF417 (FORMAT_PDF417)
  • ऐज़टेक (FORMAT_AZTEC)
  • डेटा मैट्रिक्स (FORMAT_DATA_MATRIX)

बंडल किए गए मॉडल 17.1.0 और बंडल नहीं किए गए मॉडल 18.2.0 से शुरू करते हुए, सभी संभावित बारकोड को लौटाने के लिए enableAllPotentialBarcodes() को भी कॉल किया जा सकता है, भले ही उन्हें डिकोड नहीं किया जा सकता हो. इसका इस्तेमाल, बेहतर तरीके से पता लगाने के लिए किया जा सकता है. उदाहरण के लिए, बाउंडिंग बॉक्स में किसी बारकोड की साफ़ इमेज पाने के लिए कैमरे को ज़ूम इन करके.

Kotlin

val options = BarcodeScannerOptions.Builder()
        .setBarcodeFormats(...)
        .enableAllPotentialBarcodes() // Optional
        .build()

Java

BarcodeScannerOptions options =
        new BarcodeScannerOptions.Builder()
        .setBarcodeFormats(...)
        .enableAllPotentialBarcodes() // Optional
        .build();

Further on, starting from bundled library 17.2.0 and unbundled library 18.3.0, a new feature called auto-zoom has been introduced to further enhance the barcode scanning experience. With this feature enabled, the app is notified when all barcodes within the view are too distant for decoding. As a result, the app can effortlessly adjust the camera's zoom ratio to the recommended setting provided by the library, ensuring optimal focus and readability. This feature will significantly enhance the accuracy and success rate of barcode scanning, making it easier for apps to capture information precisely.

To enable auto-zooming and customize the experience, you can utilize the setZoomSuggestionOptions() method along with your own ZoomCallback handler and desired maximum zoom ratio, as demonstrated in the code below.

Kotlin

val options = BarcodeScannerOptions.Builder()
        .setBarcodeFormats(...)
        .setZoomSuggestionOptions(
            new ZoomSuggestionOptions.Builder(zoomCallback)
                .setMaxSupportedZoomRatio(maxSupportedZoomRatio)
                .build()) // Optional
        .build()

Java

BarcodeScannerOptions options =
        new BarcodeScannerOptions.Builder()
        .setBarcodeFormats(...)
        .setZoomSuggestionOptions(
            new ZoomSuggestionOptions.Builder(zoomCallback)
                .setMaxSupportedZoomRatio(maxSupportedZoomRatio)
                .build()) // Optional
        .build();

zoomCallback is required to be provided to handle whenever the library suggests a zoom should be performed and this callback will always be called on the main thread.

The following code snippet shows an example of defining a simple callback.

Kotlin

fun setZoom(ZoomRatio: Float): Boolean {
    if (camera.isClosed()) return false
    camera.getCameraControl().setZoomRatio(zoomRatio)
    return true
}

Java

boolean setZoom(float zoomRatio) {
    if (camera.isClosed()) {
        return false;
    }
    camera.getCameraControl().setZoomRatio(zoomRatio);
    return true;
}

maxSupportedZoomRatio is related to the camera hardware, and different camera libraries have different ways to fetch it (see the javadoc of the setter method). In case this is not provided, an unbounded zoom ratio might be produced by the library which might not be supported. Refer to the setMaxSupportedZoomRatio() method introduction to see how to get the max supported zoom ratio with different Camera libraries.

When auto-zooming is enabled and no barcodes are successfully decoded within the view, BarcodeScanner triggers your zoomCallback with the requested zoomRatio. If the callback correctly adjusts the camera to this zoomRatio, it is highly probable that the most centered potential barcode will be decoded and returned.

A barcode may remain undecodable even after a successful zoom-in. In such cases, BarcodeScanner may either invoke the callback for another round of zoom-in until the maxSupportedZoomRatio is reached, or provide an empty list (or a list containing potential barcodes that were not decoded, if enableAllPotentialBarcodes() was called) to the OnSuccessListener (which will be defined in step 4. Process the image).

2. Prepare the input image

To recognize barcodes in an image, create an InputImage object from either a Bitmap, media.Image, ByteBuffer, byte array, or a file on the device. Then, pass the InputImage object to the BarcodeScanner's process method.

You can create an InputImage object from different sources, each is explained below.

Using a media.Image

To create an InputImage object from a media.Image object, such as when you capture an image from a device's camera, pass the media.Image object and the image's rotation to InputImage.fromMediaImage().

If you use the CameraX library, the OnImageCapturedListener and ImageAnalysis.Analyzer classes calculate the rotation value for you.

Kotlin

private class YourImageAnalyzer : ImageAnalysis.Analyzer {

    override fun analyze(imageProxy: ImageProxy) {
        val mediaImage = imageProxy.image
        if (mediaImage != null) {
            val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)
            // Pass image to an ML Kit Vision API
            // ...
        }
    }
}

Java

private class YourAnalyzer implements ImageAnalysis.Analyzer {

    @Override
    public void analyze(ImageProxy imageProxy) {
        Image mediaImage = imageProxy.getImage();
        if (mediaImage != null) {
          InputImage image =
                InputImage.fromMediaImage(mediaImage, imageProxy.getImageInfo().getRotationDegrees());
          // Pass image to an ML Kit Vision API
          // ...
        }
    }
}

अगर आपने ऐसी कैमरा लाइब्रेरी का इस्तेमाल नहीं किया है जो इमेज को घुमाने की डिग्री देती है, तो डिवाइस की रोटेशन डिग्री और डिवाइस में कैमरा सेंसर के ओरिएंटेशन की मदद से, इसका हिसाब लगाया जा सकता है:

Kotlin

private val ORIENTATIONS = SparseIntArray()

init {
    ORIENTATIONS.append(Surface.ROTATION_0, 0)
    ORIENTATIONS.append(Surface.ROTATION_90, 90)
    ORIENTATIONS.append(Surface.ROTATION_180, 180)
    ORIENTATIONS.append(Surface.ROTATION_270, 270)
}

/**
 * Get the angle by which an image must be rotated given the device's current
 * orientation.
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Throws(CameraAccessException::class)
private fun getRotationCompensation(cameraId: String, activity: Activity, isFrontFacing: Boolean): Int {
    // Get the device's current rotation relative to its "native" orientation.
    // Then, from the ORIENTATIONS table, look up the angle the image must be
    // rotated to compensate for the device's rotation.
    val deviceRotation = activity.windowManager.defaultDisplay.rotation
    var rotationCompensation = ORIENTATIONS.get(deviceRotation)

    // Get the device's sensor orientation.
    val cameraManager = activity.getSystemService(CAMERA_SERVICE) as CameraManager
    val sensorOrientation = cameraManager
            .getCameraCharacteristics(cameraId)
            .get(CameraCharacteristics.SENSOR_ORIENTATION)!!

    if (isFrontFacing) {
        rotationCompensation = (sensorOrientation + rotationCompensation) % 360
    } else { // back-facing
        rotationCompensation = (sensorOrientation - rotationCompensation + 360) % 360
    }
    return rotationCompensation
}

Java

private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
    ORIENTATIONS.append(Surface.ROTATION_0, 0);
    ORIENTATIONS.append(Surface.ROTATION_90, 90);
    ORIENTATIONS.append(Surface.ROTATION_180, 180);
    ORIENTATIONS.append(Surface.ROTATION_270, 270);
}

/**
 * Get the angle by which an image must be rotated given the device's current
 * orientation.
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private int getRotationCompensation(String cameraId, Activity activity, boolean isFrontFacing)
        throws CameraAccessException {
    // Get the device's current rotation relative to its "native" orientation.
    // Then, from the ORIENTATIONS table, look up the angle the image must be
    // rotated to compensate for the device's rotation.
    int deviceRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int rotationCompensation = ORIENTATIONS.get(deviceRotation);

    // Get the device's sensor orientation.
    CameraManager cameraManager = (CameraManager) activity.getSystemService(CAMERA_SERVICE);
    int sensorOrientation = cameraManager
            .getCameraCharacteristics(cameraId)
            .get(CameraCharacteristics.SENSOR_ORIENTATION);

    if (isFrontFacing) {
        rotationCompensation = (sensorOrientation + rotationCompensation) % 360;
    } else { // back-facing
        rotationCompensation = (sensorOrientation - rotationCompensation + 360) % 360;
    }
    return rotationCompensation;
}

इसके बाद, media.Image ऑब्जेक्ट और रोटेशन डिग्री की वैल्यू को InputImage.fromMediaImage() पर पास करें:

Kotlin

val image = InputImage.fromMediaImage(mediaImage, rotation)

Java

InputImage image = InputImage.fromMediaImage(mediaImage, rotation);

फ़ाइल यूआरआई का इस्तेमाल करना

किसी फ़ाइल यूआरआई से InputImage ऑब्जेक्ट बनाने के लिए, ऐप्लिकेशन कॉन्टेक्स्ट और फ़ाइल यूआरआई को InputImage.fromFilePath() में पास करें. यह तब काम आता है, जब ACTION_GET_CONTENT इंटेंट का इस्तेमाल करके, उपयोगकर्ता से उसके गैलरी ऐप्लिकेशन से कोई इमेज चुनने का अनुरोध किया जाता है.

Kotlin

val image: InputImage
try {
    image = InputImage.fromFilePath(context, uri)
} catch (e: IOException) {
    e.printStackTrace()
}

Java

InputImage image;
try {
    image = InputImage.fromFilePath(context, uri);
} catch (IOException e) {
    e.printStackTrace();
}

ByteBuffer या ByteArray का इस्तेमाल करके

किसी ByteBuffer या ByteArray से InputImage ऑब्जेक्ट बनाने के लिए, सबसे पहले इमेज के रोटेशन डिग्री का हिसाब लगाएं, जैसा कि media.Image इनपुट के लिए पहले बताया गया था. इसके बाद, इमेज की ऊंचाई, चौड़ाई, कलर एन्कोडिंग का फ़ॉर्मैट, और रोटेशन डिग्री के साथ, बफ़र या अरे की मदद से InputImage ऑब्जेक्ट बनाएं:

Kotlin

val image = InputImage.fromByteBuffer(
        byteBuffer,
        /* image width */ 480,
        /* image height */ 360,
        rotationDegrees,
        InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
)
// Or:
val image = InputImage.fromByteArray(
        byteArray,
        /* image width */ 480,
        /* image height */ 360,
        rotationDegrees,
        InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
)

Java

InputImage image = InputImage.fromByteBuffer(byteBuffer,
        /* image width */ 480,
        /* image height */ 360,
        rotationDegrees,
        InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
);
// Or:
InputImage image = InputImage.fromByteArray(
        byteArray,
        /* image width */480,
        /* image height */360,
        rotation,
        InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
);

Bitmap का इस्तेमाल करके

किसी Bitmap ऑब्जेक्ट से InputImage ऑब्जेक्ट बनाने के लिए, यह एलान करें:

Kotlin

val image = InputImage.fromBitmap(bitmap, 0)

Java

InputImage image = InputImage.fromBitmap(bitmap, rotationDegree);

इमेज को रोटेशन डिग्री के साथ, Bitmap ऑब्जेक्ट से दिखाया गया है.

3. BarcodeScanner का इंस्टेंस पाएं

Kotlin

val scanner = BarcodeScanning.getClient()
// Or, to specify the formats to recognize:
// val scanner = BarcodeScanning.getClient(options)

Java

BarcodeScanner scanner = BarcodeScanning.getClient();
// Or, to specify the formats to recognize:
// BarcodeScanner scanner = BarcodeScanning.getClient(options);

4. इमेज को प्रोसेस करें

इमेज को process तरीके से पास करें:

Kotlin

val result = scanner.process(image)
        .addOnSuccessListener { barcodes ->
            // Task completed successfully
            // ...
        }
        .addOnFailureListener {
            // Task failed with an exception
            // ...
        }

Java

Task<List<Barcode>> result = scanner.process(image)
        .addOnSuccessListener(new OnSuccessListener<List<Barcode>>() {
            @Override
            public void onSuccess(List<Barcode> barcodes) {
                // Task completed successfully
                // ...
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                // Task failed with an exception
                // ...
            }
        });

5. बारकोड से जानकारी पाएं

अगर बारकोड की पहचान करने वाली कार्रवाई पूरी हो जाती है, तो सक्सेस लिसनर को Barcode ऑब्जेक्ट की सूची भेज दी जाती है. हर Barcode ऑब्जेक्ट, एक बारकोड दिखाता है, जिसका पता इमेज में लगाया गया था. हर बारकोड के लिए, इनपुट इमेज में उसके बाउंडिंग निर्देशांक के साथ-साथ बारकोड से एन्कोड किया गया रॉ डेटा देखा जा सकता है. साथ ही, अगर बारकोड स्कैनर बारकोड से एन्कोड किए गए डेटा का प्रकार तय कर पाता है, तो आपको पार्स किया गया डेटा वाला ऑब्जेक्ट मिल सकता है.

उदाहरण के लिए:

Kotlin

for (barcode in barcodes) {
    val bounds = barcode.boundingBox
    val corners = barcode.cornerPoints

    val rawValue = barcode.rawValue

    val valueType = barcode.valueType
    // See API reference for complete list of supported types
    when (valueType) {
        Barcode.TYPE_WIFI -> {
            val ssid = barcode.wifi!!.ssid
            val password = barcode.wifi!!.password
            val type = barcode.wifi!!.encryptionType
        }
        Barcode.TYPE_URL -> {
            val title = barcode.url!!.title
            val url = barcode.url!!.url
        }
    }
}

Java

for (Barcode barcode: barcodes) {
    Rect bounds = barcode.getBoundingBox();
    Point[] corners = barcode.getCornerPoints();

    String rawValue = barcode.getRawValue();

    int valueType = barcode.getValueType();
    // See API reference for complete list of supported types
    switch (valueType) {
        case Barcode.TYPE_WIFI:
            String ssid = barcode.getWifi().getSsid();
            String password = barcode.getWifi().getPassword();
            int type = barcode.getWifi().getEncryptionType();
            break;
        case Barcode.TYPE_URL:
            String title = barcode.getUrl().getTitle();
            String url = barcode.getUrl().getUrl();
            break;
    }
}

रीयल-टाइम में परफ़ॉर्मेंस को बेहतर बनाने के लिए सलाह

अगर आपको रीयल-टाइम ऐप्लिकेशन में बारकोड स्कैन करने हैं, तो सही फ़्रेमरेट पाने के लिए, इन दिशा-निर्देशों का पालन करें:

  • इनपुट को कैमरे के नेटिव रिज़ॉल्यूशन पर कैप्चर न करें. कुछ डिवाइसों पर, नेटिव रिज़ॉल्यूशन पर इनपुट कैप्चर करने पर, बहुत बड़ी (10 से ज़्यादा मेगापिक्सल) इमेज बनती हैं. इस वजह से, इमेज के लोड होने के इंतज़ार में बहुत कम समय लगता है और उन्हें सटीक तरीके से दिखाने में कोई फ़ायदा नहीं होता. इसके बजाय, कैमरे से सिर्फ़ उसी साइज़ का अनुरोध करें जो बारकोड का पता लगाने के लिए ज़रूरी है. आम तौर पर, यह साइज़ 2 मेगापिक्सल से ज़्यादा नहीं होता.

    अगर स्कैन करने की स्पीड ज़रूरी है, तो इमेज कैप्चर करने के रिज़ॉल्यूशन को और कम किया जा सकता है. हालांकि, बारकोड के साइज़ के लिए ऊपर बताई गई शर्तों को ध्यान में रखें.

    अगर वीडियो फ़्रेम की स्ट्रीमिंग के क्रम से बारकोड की पहचान करने की कोशिश की जा रही है, तो आइडेंटिफ़ायर एक फ़्रेम से दूसरे फ़्रेम तक अलग-अलग नतीजे दे सकता है. आपको एक ही वैल्यू की लगातार सीरीज़ मिलने तक इंतज़ार करना चाहिए, ताकि यह पक्का हो सके कि आप अच्छा नतीजा दे रहे हैं.

    Checksum अंक, ITF और CODE-39 के लिए काम नहीं करता.

  • अगर Camera या camera2 एपीआई का इस्तेमाल किया जाता है, तो डिटेक्टर के पास कॉल को थ्रॉटल करें. अगर डिटेक्टर के चालू होने के दौरान, कोई नया वीडियो फ़्रेम उपलब्ध हो जाता है, तो फ़्रेम को छोड़ दें. उदाहरण के लिए, क्विकस्टार्ट सैंपल ऐप्लिकेशन में VisionProcessorBase क्लास देखें.
  • अगर CameraX एपीआई का इस्तेमाल किया जाता है, तो यह पक्का कर लें कि बैकप्रेशर स्ट्रेटजी, अपनी डिफ़ॉल्ट वैल्यू ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST पर सेट हो. इससे यह गारंटी मिलती है कि विश्लेषण के लिए एक बार में सिर्फ़ एक इमेज ही डिलीवर की जाएगी. अगर ऐनालाइज़र के व्यस्त होने पर ज़्यादा इमेज जनरेट होती हैं, तो वे अपने-आप हट जाएंगी और डिलीवरी के लिए सूची में नहीं दिखेंगी. जिस इमेज की जांच की जा रही है उसे Imageप्रॉक्सी.close() को कॉल करके बंद किए जाने के बाद, अगली सबसे नई इमेज डिलीवर की जाएगी.
  • अगर इनपुट इमेज पर ग्राफ़िक ओवरले करने के लिए, डिटेक्टर के आउटपुट का इस्तेमाल किया जाता है, तो सबसे पहले एमएल किट से नतीजा पाएं. इसके बाद, एक ही बार में इमेज और ओवरले को रेंडर करें. यह तरीका, हर इनपुट फ़्रेम के लिए सिर्फ़ एक बार डिसप्ले सरफ़ेस पर रेंडर होता है. उदाहरण के लिए, क्विकस्टार्ट ऐप्लिकेशन के नमूने में CameraSourcePreview और GraphicOverlay क्लास देखें.
  • अगर Camera2 API का इस्तेमाल किया जाता है, तो इमेज को ImageFormat.YUV_420_888 फ़ॉर्मैट में कैप्चर करें. अगर पुराने Camera API का इस्तेमाल किया जा रहा है, तो इमेज को ImageFormat.NV21 फ़ॉर्मैट में कैप्चर करें.