HUAWEI HiAI is an open artificial intelligence (AI) capability platform for smart devices, which adopts a "chip-device-cloud" architecture, opening up chip, app, and service capabilities for a fully intelligent ecosystem. This assists developers in delivering an optimal smart app experience for users, by fully leveraging Huawei's powerful AI processing capabilities.

In order to open up app capabilities, HUAWEI HiAI Engine provides a wide range of AI capabilities that can be integrated into apps. Document Skew Correction and General Text Recognition are two of the AI capabilities.

For more information, please visit our official website at the following URL:

What You Will Create

In this codelab, you can use this AI capability to create an Android app that can identifies document positions and adjusts document angles and extract text information from images.
For example:

What You Will Learn

What You Will Need

Hardware Requirements

Software Requirements

Step 1: Install

Click the File -> "Settings" -> "Plugins" -> "Marketplace"

Enter " HMS Toolkit " to search for the plugin and install it.

Step 2: Restart Android Studio

Click "Restart"

Step 1: Import the project from official site.

Download via the link below:


Step 2: Open the Coding Assistant

Click "HMS" "Coding Assistant",and login to Huawei account

Step 3: Select "AI" "HUAWEI HiAI Engine"

Document Correction/Detection

Step 1 Open up the DocSkewCorrectionActivity in the project

Find the handleDocDetect(Bitmap bitmap){} method for document detection and the handleDocRefine(Bitmap bitmap,DocCoordinates docCoordinates) {} method for document correction.

Step 2 Click Document Correction/Detection to enter the detail page

Step 3 Refer to the Code Sample for Document Correction/Detection

Document Extraction

Step 1 Open up the TextRecognitionActivity in the project

Find the handleTextRecognition (){} method for document extraction.

Step 2 Click General Text Recognition to enter the detail page

Step 3 Refer to the Code Sample for General Text Recognition

After the project sync, select your device as deployment target, and click the "Run" icon to install and start sample application. You may start to experience and test now. See as follows:

Code copied