Forum Xamarin.Forms

Barcode Scanner - Zxing Mobile

Hi developers,

I have a sample Xamarin Forms application and i'm using Zxing.Net.Mobile.
I can read QR Codes, ITF Small codes but, I can't read barcodes that has 44 digits.
My ideia is with app, read bank slip some figure below:

How do this?

It is my simples code:

`
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}

    async private void openScanner_Clicked(object sender, EventArgs e)
    {
        var opts = new ZXing.Mobile.MobileBarcodeScanningOptions
        {
            PossibleFormats = new List<ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE, ZXing.BarcodeFormat.ITF,
                ZXing.BarcodeFormat.All_1D, ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128,
                ZXing.BarcodeFormat.PDF_417, ZXing.BarcodeFormat.UPC_EAN_EXTENSION  
            }
        };

        opts.TryHarder = true;
        var barcodeReader = opts.BuildBarcodeReader();
        barcodeReader.Options.AllowedLengths = new[] { 44 };

        ZXingScannerPage scanPage = new ZXingScannerPage(opts);
        ITFReader
        scanPage.OnScanResult += (result) => {

            Device.BeginInvokeOnMainThread(() => {
                Navigation.PopAsync();
                DisplayAlert("Scanned Barcode", result.Text, "OK");
            });
        };

        await Navigation.PushAsync(scanPage);
    }
}

`

Posts

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    What error are you getting?

    Do you know what barcode format the document is using and whether it is supported by zing?

    A final observation is that getting a long barcode focused in the camera image is likely to be a challenge. My experience is that device camera barcode scanning struggles with anything other than large, clear barcodes - and is at the mercy of the device camera quality.
  • @JamesLavery said:
    What error are you getting?

    Do you know what barcode format the document is using and whether it is supported by zing?

    A final observation is that getting a long barcode focused in the camera image is likely to be a challenge. My experience is that device camera barcode scanning struggles with anything other than large, clear barcodes - and is at the mercy of the device camera quality.

    @JamesLavery

    It just don't read the code, doesnt happen.

    I was use the demo of Zxing in Play Store and there ai can read the barcode. The format his is ITF format, Type Text. This format is supported by zxing.

    Obs: So sorry, my english is not so good.

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    So the zing demo can read the code but your app cannot?

    Therefore it must be a bug in your implementation (my apologies if I am stating the obvious).

    Can you get the source for the zxing demo? If so, compare it with your code.

    I'm afraid I'm not in a position to examine or compare your code right now - I only have smartphone Internet and no dev machine available.
  • @JamesLavery said:
    So the zing demo can read the code but your app cannot?

    Therefore it must be a bug in your implementation (my apologies if I am stating the obvious).

    Can you get the source for the zxing demo? If so, compare it with your code.

    I'm afraid I'm not in a position to examine or compare your code right now - I only have smartphone Internet and no dev machine available.

    @JamesLavery

    So the zing demo can read the code but your app cannot?

    Yes, i try to find th demo code of App in Play Store but i cannot found.

    I'm afraid I'm not in a position to examine or compare your code right now - I only have smartphone Internet and no dev machine available.

    I'll going trying, do you know other Plugin that I can try read bardcodes like Zxing?

  • @JamesLavery said:
    So the zing demo can read the code but your app cannot?

    Therefore it must be a bug in your implementation (my apologies if I am stating the obvious).

    Can you get the source for the zxing demo? If so, compare it with your code.

    I'm afraid I'm not in a position to examine or compare your code right now - I only have smartphone Internet and no dev machine available.

    Do you know some place that I can set the length max of barcode read?

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    So there are no errors in the application output or device logs? Have you stepped through your code to verify that the line where navigation to the scan page occurs is being called?

    How about the zxing for Forms repo for sample code:

    https://github.com/Redth/ZXing.Net.Mobile
  • @JamesLavery said:
    So there are no errors in the application output or device logs? Have you stepped through your code to verify that the line where navigation to the scan page occurs is being called?

    How about the zxing for Forms repo for sample code:

    https://github.com/Redth/ZXing.Net.Mobile

    Yes, no there errors in my output and device log, the function is not called with this barcode, just with QR codes and other bardcodes.

    I already try run this demo, i solve all nuget dependencies but i get this error below:

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    Sorry - can't help with the demo build error.

    Did you base your code on the demo?
  • @JamesLavery said:
    Sorry - can't help with the demo build error.

    Did you base your code on the demo?

    Yes, I based in demo, I raised the simple app, this just has this Page and just read the barcode.

    I'm trying to run the demo code, but I need to solve this error for testing this large barcode. Maybe if the demo works, I can have a some idea.

  • @JamesLavery said:
    Sorry - can't help with the demo build error.

    Did you base your code on the demo?

    I exclude all nuget packages and reinstall, I got run the demo, but it also doesnt read this Barcode. :(

    What I didnt understand is, why the app demo in Play store of Zxing Team works with this barcode?

    Maybe a some config...? I dont know

  • Anyone know other Lib/Plugin for read barcodes in Xamarin Forms?

  • I check and the problem is in default maximum length of ITF format in Zxing.Net.Mobile that is 18.
    Anyone know how increase it?

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    I'm using Rb.Forms.Barcode which uses native vision components to decode the barcodes.

    (Technically, I'm using a forked version because their published package breaks Visual Studio's Nuget Package Manager.)

  • @JoeManke said:
    I'm using Rb.Forms.Barcode which uses native vision components to decode the barcodes.

    (Technically, I'm using a forked version because their published package breaks Visual Studio's Nuget Package Manager.)

    I will going to test this Plugin brother. Is it run in NET Framework 4.5?

  • I have the same problem as you Jonathan. Did you solve it ?

Sign In or Register to comment.