Huawei Developers
Published in

Huawei Developers

Intermediate: Integrating Text Recognition in Xamarin (Android) using Huawei ML Kit

What is Text Recognition?

Text Recognition is a technique for automating data extraction from a document or image having text in printed or written format.

Introduction

Huawei ML Kit provides Text Recognition service which helps to extract text from images and documents. It automates the data entry for credit cards, receipts and business card. It helps users to prevent manually input data into form or add card information while making a payment. Using this feature, we can make applications which will help to recognize passport or tickets on Stations and Airports.

Benefits of Text Recognition:

  1. Elimination of manual data entry.
  2. Error reductions.
  3. Resource saving due to process more data faster.

Let us start with the project configuration part:

Please follow Integrating Text Embedding in Xamarin(Android) project configuration except Step 9.

Let us start with the implementation part:

Step 1: Create activity_main.xml for UI.

Step 2: Create an object of MLLocalTextSetting to specify the language which has to recognize.

Step 3: Create MLTextAnalyzer to recognize text from images.

Step 4: Create an MLFrame using the Bitmap.

Step 5: Use AnalyseFrameAsync() method and pass MLFrame object to recognize the text.

Step 6: Set the result to TextView.

Step 7: Stop the analyzer to release the recognition resources inside OnDestroy() method.

Now Implementation part done.

Result:

Tips and Tricks

  1. Please use Manifest Merger inside ProjectName > ProjectName.csproj file.

2. Please set API Key inside MainActivity.cs OnCreate() method.

3. JPG, JPEG, PNG and BMP images are supported.

4. Length-Width ratio of image should range from 1:2 to 2:1.

Conclusion

In this article, we have learnt about getting the data from images and documents which helps to reduce manual data entry. It is useful for our daily life like Payments and sending Biodata etc.

Thanks for reading! If you enjoyed this story, please provide Likes and Comments.

Reference

Implementing ML Kit Text Recognition

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store