Intermediate: OneSignal Push Notification Integration in Xamarin (Android)
Overview
In this article, I will create a demo app along with the integration of ML Kit Text Recognition which is based on Cross platform Technology Xamarin. It provides the text translate from supported languages and also supports text recognition from photo. User can easily capture the photos of text based images and detect the text from images and translate into local languages.
Text Recognition Service Introduction
ML Text Recognition service extracts text from images of receipts, business cards, and documents. This service is useful for industries such as printing, education, and logistics. User can use it to develop apps that handle data entry and check tasks.
This service can run on the cloud or device, but the supported languages differ in the two scenarios:
1. On-device API recognizes characters in Simplified Chinese, Japanese, Korean, and Latin-based languages.
2. On-cloud API supports more languages. For example, Simplified Chinese, English, Spanish, Portuguese, Italian, German, French, Russian, Japanese, Korean, Polish, Finnish, Norwegian, Swedish, Danish, Turkish, Thai, Arabic, Hindi, and Indonesian.
The text recognition service can recognize text in both static images and dynamic camera streams with a host of APIs, which you can call synchronously or asynchronously to build your text recognition-enabled apps.
Prerequisite
1. Xamarin Framework
2. Huawei phone
3. Visual Studio 2019
App Gallery Integration process
1. Sign In and Create or Choose a project on AppGallery Connect portal.
2. Add App and provide the app details.
3. Navigate to Project settings > download the configuration file.
4. Navigate to General Information > Data Storage location.
5. Navigate to Manage APIs > enable ML Kit.
6. Navigate to ML Kit > Text Recognition.
Installing the Huawei ML NuGet package
1. Navigate to Solution Explore > Project > Right Click > Manage NuGet Packages.
2. Install Huawei.Hms.MlComputerVisionTextimagesuprresolutionModel and other respective packages.
Xamarin App Development
1. Open Visual Studio 2019 and Create A New Project.
2. Configure Manifest file and add following permissions and tags.
3. Create Activity class with XML UI.
TranslatorActivity.cs
This activity performs all the operation regarding translate the text from supported languages.
ImageTextAnalyseActivity.cs
This activity performs all the operation recognize characters in images.
Xamarin App Build Result
1. Navigate to Solution Explore > Project > Right Click > Archive/View Archive to generate SHA-256 for build release and Click on Distribute.
2. Choose Archive > Distribute.
3. Choose Distribution Channel > Ad Hoc to sign apk.
4. Choose Demo keystore to release apk.
5. Build succeed and click Save.
6. Result.
API statistics
Navigate to ML Kit > On-cloud API statistics.
Tips and Tricks
Following languages are support by Text Recognition.
- On-device: Simplified Chinese, Japanese, Korean, and Latin-based languages
- On-cloud: Simplified Chinese, English, Spanish, Portuguese, Italian, German, French, Russian, Japanese, Korean, Polish, Finnish, Norwegian, Swedish, Danish, Turkish, Thai, Arabic, Hindi, and Indonesian
Conclusion
In this article, we have learned how to integrate ML Text Recognition in Xamarin based Android application. User can capture or take image from gallery and detect the text and also translate the text from if user wants to translate the images from supported languages.
Thanks for reading this article. Be sure to like and comments to this article, if you found it helpful. It means a lot to me.
References
Text Recognition: https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/text-recognition-0000001051807680-V1