1. Introduction
Overview
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 you 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.
- The document skew correction AI capability can identify document positions and adjust document angles in an image.
- The general text recognition AI capability can extract text in the image.
For more information, please visit our official website:
https://developer.huawei.com/consumer/en/hiai#Engine
2. About This Codelab
What You Will Create
In this codelab, you can use this AI capability to create an Android app that can identify document positions and adjust document angles and extract text information from images.
For example:
What You Will Learn
In this codelab, you will learn how to:
- Use Android Studio for efficient Android app development
- Use the document skew correction API of HUAWEI HiAI Engine
- Use the general text recognition API of HUAWEI HiAI Engine
What You Will Need
Hardware Requirements
- A development computer (desktop or laptop)
- A Huawei mobile phone equipped with the Kirin 970 or a later chipset and running EMUI 8.1.0 or later
Software Requirements
- Java JDK installation package
- Android Studio 3.5.2 or later
- Android SDK package
- HiAI SDK package
3. Installing the HMS Toolkit Plugin
Step 1: Install the plugin
Go to File > Settings > Plugins > Marketplace.
Enter "HMS Toolkit" to search for the plugin and install it.
Step 2: Restart Android Studio
Click "Restart".
4. Importing the Project
Step 1: Import the project
Download the project via the link below:
Step 2: Open the Coding Assistant
Go to HMS > Coding Assistant, and sign in to the HUAWEI ID.
Step 3: Go to AI > HUAWEI HiAI Engine
5. Project Details
Document Detection and Correction
Step 1: Open DocSkewCorrectionActivity
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
Step 3: View the Code Sample
Document Extraction
Step 1: Open TextRecognitionActivity
Find the handleTextRecognition(){} method for document extraction.
Step 2: Click General Text Recognition
Step 3: View the Code Sample
6. Building and Running the App
After project syncing, select a device as the deployment target, and click the Run icon to install and start sample app, as shown in the following figure.