loading...

Comparison between Huawei Scan Kit and Zxing

irene83018774 profile image Irene ・4 min read

Introduction

The Huawei Scan Kit offers versatile scanning, decoding, and generation capacities for bar code and QR code, enabling developers to quickly create the scans for QR code in apps.

Huawei can automatically detect and amplify long-distance or smaller scan codes via its long-range accumulation in the computer vision sector and automate the recognition of normal, complex barcode (example: reflection) scanning (such as dark light, smudge, blur and cylinder) scanning services. Scan Kit improves the performance rate and user experience of QR scanning code.

Zxing is a common third-party open-source SDK, it allows an Android device with imaging hardware (a built-in camera) to scan barcodes or 2-D graphical barcodes and retrieve the data encoded. It only carries out simple QR-code scanning operations and does not support complex scanning conditions, including high light, bend and deformation. However, the optimization effect is still not ideal, and many people will spend a lot of time on the optimization.

Let us now evaluate the Zxing and the Huawei HMS scan kit capabilities:

Note
1.In this article, I have scanned the code for 5 times and taken the best time captured.
2.Results may vary from device to device. I have used Huawei Y7p device for scanning, maintained similar condition for both HMS scan and Zxing.

Normal Scanning

Alt Text
When simple QR code is scanned from normal distance (around half feet), we have captured the time for decoding the code .
Huawei Scan kit took 0.68 seconds.
Zxing scanner took 1.38 seconds.

Scanning QR code at an angle

Let us scan the QR code at an angle more than 45 degrees from line of sight.
Huawei Scan kit took 0.657 seconds.
Zxing scanner took 1.27 seconds.
Alt Text
However, when we tried to capture at an angle more than 60 degrees, Zxing was not able to scan the code.

Scanning Damaged and Transformed Code

In some scenarios, code scanning can be classified into reflection, dark light, smudge, blur, and cylinder scanning.
Alt Text
Alt Text
Alt Text
Result : In most of the transformed / damaged codes, HMS scanner was able to detect code in lesser time. HMS Scan kit wins.

Scanning Complex Code:

Complex QR or bar code is too dense to decode. Let us see effectiveness of both the scanners.
Alt Text
Huawei scanner took 2.214 seconds when scanned from ideal distance (1.5 feet). However, if QR code is scanned from close distance it took 10.237 seconds. When QR code is scanned from distance more that 3 to 4 feet, it took 23.105 seconds.

ZXING scan took 19.10 seconds when scanned from ideal distance (1.5 feet). When scanned from too close or away from QR code, it was not able to able to scan it.

Result: HMS Scan kit wins.

Scanning code from long distance

Since Zxing does not have an automatic zoom-in optimisation, it is difficult to recognize code when the code is less than 20% of the frame.
The HMS Scan Kit has a pre-detection feature that can automatically amplify a long distance QR code even if the QR code cannot be detected by naked eyes.
HMS scan took 1.391 sec to detect when QR code is more 8 feet away.
Zxing failed to detect the code.
Alt Text

Implementation of HMS scan kit:

Prerequisite

1.Java JDK 1.8 or higher is recommended.
2.Android Studio is recommended.
3.Before developing an app, you will need to register as a HUAWEI developer. Refer to Register a HUAWEI ID.
4.Integrating app gallery connect SDK. Refer to AppGallery Connect Service Getting Started.

Development

  1. Add the HMS scan kit dependencies in module-level build.gradle
implementation 'com.huawei.hms:scan:1.1.3.301'
  1. To launch HMS default scanner
ScanUtil.startScan(this, REQUEST_CODE_SCAN_ONE, new HmsScanAnalyzerOptions.Creator().create());
  1. Getting the scan result
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         if (resultCode != RESULT_OK || data == null) {
             return;
         }

         endTime = System.currentTimeMillis();

         //Default View
         if (requestCode == REQUEST_CODE_SCAN_ONE) {
             HmsScan obj = data.getParcelableExtra(ScanUtil.RESULT);

             if (obj != null) {

                     tvTimer.setText(String.valueOf((endTime-startTime) /1 000) + " sec");
              }    

             }

Implementation of Zxing scan:

  1. Add the Zxing scan dependencies in module-level build.gradle
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
  1. To initialize QR code scanner
qrScan = new IntentIntegrator(this);
  1. To launch the scanner
//initiating the qr code scan
 qrScan.initiateScan();
  1. Getting the scan result
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK || data == null) {
        return;
    }
    endTime = System.currentTimeMillis();


        IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);

            tvTimer.setText(String.valueOf((endTime-startTime)/1000) + " sec");

        if (result != null) {
            //if qrcode has nothing in it
            if (result.getContents() == null) {
                Toast.makeText(this, "Result Not Found", Toast.LENGTH_LONG).show();
            } else {
                //if qr contains data
                try {
                    //converting the data to json
                    JSONObject obj = new JSONObject(result.getContents());

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Reference: 1.https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/service-introduction-0000001050041994
2.https://github.com/zxing/zxing

Posted on by:

Discussion

markdown guide