অ্যান্ড্রয়েডে এমএল কিট দিয়ে বারকোড স্ক্যান করুন

আপনি বারকোড চিনতে এবং ডিকোড করতে ML কিট ব্যবহার করতে পারেন।

বৈশিষ্ট্য আনবান্ডেড বান্ডিল
বাস্তবায়ন মডেলটি গতিশীলভাবে Google Play পরিষেবার মাধ্যমে ডাউনলোড করা হয়। মডেলটি বিল্ড টাইমে আপনার অ্যাপের সাথে স্ট্যাটিকভাবে লিঙ্ক করা থাকে।
অ্যাপের আকার প্রায় 200 KB আকার বৃদ্ধি. প্রায় 2.4 MB আকার বৃদ্ধি.
প্রারম্ভিক সময় প্রথম ব্যবহারের আগে মডেল ডাউনলোড করার জন্য অপেক্ষা করতে হতে পারে। মডেল অবিলম্বে উপলব্ধ.

চেষ্টা কর

তুমি শুরু করার আগে

  1. আপনার প্রকল্প-স্তরের build.gradle ফাইলে, আপনার buildscript এবং allprojects উভয় বিভাগেই Google-এর Maven সংগ্রহস্থল অন্তর্ভুক্ত করা নিশ্চিত করুন৷

  2. আপনার মডিউলের অ্যাপ-লেভেল গ্রেডল ফাইলে এমএল কিট অ্যান্ড্রয়েড লাইব্রেরির জন্য নির্ভরতা যোগ করুন, যা সাধারণত 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 পরিষেবাগুলিতে মডেলটি ব্যবহার করার জন্য:

    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 পরিষেবাগুলিতে মডেলটি ব্যবহার করতে চান , তাহলে প্লে স্টোর থেকে আপনার অ্যাপ ইনস্টল হওয়ার পরে আপনি ডিভাইসে মডেলটিকে স্বয়ংক্রিয়ভাবে ডাউনলোড করতে আপনার অ্যাপটি কনফিগার করতে পারেন। এটি করতে, আপনার অ্যাপের 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 পরিষেবা ModuleInstallClient API- এর মাধ্যমে ডাউনলোডের অনুরোধ করতে পারেন।

    আপনি যদি ইনস্টল-টাইম মডেল ডাউনলোডগুলি সক্ষম না করেন বা স্পষ্ট ডাউনলোডের অনুরোধ না করেন, আপনি প্রথমবার স্ক্যানার চালানোর সময় মডেলটি ডাউনলোড করা হবে৷ ডাউনলোড সম্পূর্ণ হওয়ার আগে আপনি যে অনুরোধগুলি করেন তা কোনও ফলাফল দেয় না।

ইনপুট ইমেজ নির্দেশিকা

  • এমএল কিট সঠিকভাবে বারকোড পড়ার জন্য, ইনপুট চিত্রগুলিতে অবশ্যই বারকোড থাকতে হবে যা পর্যাপ্ত পিক্সেল ডেটা দ্বারা উপস্থাপিত হয়।

    নির্দিষ্ট পিক্সেল ডেটা প্রয়োজনীয়তা বারকোডের ধরন এবং এতে এনকোড করা ডেটার পরিমাণ উভয়ের উপর নির্ভর করে, যেহেতু অনেক বারকোড পরিবর্তনশীল আকারের পেলোড সমর্থন করে। সাধারণভাবে, বারকোডের ক্ষুদ্রতম অর্থপূর্ণ এককটি কমপক্ষে 2 পিক্সেল প্রশস্ত হওয়া উচিত এবং 2-মাত্রিক কোডগুলির জন্য, 2 পিক্সেল লম্বা হওয়া উচিত৷

    উদাহরণস্বরূপ, EAN-13 বারকোডগুলি 1, 2, 3, বা 4 ইউনিট প্রশস্ত বার এবং স্পেস দিয়ে তৈরি, তাই একটি EAN-13 বারকোড ছবিতে আদর্শভাবে বার এবং স্পেস রয়েছে যা কমপক্ষে 2, 4, 6, এবং 8 পিক্সেল চওড়া। যেহেতু একটি EAN-13 বারকোড মোট 95 ইউনিট চওড়া, বারকোডটি কমপক্ষে 190 পিক্সেল প্রশস্ত হওয়া উচিত।

    ঘন বিন্যাস, যেমন PDF417, ML Kit এর নির্ভরযোগ্যভাবে পড়ার জন্য তাদের পিক্সেল মাত্রার প্রয়োজন। উদাহরণস্বরূপ, একটি PDF417 কোডে একক সারিতে 34 17-ইউনিট চওড়া "শব্দ" থাকতে পারে, যা আদর্শভাবে কমপক্ষে 1156 পিক্সেল চওড়া হবে।

  • খারাপ ইমেজ ফোকাস স্ক্যানিং নির্ভুলতা প্রভাবিত করতে পারে। আপনার অ্যাপ গ্রহণযোগ্য ফলাফল না পেলে, ব্যবহারকারীকে ছবিটি পুনরায় ক্যাপচার করতে বলুন।

  • সাধারণ অ্যাপ্লিকেশানগুলির জন্য, এটি একটি উচ্চ রেজোলিউশনের চিত্র প্রদান করার পরামর্শ দেওয়া হয়, যেমন 1280x720 বা 1920x1080, যা বারকোডগুলিকে ক্যামেরা থেকে অনেক দূরে থেকে স্ক্যানযোগ্য করে তোলে৷

    যাইহোক, অ্যাপ্লিকেশানগুলিতে যেখানে লেটেন্সি গুরুত্বপূর্ণ, আপনি কম রেজোলিউশনে চিত্রগুলি ক্যাপচার করে কার্যক্ষমতা উন্নত করতে পারেন, তবে বারকোডটি ইনপুট চিত্রের বেশিরভাগ অংশ তৈরি করতে হবে৷ এছাড়াও রিয়েল-টাইম কর্মক্ষমতা উন্নত করার টিপস দেখুন।

1. বারকোড স্ক্যানার কনফিগার করুন

আপনি যদি জানেন যে কোন বারকোড বিন্যাসগুলি আপনি পড়তে আশা করেন, আপনি বারকোড ডিটেক্টরের গতি উন্নত করতে পারেন শুধুমাত্র সেই বিন্যাসগুলি সনাক্ত করার জন্য কনফিগার করে।

উদাহরণস্বরূপ, শুধুমাত্র Aztec কোড এবং QR কোড সনাক্ত করতে, নিম্নলিখিত উদাহরণের মত একটি BarcodeScannerOptions অবজেক্ট তৈরি করুন:

কোটলিন

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

জাভা

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 )
  • ITF ( FORMAT_ITF )
  • UPC-A ( FORMAT_UPC_A )
  • UPC-E ( FORMAT_UPC_E )
  • QR কোড ( FORMAT_QR_CODE )
  • PDF417 ( FORMAT_PDF417 )
  • অ্যাজটেক ( FORMAT_AZTEC )
  • ডেটা ম্যাট্রিক্স ( FORMAT_DATA_MATRIX )

বান্ডেল করা মডেল 17.1.0 এবং আনবান্ডেড মডেল 18.2.0 থেকে শুরু করে, আপনি enableAllPotentialBarcodes() কে কল করতে পারেন যাতে সব সম্ভাব্য বারকোডগুলি ডিকোড করা না গেলেও ফেরত দেওয়া যায়৷ এটি আরও সনাক্তকরণের সুবিধার্থে ব্যবহার করা যেতে পারে, উদাহরণস্বরূপ ফেরত বাউন্ডিং বাক্সে যেকোনো বারকোডের একটি পরিষ্কার চিত্র পেতে ক্যামেরা জুম করে৷

কোটলিন

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
            // ...
        }
    }
}

জাভা

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
          // ...
        }
    }
}

আপনি যদি এমন একটি ক্যামেরা লাইব্রেরি ব্যবহার না করেন যা আপনাকে চিত্রের ঘূর্ণন ডিগ্রী দেয়, আপনি ডিভাইসের ঘূর্ণন ডিগ্রী এবং ডিভাইসে ক্যামেরা সেন্সরের অভিযোজন থেকে এটি গণনা করতে পারেন:

কোটলিন

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
}

জাভা

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() এ পাস করুন :

কোটলিন

val image = InputImage.fromMediaImage(mediaImage, rotation)

Java

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

একটি ফাইল ইউআরআই ব্যবহার করে

একটি ফাইল URI থেকে একটি InputImage অবজেক্ট তৈরি করতে, অ্যাপের প্রসঙ্গ এবং ফাইল URIকে InputImage.fromFilePath() এ পাস করুন। এটি উপযোগী যখন আপনি একটি ACTION_GET_CONTENT উদ্দেশ্য ব্যবহার করে ব্যবহারকারীকে তাদের গ্যালারি অ্যাপ থেকে একটি ছবি নির্বাচন করতে অনুরোধ করেন৷

কোটলিন

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 অবজেক্ট তৈরি করুন:

কোটলিন

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
)

জাভা

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 অবজেক্ট তৈরি করতে, নিম্নলিখিত ঘোষণা করুন:

কোটলিন

val image = InputImage.fromBitmap(bitmap, 0)

Java

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

চিত্রটি ঘূর্ণন ডিগ্রী সহ একটি Bitmap বস্তু দ্বারা উপস্থাপিত হয়।

3. বারকোডস্ক্যানারের একটি উদাহরণ পান

কোটলিন

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

জাভা

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

4. ইমেজ প্রক্রিয়া

process পদ্ধতিতে চিত্রটি পাস করুন:

কোটলিন

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

জাভা

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 বস্তু একটি বারকোড উপস্থাপন করে যা চিত্রে সনাক্ত করা হয়েছিল। প্রতিটি বারকোডের জন্য, আপনি ইনপুট ছবিতে এর আবদ্ধ স্থানাঙ্ক পেতে পারেন, সেইসাথে বারকোড দ্বারা এনকোড করা কাঁচা ডেটাও পেতে পারেন৷ এছাড়াও, বারকোড স্ক্যানার বারকোড দ্বারা এনকোড করা ডেটার ধরন নির্ধারণ করতে সক্ষম হলে, আপনি পার্স করা ডেটা ধারণকারী একটি বস্তু পেতে পারেন।

উদাহরণ স্বরূপ:

কোটলিন

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
        }
    }
}

জাভা

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 মেগাপিক্সেলের বেশি হয় না।

    যদি স্ক্যানিং গতি গুরুত্বপূর্ণ হয়, আপনি চিত্র ক্যাপচার রেজোলিউশন আরও কম করতে পারেন। যাইহোক, উপরে বর্ণিত ন্যূনতম বারকোড আকারের প্রয়োজনীয়তাগুলি মনে রাখবেন।

    আপনি যদি স্ট্রিমিং ভিডিও ফ্রেমগুলির একটি ক্রম থেকে বারকোডগুলি সনাক্ত করার চেষ্টা করছেন, তাহলে সনাক্তকারী ফ্রেম থেকে ফ্রেমে বিভিন্ন ফলাফল তৈরি করতে পারে৷ আপনি একটি ভাল ফলাফল ফিরিয়ে দিচ্ছেন এই আত্মবিশ্বাসের জন্য আপনি একই মানের একটি ধারাবাহিক সিরিজ না পাওয়া পর্যন্ত অপেক্ষা করুন।

    চেকসাম ডিজিটটি ITF এবং CODE-39-এর জন্য সমর্থিত নয়।

  • আপনি Camera বা camera2 API ব্যবহার করলে, ডিটেক্টরে থ্রোটল কল করুন। ডিটেক্টর চলাকালীন একটি নতুন ভিডিও ফ্রেম উপলব্ধ হলে, ফ্রেমটি ফেলে দিন। একটি উদাহরণের জন্য Quickstart নমুনা অ্যাপে VisionProcessorBase ক্লাস দেখুন।
  • আপনি যদি CameraX API ব্যবহার করেন, নিশ্চিত হন যে ব্যাকপ্রেশার কৌশলটি এর ডিফল্ট মান ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST এ সেট করা আছে। এটি গ্যারান্টি দেয় যে একবারে বিশ্লেষণের জন্য শুধুমাত্র একটি চিত্র সরবরাহ করা হবে। বিশ্লেষক ব্যস্ত থাকাকালীন যদি আরও ছবি তৈরি করা হয়, তবে সেগুলি স্বয়ংক্রিয়ভাবে ড্রপ করা হবে এবং বিতরণের জন্য সারিবদ্ধ হবে না। একবার ImageProxy.close() কল করে বিশ্লেষিত চিত্রটি বন্ধ হয়ে গেলে পরবর্তী সর্বশেষ চিত্রটি বিতরণ করা হবে।
  • আপনি যদি ইনপুট ইমেজে গ্রাফিক্স ওভারলে করার জন্য ডিটেক্টরের আউটপুট ব্যবহার করেন, তাহলে প্রথমে ML Kit থেকে ফলাফল পান, তারপর একটি একক ধাপে চিত্র এবং ওভারলে রেন্ডার করুন। এটি প্রতিটি ইনপুট ফ্রেমের জন্য শুধুমাত্র একবার প্রদর্শন পৃষ্ঠে রেন্ডার করে। একটি উদাহরণের জন্য Quickstart নমুনা অ্যাপে CameraSourcePreview এবং GraphicOverlay ক্লাসগুলি দেখুন।
  • আপনি Camera2 API ব্যবহার করলে, ImageFormat.YUV_420_888 ফরম্যাটে ছবি ক্যাপচার করুন। আপনি পুরানো ক্যামেরা API ব্যবহার করলে, ImageFormat.NV21 ফর্ম্যাটে ছবিগুলি ক্যাপচার করুন৷