Have you ever thought that Machines can’t do much without human interaction and commands?

Its sound so excited to work on the Machine learning modules and replicate the human behavior in Machines.

Let us explore a contrivance which replicate the human behavior of reading the text and writing to a paper.

YES!! You are thinking right. I am talking about Text-Recognition mechanism.

HUAWEI ML KIT introduced plenty of such concepts to ease down the human processing in order to get the work done by Machines.

HUAWEI ML KIT enable your applications to easily leverage the proven expertise in machine learning to support diverse Artificial Intelligence (AI) applications.

Let’s take a glace on supported services:

Text-related Services

Text Recognition

Document Recognition

Bank Card Recognition

General Card Recognition

Language-related Services

Text Translation

Language Detection

Audio File Transcription

Automatic Speech Recognition (ASR)

Text to Speech (TTS)

Image-related Services

Image Classification

Object Detection and Tracking

Landmark Recognition

Image Segmentation

Product Visual Search

Face/Body-related Services

Face Detection

We will be focusing on Text-related Services:

As Text-related services leverage multiple capabilities to implement useful AI applications.

We will be discussing on General card recognition capability in detail.

General card recognition service provides universal development framework based on text recognition technology.

General Card recognition service provides API’s for processing the text extraction from the travel card, Identity cards using camera streams, pictures taking and locally saved images.


The algorithm scan through the uploaded card, check if it’s supported and identify the text. Once the text is identified, it gives the result back in a text format which can further be customized.

Set Up Needed

· Must have a Huawei Developer Account

· Must have a Huawei phone with HMS or later

· Android Studio setup


In order to develop the HMS react native apps following steps are mandatory.

· Create a new project in Android studio.

· Configure your app into AGC.

· Enable ML kit Api & add SHA-256.

· Download the agconnect-services.json from AGC. Paste into app directory.


· Configure android level build.gradle

1) Add to allprojects/repositories

maven {url ‘'}

2) Add to buildscript/repositores

maven {url ‘'}

3) Add to buildscript/dependencies

classpath ‘com.huawei.agconnect:agcp:’

· Adding the Base SDK for text recognition into app.gradle


implementation ‘com.huawei.hms:ml-computer-vision-ocr:’ }

· Import the general card recognition plug-in package into app.gradle


implementation’com.huawei.hms:ml-computer-card-gcr-plugin:' }

· Add agc plugin in the top of app.gradle file

apply plugin: ‘com.huawei.agconnect’

· If you want the model to get updated automatically then add the below line of code above the application tag in Manifest.



android:value= “ocr”/>

Adding permissions

Add below permissions to Android. Manifest file.

1. <uses-permission android:name=”android.permission.CAMERA” />

2. <uses-permission android:name=”android.permission.INTERNET” />

3. <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />

4. <uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE” />

Adding features to Manifest

1. <uses-feature android:name=”” />

2. <uses-feature android:name=”” />

Sync Gradle and build the project.

Development Process

· Add the below code in order to upload the card images on the Main activity using camera or local folder.

· Implement the method for handling the Camera stream

· Implement the method for handling Local image

· Handling the call Back

// Recognition result processing logic.


Below are the screen shots attached from the working application.

Main Activity screen

Upload card images screen

Select supported card from the local storage

Note: Currently only Hong Kong, China, Macao and Taiwan card and Travel cards are supported.

Text- Recognition results


For official documentation visit here:


We can now read the text from any supported card and use them in our applications for further use with the customization.

Isn’t cool?