Skip to content

BarcodeDetector loses QR code segment information #112

Description

@jimmywarting

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' }
]
Image

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions