Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

M.2 Recognize Text

Hadi Tavakoli edited this page Jun 16, 2019 · 2 revisions

Text Recognition

With ML Kit's text recognition APIs, you can recognize text in any Latin-based language (and more, with Cloud-based text recognition).

Text recognition can automate tedious data entry for credit cards, receipts, and business cards, or help organize photos. With the Cloud-based API, you can extract text from documents, which you can use to increase accessibility or translate documents. Apps can even keep track of real-world objects, such as by reading the numbers on trains.

NOTICE: This is a beta release of ML Kit for Firebase. This API might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

You can use ML Kit to recognize text in images. ML Kit has both a general-purpose API suitable for recognizing text in images, such as the text of a street sign, and an API optimized for recognizing the text of documents. The general-purpose API has both on-device and cloud-based models. Document text recognition is available only as a cloud-based model. See the overview for a comparison of the cloud and on-device models.

Create a VisionImage first:

import com.myflashlab.air.extensions.firebase.mlkit.*;

// initialize ML Kit AFTER FirebaseCore is successfully started
Mlkit.init();

/*
    You can create VisionImage instance from BitmapData, File or ByteArray

    Mlkit.createVisionImageFromBitmapData
    Mlkit.createVisionImageFromFile
    Mlkit.createVisionImageFromBytes
*/

var image:File = File.applicationDirectory.resolvePath("img.jpg");

// This is beta version and for some reason, creating vision 
// images from file is not working! instead you may use 
// BitmapData for now!

var loader:Loader = new Loader();
loader.load(new URLRequest(image.url));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function loaderComplete(e:Event):void
{
	var bm:Bitmap = e.target.content as Bitmap;

	// create a VisionImage
	var visionImg:VisionImage = Mlkit.createVisionImageFromBitmapData(bm.bitmapData);
				
	trace("visionImg.id = " + visionImg.id);
});

Extract information from the image

// (Optional) initialize an instance of TextRecognizerCloudOptions
//var options:TextRecognizerCloudOptions = new TextRecognizerCloudOptions();
//options.languageHints = 
//options.modelType = 
//...

// get an instance of TextRecognizer
var detector:TextRecognizer = Mlkit.initTextRecognizer(Mlkit.ON_DEVICE, options);

// process the image and wait for results
detector.process(visionImg, function ($visionText:VisionText, $error:Error):void
{
	if($error) trace($error.message);
				
	if($visionText) trace($visionText.toString());
				
	detector.close();
});

Introduction to Firebase ANEs collection for Adobe Air apps


Get Started with Firebase Core in AIR

  1. Prerequisites
  2. Add Firebase to your app
  3. Add the Firebase SDK
  4. Init Firebase Core
  5. Available ANEs
  6. Managing Firebase iid

Get Started with Analytics

  1. Add Analytics ANE
  2. Init Analytics ANE
  3. Log Events
  4. Set User Properties

Get Started with Crashlytics

  1. Add Crashlytics ANE
  2. Test Your Implementation
  3. Customize Crash Reports
  4. Upload .dSYM for iOS apps

Get Started with DynamicLinks

  1. Add DynamicLinks ANE
  2. Init DynamicLinks ANE
  3. Create DynamicLinks
  4. Receive DynamicLinks
  5. View Analytics

Get Started with Authentication

  1. Add Authentication
  2. Init Authentication
  3. Manage Users
  4. Phone Number
  5. Custom Auth
  6. Anonymous Auth
  7. State in Email Actions
  8. Email Link Authentication

Get Started with FCM + OneSignal

  1. Add FCM ANE
  2. Init FCM ANE
  3. Send Your 1st Message
  4. Send Msg to Topics
  5. Understanding FCM Messages
  6. init OneSignal

Get Started with Firestore

  1. Add Firestore
  2. Init Firestore
  3. Add Data
  4. Transactions & Batches
  5. Delete Data
  6. Manage the Console
  7. Get Data
  8. Get Realtime Updates
  9. Simple and Compound
  10. Order and Limit Data
  11. Paginate Data
  12. Manage Indexes
  13. Secure Data
  14. Offline Data
  15. Where to Go From Here

Get Started with Realtime Database

  1. Add Realtime Database
  2. Init Realtime Database
  3. Structure Your Database
  4. Save Data
  5. Retrieve Data
  6. Enable Offline Capabilities

Get Started with Remote Config

  1. Parameters and Conditions
  2. Add Remote Config
  3. Init Remote Config

Get Started with Performance

  1. Add Performance ANE
  2. Init & Start Monitoring

Get Started with Storage

  1. Add Storage ANE
  2. Init Storage ANE
  3. Upload Files to Storage
  4. Download Files to Air
  5. Use File Metadata
  6. Delete Files

Get Started with Functions

  1. Write & Deploy Functions
  2. Add Functions ANE
  3. Init Functions
Clone this wiki locally