-
Notifications
You must be signed in to change notification settings - Fork 16
M.4 Scan Barcodes
With ML Kit's barcode scanning API, you can read data encoded using most standard barcode formats.
Barcodes are a convenient way to pass information from the real world to your app. In particular, when using 2D formats such as QR code, you can encode structured data such as contact information or WiFi network credentials. Because ML Kit can automatically recognize and parse this data, your app can respond intelligently when a user scans a barcode.
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.
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 BarcodeDetectorOptions
//var options:BarcodeDetectorOptions = new BarcodeDetectorOptions();
//options.barcodeFormats =
var detector:BarcodeDetector = Mlkit.initBarcodeDetector(options);
detector.process(visionImg,function ($barcodes:Vector.<VisionBarcode>, $error:Error):void
{
if($error) trace($error.message);
if($barcodes)
{
trace("--------- VisionBarcode ------");
for(var i:int=0; i < $barcodes.length; i++)
{
var barcode:VisionBarcode = $barcodes[i];
trace("\t" + barcode.toString());
}
trace("------------------------------");
}
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