I noticed that BarcodeDetector appears to lose information when decoding QR codes containing multiple data segments.
QR codes are not necessarily encoded as one continuous string. A QR code can contain multiple segments, where each segment has its own encoding mode and length.
For example, I created a QR code containing these two segments:
[
{ data: 'ABCDEFG', mode: 'alphanumeric' },
{ data: '0123456', mode: 'numeric' }
]
These are two distinct segments in the QR data stream:
ALPHANUMERIC("ABCDEFG")
NUMERIC("0123456")
The native BarcodeDetector successfully detects the QR code, but only return:
[
{
"boundingBox": { ... },
"cornerPoints": [ ... ],
"format": "qr_code",
"rawValue": "ABCDEFG0123456"
}
]
The two segments have effectively been flattened into a single string.
This means that information that was present in the QR code is no longer available to the web application.
The problem becomes even more significant with byte segments. A QR code can contain arbitrary binary data, for example:
ALPHANUMERIC("https://example.com")
BYTE(DE AD BE EF)
In this case, exposing only a concatenated string does not preserve the original byte data or the boundaries between the segments.
I'm also somewhat confused by the name rawValue here. The value exposed by the API does not appear to be the raw barcode payload. More on that here: #35
I need a raw Uint8Array
either the HOLE QR bits so i can split the segments myself so that i can read the bit / length / data manually
or i could get an array with segments back somehow.
I noticed that
BarcodeDetectorappears to lose information when decoding QR codes containing multiple data segments.QR codes are not necessarily encoded as one continuous string. A QR code can contain multiple segments, where each segment has its own encoding mode and length.
For example, I created a QR code containing these two segments:
These are two distinct segments in the QR data stream:
The native
BarcodeDetectorsuccessfully detects the QR code, but only return:The two segments have effectively been flattened into a single string.
This means that information that was present in the QR code is no longer available to the web application.
The problem becomes even more significant with byte segments. A QR code can contain arbitrary binary data, for example:
In this case, exposing only a concatenated string does not preserve the original byte data or the boundaries between the segments.
I'm also somewhat confused by the name
rawValuehere. The value exposed by the API does not appear to be the raw barcode payload. More on that here: #35I need a raw
Uint8Arrayeither the HOLE QR bits so i can split the segments myself so that i can read the bit / length / data manually
or i could get an array with segments back somehow.