Implementation

This section only covers working with Barcode Scanner in the Catalyst console. Refer to the SDKand API documentation sections for implementing Barcode Scanner in your application’s code.

As mentioned earlier, you can access the code templates that will enable you to integrate Barcode Scanner in your Catalyst application from the console, and also test the feature by uploading images with barcodes and obtaining the decoded content.

Access Barcode Scanner

To access Barcode Scanner in your Catalyst console:

  1. Navigate to Zia Services in the left pane of the Catalyst console and click Barcode Scanner.
    barcode-scanner

  2. Click Try a Demo in the Barcode Scanner feature page.
    catalyst_barcode_test_page

Test Barcode Scanner in the Catalyst Console

You can test Barcode Scanner by either selecting a sample image from Catalyst or by uploading your own image.

To scan a sample image with a barcode and decode its content:

  1. Click Select a Sample Image in the box.
    catalyst_barcode_sample
  2. Select an image from the samples provided.
    catalyst_barcode_select_sample
    Barcode Scanner will scan the barcode and display its content under Result.

    You can also click View Response to do so in the JSON format.
    catalyst_barcode_sample_json

To upload your own image with a barcode and decode its content:

  1. Click Upload under the Result section.
    catalyst_barcode_upload
    If you’re opening Barcode Scanner after you have closed it, click Browse Files in this box.
    catalyst_barcode_browse
  2. Upload a file from your local system.
Notes:
  • The file must be in .jpg/.jpeg or .png format. The file size must not exceed 10 MB. The resolution of the image must not exceed 36000000 pixels.
  • You will not be able to specify the barcode type as an input while testing it in the Catalyst console, as it is detected automatically. If you know the barcode type, you can specify it in the API request that you send from your Catalyst application.
The console will scan the barcode and display its content.
catalyst_barcode_qr_scanned
You can copy the content using the copy icon for easier access, or check the JSON response by clicking View Response.
catalyst_barcode_qr_json

Access Code Templates for Barcode Scanner

You can implement Barcode Scanner in your Catalyst application using the code templates provided by Catalyst for Java, Node.js and Python platforms.

You can access them from the section below the test window. Click either the Java SDK, NodeJS SDK or Python SDK tab, and copy the code using the copy icon. You can paste this code in your web or Android application’s code wherever you require.

catalyst_barcode_java

In Java, you can process the input file as a new File and select the format of the barcode using the ZCBarcodeOptions module. If you want Zia to scan the image for all formats, you can use ZCBarcodeFormat.ALL. If you are aware of the format, you can enter it as ZCBarcodeFormat.ean13, for example. Refer to the API documentation for the keys of all supported formats.

catalyst_barcode_node

The Node.js code processes the barcode image as the object barcodePromise. You can provide the image file name and the format in a similar way here.

catalyst_barcode_python

In Python, you can provide an input file of the format .jpg/.jpeg or .png to the open() method and it returns the image file object as a response.You must pass the image file object an argument to the zia.scan_barcode() method. You can specify the barcode format using setFormat. If you enter the format asALL, Barcode Scanner automatically detects the format. It provides the decoded information as the response.

Last Updated 2023-09-05 15:16:18 +0530 +0530