WICG / WICG/shape-detection-api

`BarcodeDetector` loses QR code segment information

Open
#112 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
316
Forks
39
Avg merge
8d 3h
Merged PRs (30d)
1

Description

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: https://github.com/WICG/shape-detection-api/issues/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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin at the BarcodeDetector result shape, especially rawValue, and compare the requested QR segment and byte information with the concern in WICG/shape-detection-api#35. Done means the API change is specified clearly enough to preserve segment boundaries and arbitrary bytes, with the chosen exposed representation documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.