0

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)
    {

    }
}
Terry Burton
  • 2,801
  • 1
  • 29
  • 41
Arti
  • 2,993
  • 11
  • 68
  • 121
  • Are you using Firbase ML kit or Google vision api ? if you are Using MLkit and getting this issue then go for Zxing – Saurabh Bhandari May 03 '19 at 08:01
  • I am using Google Vision API – Arti May 03 '19 at 09:00
  • Use FireBase MLKit because Google vision api is deprecated now. Mlkit is upgraded version of this – Saurabh Bhandari May 03 '19 at 10:32
  • Code 128 is the spec code, GS1-128 is the app code. – SushiHangover May 03 '19 at 10:36
  • Is Mlkit available for xamarin? I tried using Zxing but its a pain to customize the UI. Which is why I had opted for Google vision API. – Arti May 03 '19 at 11:30
  • @SushiHangover So does that men Google vision API doe not support GS1-128? – Arti May 06 '19 at 04:25
  • @Arti GS1-128 is a part of the Code 128 spec (https://en.wikipedia.org/wiki/Code_128) so your GS1-128 barcodes should seen as Code 128 (as you stated it does in your question). The Vision API is being retired and for new code you really should start using FireBase's ML Kit (it is in "beta" but I've had no issues using it) and by using the Camera2 api (YUV output format) and dropping extra frames during the model execution, you can get near real-time detection/decoding... – SushiHangover May 06 '19 at 05:01

0 Answers0