I have a functionality to scan QR as well as barcode (GS1 128) format in two seperate screens. I am able to scan QR code however my ReceiveDetections(Detections detections) not detecting Barcode. Strange, I trying setting .SetBarcodeFormats(Barcode.AllFormats) and it detected Code-128 but cant get it to detect GS1-128 (UCC/EAN-128). ReceiveDetections is called but barcodes is null.

Below is my code:

_barcodeDetector = new BarcodeDetector.Builder(this)
         .SetBarcodeFormats(Barcode.AllFormats)
         .Build();
_cameraSource = new CameraSource
    .Builder(this, _barcodeDetector)
    .SetRequestedPreviewSize(250, 250)
    .SetAutoFocusEnabled(true)
    .Build();
surfaceView.Holder.AddCallback(this);
_barcodeDetector.SetProcessor(this);

public void ReceiveDetections(Detections detections)
{
    try
    {
        SparseArray barcodes = detections.DetectedItems;
        if (barcodes.Size() != 0)
        {
            string barcode = ((Barcode)barcodes.ValueAt(0)).RawValue;
        }
    }
    catch (Exception ex)
    {

    }
}

0 Answers