Smart Barcode Reader on QCS610 SoC

This project is designed to implement the EAN-13 barcode decoding application on TurboX C610 Open kit powered by the Qualcomm® QCS610 SoC.

The main objective of this application is to capture the barcode images from the TurboX C610 dev kit and then decode the EAN-13 barcode information from the captured barcode.

EquipmentLink
Thundercomm TurboX C610 development boardhttps://www.thundercomm.com/app_en/product/1593776185472315?index=1&categoryId=categorynull
USB CablesFor serial console interface, ADB and fastboot commands. USB3.0 Type C port for connecting to the board and flashing images.
DescriptionLink
Source Code: EAN-13 Barcode detection and decoding using FastCVhttps://github.com/globaledgesoft/Barcode-Reader-App-C610
Resource TitleLink or File name (and provide File)
Thundercomm TurboX C610 Platform Linux User GuidePlease refer to technical documents section on the product page: https://www.thundercomm.com/app_en/product/1593776185472315?index=1&categoryId=categorynull

About the Project
In this project, the app is designed to perform barcode region detection and recognition of the EAN-13 type barcode in the given image.

The application source tree on the host system is as seen below:barcodeTest/
 inc/
  - fastcv.h
  - barcode_decoder.h
  stb/
   - stb_image.h
   - stb_image_write.h
  opencv2/
   - Contain opencv header file
 lib/
  - contain fastcv and opencv libraries
 src/
  - barcode_decoding.cpp
  - main.cpp
 sampleImage/
 Contain barcode images for testing
 Makefile
 UbuntuARM.min

Dependencies

  1. Ubuntu System 18.04 or above
  2. Install Adb tool (Android debugging bridge) on host system

Prerequisites
Install the FastCV SDK

  1. Download FastCV SDK from url https://developer.qualcomm.com/software/fast-cv-sdk/tools and select particular version named v1.7.1 for Linux Embedded
  2. For FastCV installation and compilation, follow the below steps,
    $ chmod 777 fastcv-installer-linuxembedded-1-7-1.bin
    $ ./fastcv-installer-linuxembedded-1-7-1.bin

To build application in fastcv:

  1. Download Qualcomm® Hexagon™ DSP SDK from Qualcomm Developer Network https://developer.qualcomm.com/software/hexagon-dsp-sdk
    Extract the tar file
    $ tar xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tarcopy folder gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf to /tools/ folder.
    $ cp -r gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/ /tools/To install Hexagon SDK, follow below steps
    $chmod 777 qualcomm_hexagon_sdk_3_5_2_eval.bin
    $./qualcomm_hexagon_sdk_3_5_2_eval.bin
  2. Download gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar using given url
    https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/
    Extract the tar file
    $ tar xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tarcopy folder gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf to /tools/ folder.
    $ cp -r gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/ /tools/Rename gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf folder to linaro
    $ mv gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf linaro
  3. Keep the application folder ‘fastcvSimpleTest’ in /examples/common/ folder
    $ cp fastcv-1-7-1_LinuxEmbedded/samples/fastcvSimpleTest/ /examples/common/Copy 32-bit libfastcv.a from libs provided in the fastcv sdk (fastcv-1-7-1_LinuxEmbedded\lib\32-bit\hard\libfastcv.a) to /examples/common/fastcvSimpleTest/lib/ Folder.
    $ cp fastcv-1-7-1_LinuxEmbedded\lib\32-bit\hard\libfastcv.a /examples/common/fastcvSimpleTest/lib/
  4. Open a new terminal from the root directory of the Hexagon SDK and run below command
    $ cd
    $ source setup_sdk_env.source
  5. Change the directory to fastcvSimpleTest
    $ cd examples/common/fastcvSimpleTest
    Execute command below command
    $ make tree V=UbuntuARM_Release
  6. A folder with the name "UbuntuARM_Release" should get generated in the fastcvSimpleTest folder. It will contain the application’s binary file ‘fastcvSimpleTest’.

Introduction to Barcode:

Barcode is an image having a shape like a square or rectangle that consists of a sequence of parallel black lines and white spaces of various widths. Barcodes are placed on products for quick identification. 1D barcodes are used to store text information, like product size, type and color.

In this project we are decoding EAN (European Article Number) barcodes of type 1-D.

EAN is one of the standardized barcodes which is marked on most commercial products which are currently available at the stores. EAN barcodes only represent the digits 0–9, whereas some other barcodes can represent additional characters along with digits

Following figure represents EAN-13 data composition.

(1) Country code
Code that indicates the country 's name.

(2) Manufacturer code
It tells the original seller's name. Manufacturer code is applied for registration at the code center of each country in order to obtain it. EAN code can be used only after the manufacturer code is obtained.

(3) Product item code
Identifies the product. Different products from the same manufacturer have different product item codes.

(4) Check digit
It is used to verify whether a barcode has been scanned correctly or not.

EAN Decoding involves 2 steps:

  1. Barcode recognition
  2. Barcode decode

Barcode recognition:
 Input image is converted to a grayscale image. On the resulting image, apply morphological operations and then apply contours to get the region of interest of barcode.

Barcode decode:
Digits in the barcode are split into three groups such that: First digit, the first group of 6, the last group of 6.

Leaving the first digit, each digit of barcode is represented by 4 bars, such that white and black are alternate for the first group of 6, black and white are alternate for the last group of 6.

Each group of 4 bars has the bar width as 7, whereas each bar in the group of 4 can be any value from 1 to 4. Binary values of this 7 bit value are compared with ‘L’ ‘G’ ‘R’ Table and barcode numbers are extracted.


Steps to run the application:
To run application on the c610 board:

  1. Remount the root directory writable:
    $ adb root
    $ adb remount
    $ adb shell mount -o remount,rw /
  2. Push the fastcvSimpleTest binary file and input image to the target:
    $ git clone https://github.com/globaledgesoft/Barcode-Reader-App-C610
    $ cd Barcode-Reader-App-C610
    $ cp barcodeTest/ /examples/common/.
    Build the application
    $ cd
    $ source setup_sdk_env.source
    $ cd examples/common/barcodeTest/
    $ make tree V=UbuntuARM_Release
    $ adb push UbuntuARM_Release\ship\barcodeTest /data/barcode
    $ adb push sampleImage/ /data/barcode/
  3. Change bin permissions and execute the application executable:
    $ adb shell
    /# chmod +x /data/barcode/barcodeTest
    /# cd /data/barcode/
    /# ./barcodeTest Images/Digit_1/barcode_1.jpeg
    Then barcode numbers are displayed on the terminal.
  4. to test with qcs610 camera
    /# ./barcodeTest camera

Qualcomm QCS610 and Qualcomm Hexagon are products of Qualcomm Technologies, Inc. and/or its subsidiaries.

NameTitle Company
Rakesh Sankar
s.rakesh@globaledgesoft.com
Sr, System Architect
Global Edge Software Ltd
Ashish Tiwari
t.ashish@globaledgesoft.com
Architect
Global Edge Software Ltd
Ramsingh G
g.ramsingh@globaledgesoft.com
Senior Software Engineer
Global Edge Software Ltd
Priyanka K S
ks.priyanka@globaledgesoft.com
Software Engineer
Global Edge Software Ltd