-
-
Notifications
You must be signed in to change notification settings - Fork 5
Vision Barcode Scan Barcodes
The contents of this page are based on the original Firebase Documentation
You can use ML Kit to recognize and decode barcodes.
If you know which barcode formats you expect to read, you can improve the speed of the barcode detector by configuring it to only detect those formats.
For example, to detect only Aztec code and QR codes, build a BarcodeDetectorOptions object as in the following example:
var options:BarcodeDetectorOptions = new BarcodeDetectorOptions();The following formats are supported:
- Code128
- Code39
- Code93
- CodaBar
- EAN13
- EAN8
- ITF
- UPCA
- UPCE
- QRCode
- PDF417
- Aztec
- DataMatrix
Note: For a Data Matrix code to be recognized, the code must intersect the center point of the input image. Consequently, only one Data Matrix code can be recognized in an image.
To scan barcodes in an image, pass the image as a Bitmapdata to the BarcodeDetector's detect() method:
- Get an instance of CloudLandmarkDetector:
var vision:VisionANE = VisionANE.vision;
barcodeDetector = vision.barcodeDetector();- Create a VisionImage object using a Bitmapdata.
var visionImage:VisionImage = new VisionImage(bmpQr.bitmapData);- Then, pass the image to the detect() method:
barcodeDetector.detect(visionImage,
function (features:Vector.<Barcode>, error:BarcodeError):void {
if (error) {
// ...
return;
}
// ...
});If the barcode recognition operation succeeds, the detector returns an array of VisionBarcode objects. Each VisionBarcode object represents a barcode that was detected in the image. For each barcode, you can get its bounding coordinates in the input image, as well as the raw data encoded by the barcode. Also, if the barcode detector was able to determine the type of data encoded by the barcode, you can get an object containing parsed data.
For example:
for each (var barcode:Barcode in features) {
var corners:Vector.<Point> = barcode.cornerPoints;
var displayValue:String = barcode.displayValue;
var rawValue:String = barcode.rawValue;
var valueType:int = barcode.valueType;
switch (valueType) {
case 9: // wifi
var ssid:String = barcode.wifi.ssid;
var password:String = barcode.wifi.password;
var encryptionType:int = barcode.wifi.type;
break;
case 8: // url
var title:String = barcode.url.title;
var url:String = barcode.url.url;
default:
// See API reference for all supported value types
}
}
}Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Project setup
Analytics
Authentication
Dynamic Links
Google Sign In
Firestore
- Configuring the ANE
- Get Started
- Add and Manage Data
- Query Data
- Get Data
- Get Realtime Updates
- Perform Simple and Compound Queries
- Order and Limit Data
- Paginate Data
Messaging
One Signal
Performance
Remote Config
Storage
- Configuring the ANE
- Get Started
- Create a Reference
- Upload Files
- Download Files
- Use File Metadata
- Delete Files
Crashlytics
Vision
- Detect faces
- Scan barcodes
- Label images
- Recognize landmarks
- Natural Language
- Custom Models
External Links