-
Notifications
You must be signed in to change notification settings - Fork 16
M.2 Recognize Text
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.
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);
});
// (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();
});
Enjoy building Air apps – With ♥ from MyFlashLabs Team
Introduction to Firebase ANEs collection for Adobe Air apps
Get Started with Firebase Core in AIR
- Prerequisites
- Add Firebase to your app
- Add the Firebase SDK
- Init Firebase Core
- Available ANEs
- Managing Firebase iid
Get Started with Authentication
- Add Authentication
- Init Authentication
- Manage Users
- Phone Number
- Custom Auth
- Anonymous Auth
- State in Email Actions
- Email Link Authentication
Get Started with FCM + OneSignal
- Add FCM ANE
- Init FCM ANE
- Send Your 1st Message
- Send Msg to Topics
- Understanding FCM Messages
- init OneSignal
- Add Firestore
- Init Firestore
- Add Data
- Transactions & Batches
- Delete Data
- Manage the Console
- Get Data
- Get Realtime Updates
- Simple and Compound
- Order and Limit Data
- Paginate Data
- Manage Indexes
- Secure Data
- Offline Data
- Where to Go From Here
Get Started with Realtime Database
- Add Realtime Database
- Init Realtime Database
- Structure Your Database
- Save Data
- Retrieve Data
- Enable Offline Capabilities
Get Started with Remote Config
- Add Storage ANE
- Init Storage ANE
- Upload Files to Storage
- Download Files to Air
- Use File Metadata
- Delete Files