Learn Form Recognition using ML kit | JAVA

Huawei form recognition service uses AI technologies to recognize input images

sujith E
Huawei Developers
2 min readNov 11, 2020

--

Introduction

Form recognition service can recognize the information from FORM it will return table content such as table count, rows, columns, cellcoordinate, textInfo, etc..! and table content in Chinese and English.

Use case

This service will help you in daily basis, for example after collecting a large number of data we can use this service to recognize and convert the content into electronic documents.

Suggestions

1. Forms such as questionnaires can be recognized.

2. Currently images containing multiple forms cannot be recognized.

3. Shooting Angle: The horizontal tilt angle is less than 5 degrees.

4. Form Integrity: No missing corners and no bent or segment lines

5. Form Content: Only printed content can recognized, images, hand written content, seals and watermarks in the form cannot be recognized.

6. Image Specification: Image ratio should be less than or equal 3:1, resolution must be greater than 960 x 960 px.

ML Kit Configuration.

1. Login into AppGallery Connect, select MlKitSample in My Project list.

2. Enable Ml Kit, Choose My Projects > Project settings > Manage APIs

Development Process

Create Application in Android Studio.

App level gradle dependencies.

apply plugin: ‘com.android.application’
apply plugin: ‘com.huawei.agconnect’

Gradle dependencies

implementation ‘com.huawei.hms:ml-computer-vision-formrecognition:2.0.4.300’
implementation ‘com.huawei.hms:ml-computer-vision-formrecognition-model:2.0.4.300’

Root level gradle dependencies

maven {url ‘https://developer.huawei.com/repo/'}

classpath ‘com.huawei.agconnect:agcp:1.3.1.300’

Add the below permissions in Android Manifest file

<manifest xlmns:android…>

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

<application …

</manifest>

Add the following meta data in Manifest file its automatically install machine learning model.

<meta-data
android:name=”com.huawei.hms.ml.DEPENDENCY”
android:value=”fr”
/>

1. Create Instance for MLFormRecognitionAnalyzerSetting

in onCreate.

2. Create instance for MLFormRecognitionAnalyzer in onCreate.

MLFormRecognitionAnalyzerFactory analyzer = MLFormRecognitionAnalyzerFactory.getInstance().getFormRecognitionAnalyzer(setting);

3. Check Runtime permissions.

FormRecogActivity is the responsible for load forms from local storage and capture the live forms using FormRecognigation service and we can extract the form cells content.

Result

Tips & Tricks

1. Capture single form only, form service not supporting multiple forms.

2. The resolution must greater than 960 x 960px.

3. Currently this service not supporting handwritten text information.

Conclusion

This article will help you to get textinfo from form, it will extract the individual cells data with coordinates. This service will help you in daily basis.

Thank you for reading and if you have enjoyed this article I would suggest you implement this and provide your experience.

Reference

ML Kit — Form Recognition

Refer the URL

--

--