Barcode
Defined in package com.scandit.datacapture.barcode.data
- Barcode
class Barcode
Added in version 6.0.0
A recognized barcode.
- data
@Nullable String getData()
Added in version 6.0.0
The data of this code as a unicode string.
For some types of barcodes/2d codes (for example Data Matrix, Aztec, Pdf417), the data may contain non-printable characters, characters that cannot be represented as unicode code points, or nul-bytes in the middle of the string. data may be null for such codes. How invalid code points are handled is platform-specific and should not be relied upon. If your applications relies on scanning of such codes, use rawData instead which is capable of representing this data without loss of information.
- rawData
byte
[] getRawData()Added in version 6.0.0
The raw data contained in the barcode.
Use this property instead of data if you are relying on binary-encoded data that cannot be represented as unicode strings.
Unlike data which returns the data in Unicode representation, the rawData returns the data with the encoding that was used in the barcode. See encodingRanges for more information.
- addOnData
@Nullable String getAddOnData()
Added in version 6.5.0
If present, this property returns the add-on code (also known as extension code) associated with this barcode. See Add-on Codes to understand how add-ons can be enabled.
- compositeRawData
byte
[] getCompositeRawData()Added in version 6.6.0
- encodingRanges
@NonNull List<@NonNull EncodingRange> getEncodingRanges()
Added in version 6.0.0
Array of encoding ranges. Each entry of the returned encoding array points into bytes of rawData and indicates what encoding is used for these bytes. This information can then be used to convert the bytes to unicode, or other representations. For most codes, a single encoding range covers the whole data, but certain 2d symbologies, such as Symbology.QR allow to switch the encoding in the middle of the code.
The returned encoding ranges are sorted from lowest to highest index. Each byte in rawData is contained in exactly one range, e.g. there are no holes or overlapping ranges.
- location
@NonNull Quadrilateral getLocation()
Added in version 6.0.0
The location of the code. The coordinates are in image-space, meaning that the coordinates correspond to actual pixels in the image. For display, the coordinates need first to be converted into screen-space using the data capture view.
The meaning of the values of Quadrilateral.topLeft etc is such that the top left point corresponds to the top left corner of the barcode, independent of how the code is oriented in the image.
Note
If you use BarcodeBatch you should not use this location at all. Instead use the always up-to-date TrackedBarcode.location.
Warning
In case the feature is not licensed, a quadrilateral with all corners set to 0, 0 is returned.
- isGs1DataCarrier
boolean
isGs1DataCarrier()Added in version 6.0.0
True for codes that carry GS1 data.
- compositeFlag
CompositeFlag getCompositeFlag()
Added in version 6.0.0
Flag to hint whether the barcode is part of a composite code.
- isColorInverted
boolean
isColorInverted()Added in version 6.0.0
Whether the recognized code is color inverted (printed bright on dark background).
- symbolCount
int
getSymbolCount()Added in version 6.0.0
The symbol count of this barcode. Use this value to determine the symbol count of a particular barcode, e.g. to configure the active symbol counts.
- frameId
int
getFrameId()Added in version 6.0.0
Id of the frame from which this barcode information was obtained.
- isStructuredAppend
boolean
isStructuredAppend()Added in version 6.15.0
Whether the barcode is a structured append barcode.
- structuredAppendData
@Nullable StructuredAppendData getStructuredAppendData()
Added in version 6.15.0
If present, this property returns the structured append data associated with this barcode. In structured append mode data is encoded across multiple 1D or 2D barcodes where each barcode contains only one segment of the complete data. Once all segment-containing barcodes are scanned the complete data can be read out.
Only a few symbologies (pdf417, microPdf417, QR, DataMatrix, Aztec, DotCode, MaxiCode) can use this mode, and each has a different set of limitations, like included metadata or the maximum number of barcodes that can form a set.
@Override public void onBarcodeScanned( @NonNull BarcodeCapture barcodeCapture, @NonNull BarcodeCaptureSession session, @NonNull FrameData frameData ) { Barcode barcode = session.getNewlyRecognizedBarcode(); StructuredAppendData appendData = barcode.getStructuredAppendData(); if (appendData != null) { // The barcode is in structured append mode and has data that is split across // multiple codes. Barcodes of the set all have the same appendData.barcodeSetId. if (appendData.isComplete()) { // The data is complete and can be fetched through appendData.completeData. } else { // The data is not yet complete, more codes need to be scanned. if (appendData.getTotalSegmentCount() <= 0) { // It is unknown across how many barcodes the data is distributed. } else { // appendData.scannedSegmentCount out of the needed // appendData.totalSegmentCount barcodes have been scanned already. } } } }