Capture, read and decode barcodes through image files. More...
Import Statement: | import ArcGIS.AppFramework.Barcodes 1.0 |
Properties
- barcode : string
- barcodeType : BarcodeType
- barcodeTypeString : string
- boundingRect : rect
- decodeHints : int
- points : object
- source : url
- status : Status
Methods
- clear()
- decode(url source)
- decode(url source, rect boundingRect)
- string getBarcodeTypeString(barcodetype barcodeType_)
Detailed Description
The BarcodeDecoder component provides specialized tools to read and decode a wide variety of barcode types. This component is specifically designed to be used with images, making a dedicated external barcode scanner unnecessary.
BarcodeDecoder works through scanning images, such as from a file or an image object, for valid barcodes. These images can then be edited or processed futher by other components or applications. Consider the BarcodeFilter component for faster detection through a video stream.
This code sample outlines the functions a barcode decoder to a pre-existing camera object. The camera takes a photo every quarter of a second, searching for a readable barcode. Once found, the image is captured and the barcode decoded.
Item { BarcodeDecoder { id: barcodeDecoder property int _decodeHints: BarcodeDecoder.DecodeHintQR_CODE | BarcodeDecoder.DecodeHintTryHarder property bool rotated: false property bool has1D: (decodeHints & (BarcodeDecoder.DecodeHintCODABAR | BarcodeDecoder.DecodeHintCODE_39 | BarcodeDecoder.DecodeHintCODE_93 | BarcodeDecoder.DecodeHintCODE_128 | BarcodeDecoder.DecodeHintEAN_8 | BarcodeDecoder.DecodeHintEAN_13 | BarcodeDecoder.DecodeHintITF | BarcodeDecoder.DecodeHintMAXICODE | BarcodeDecoder.DecodeHintRSS_14 | BarcodeDecoder.DecodeHintRSS_EXPANDED | BarcodeDecoder.DecodeHintUPC_A | BarcodeDecoder.DecodeHintUPC_E | BarcodeDecoder.DecodeHintUPC_EAN_EXTENSION )) !== 0 decodeHints: _decodeHints onStatusChanged: { if (status === BarcodeDecoder.Error) { if (has1D && !rotated) { imageObject.rotate(90, imageObject.width >> 1, imageObject.height >> 1); rotated = true; decode(imageObject.url); return; } scanFailed(); return; } if (status !== BarcodeDecoder.Decoding && barcode.length !== 0) { console.log("codeScanned:", barcode, "type:", barcodeTypeString) if (debugMode) { scanMessage.show(barcodeTypeString + "\n" + barcode, 5000, "white"); } else { scanMessage.show(barcode, undefined, "green"); codeScanned(barcode); } } } } FileFolder { id: captureFolder path: AppFramework.standardPaths.writableLocation(StandardPaths.TempLocation) } Timer { id: retryTimer running: false repeat: false triggeredOnStart: false interval: 250 onTriggered: { scan(); } } function scan() { barcodeDecoder.clear(); if (flashActive || scanMode === scanModeCapture) { scanCapture(); } } function scanCapture() { camera.imageCapture.captureToLocation(captureFolder.filePath("code.jpg")); } function decodeCapture(path) { imageObject.load(path); var captureFrameD = Math.min(imageObject.size.width, imageObject.size.height) * 9/ 10; var captureFrameX = (imageObject.size.width - captureFrameD) >> 1; var captureFrameY = (imageObject.size.height - captureFrameD) >> 1; imageObject.clip(captureFrameX, captureFrameY, captureFrameD, captureFrameD); barcodeDecoder.rotated = false; barcodeDecoder.decode(imageObject.url); } }
Enumerations
Status enumeration
Enum describing the decoder's potential states.
Name | Value |
---|---|
BarcodeDecoder.Ready | 0 |
BarcodeDecoder.Decoding | 1 |
BarcodeDecoder.Error | 2 |
BarcodeType enumeration
Enum describing the type of barcode to scan for.
Name | Value |
---|---|
BarcodeDecoder.BarcodeTypeNONE | 0 |
BarcodeDecoder.BarcodeTypeAZTEC | 1 |
BarcodeDecoder.BarcodeTypeCODABAR | 2 |
BarcodeDecoder.BarcodeTypeCODE_39 | 3 |
BarcodeDecoder.BarcodeTypeCODE_93 | 4 |
BarcodeDecoder.BarcodeTypeCODE_128 | 5 |
BarcodeDecoder.BarcodeTypeDATA_MATRIX | 6 |
BarcodeDecoder.BarcodeTypeEAN_8 | 7 |
BarcodeDecoder.BarcodeTypeEAN_13 | 8 |
BarcodeDecoder.BarcodeTypeITF | 9 |
BarcodeDecoder.BarcodeTypeMAXICODE | 10 |
BarcodeDecoder.BarcodeTypePDF_417 | 11 |
BarcodeDecoder.BarcodeTypeQR_CODE | 12 |
BarcodeDecoder.BarcodeTypeRSS_14 | 13 |
BarcodeDecoder.BarcodeTypeRSS_EXPANDED | 14 |
BarcodeDecoder.BarcodeTypeUPC_A | 15 |
BarcodeDecoder.BarcodeTypeUPC_E | 16 |
BarcodeDecoder.BarcodeTypeUPC_EAN_EXTENSION | 17 |
DecodeHint enumeration
Enum describing the hints that are produced by the scanner to ensure a more accurate scan.
Name | Value |
---|---|
BarcodeDecoder.DecodeHintTryHarder | -2147483648 |
BarcodeDecoder.DecodeHintNONE | 1 |
BarcodeDecoder.DecodeHintAZTEC | 2 |
BarcodeDecoder.DecodeHintCODABAR | 4 |
BarcodeDecoder.DecodeHintCODE_39 | 8 |
BarcodeDecoder.DecodeHintCODE_93 | 16 |
BarcodeDecoder.DecodeHintCODE_128 | 32 |
BarcodeDecoder.DecodeHintDATA_MATRIX | 64 |
BarcodeDecoder.DecodeHintEAN_8 | 128 |
BarcodeDecoder.DecodeHintEAN_13 | 256 |
BarcodeDecoder.DecodeHintITF | 512 |
BarcodeDecoder.DecodeHintMAXICODE | 1024 |
BarcodeDecoder.DecodeHintPDF_417 | 2048 |
BarcodeDecoder.DecodeHintQR_CODE | 4096 |
BarcodeDecoder.DecodeHintRSS_14 | 8192 |
BarcodeDecoder.DecodeHintRSS_EXPANDED | 16384 |
BarcodeDecoder.DecodeHintUPC_A | 32768 |
BarcodeDecoder.DecodeHintUPC_E | 65536 |
BarcodeDecoder.DecodeHintUPC_EAN_EXTENSION | 131072 |
Property Documentation
Returns a human-readable string of the barcode type being scanned for.
Returns the number corresponding to the latest hint given by the decoder to return a more accurate scan.
Method Documentation
Decodes the barcode found in the defined source, presenting the contained string.
If a bounding rectangle is not present, the decoder will scan the entire image for a barcode. This is easier for the user to use, but is more likely to produce errors.
The source parameter
The URL path to the image providing the barcode.
Decodes the barcode found in the defined source, presenting the contained string.
If a bounding rectangle is present, the decoder will only scan within the rectangle. This is slower to use, but more accurate.
The source parameter
The URL path to the image providing the barcode.
The boundingRect parameter
The bounding rectangle the decoder will scan for the barcode within.