Research date: 2026-12-03. Question: what QR version can commodity Android devices reasonably scan when the code is shown on a phone screen?
No physical phones were available. The evidence here is:
- synthetic camera frames;
- decoders run in bulk on an Android emulator (ML Kit) and on the desktop (ZXing, zbar);
- one live-camera check on the emulator.
The tags used below:
- [measured]: a number from a run described here. The scripts and tables are in
scan-density/beside this file (see "Files"). - [doc]: a statement from documentation I fetched and read.
- [assumption]: an input I chose. It is not measured.
Recommendation
Level L, measured synthetically (emulator plus desktop decoders, no physical phone):
- Comfortable maximum: Version 20–22, about 840–980 bytes of card in
shc2:/digits. Assumptions: ML Kit is the decoder, the analysis frame is 1280×960 or 1920×1080, and the phone is held about 10 cm from the screen. Under those conditions V20–22 decodes exactly in at least 95% of frames with mild blur (σ = 1 px). This matches the SMART Health Cards spec's own ceiling of V22. - Stretch maximum: Version 27–30, about 1,440–1,700 bytes. This needs a 1920×1080 analysis frame (or a scanner that zooms in), the code filling at least 70% of the frame's short side, and good focus.
- Above V32, ML Kit did not reach 95% per frame in any tested cell with σ = 1 blur:
- V32 L itself reached 10/10 only at 1920×1080 with 85% fill;
- the best V35 L cell was 9/10;
- the best V40 L cell was 3/10;
- V35/V40 decode often only when frames are sharp (σ ≤ 0.5).
- Apps that keep CameraX's default 640×480 analysis size are much tighter. At σ = 1, V15 needs the code to fill at least 70% of the frame, and V22 did not reach 95% in any 640×480 cell.
Level M does not help in the same pixel budget. At equal payload, M needs a larger version. In every comparison here it needed as many camera pixels across the symbol as L, or more (section 4.6). The simulation includes no local damage such as occlusion or a saturated reflection. That is the one case M's extra error correction is for, and only a physical test can show whether it matters on screens.
What was measured and what was assumed
Measured:
-
Exact-text decode success (SHA-256 of the decoded text equals that of the encoded text) for 15,261 synthetic frames, with each of these decoders:
- ML Kit through Google Play services (the "gms" flavour, the same scanning module the system QR scanner uses);
- ML Kit bundled 17.3.0;
- ZXing 3.5.3, with default settings and with TRY_HARDER;
- zbar 0.23.95.
ML Kit bundled ran on 10,113 of the frames; the rest of the bundled refinement pass was skipped to save emulator time.
-
No decoder ever returned wrong text. There were 0 mismatches among all non-empty results, and 0 ML Kit exceptions.
-
The camera stream that the Play-services system QR scanner opens on the emulator is 1280×960, YUV_420_888 (
dumpsys media.camerawhile scanning). -
A live-camera check with the emulator's
-camera-back imagefilefeed (section 6).
Assumed:
- The image model: blur, noise, moiré, banding, glare and perspective, as defined below.
- The mapping from scanning distance to fill fraction (section 5).
- Which analysis resolutions real scanners use. Only the emulator's 1280×960 was observed. The others come from documentation or are assumptions.
Only a physical-phone test can settle:
- the real blur and noise in analysis frames, after autofocus, hand shake and the ISP's sharpening and denoising;
- real screen moiré and specular glare;
- the analysis resolution and zoom behaviour of the real system scanner, Google Lens and the Pixel or Samsung camera apps on actual devices;
- how close people actually hold the phone and how long they wait.
Per-frame success also understates per-attempt success. A scanner sees about 10–30 frames per second, so 50% per frame usually means a quick scan. But successive frames are correlated, which is why I report both the ≥95% and the ≥50% thresholds.
1. Test symbols [measured]
Symbols come from toQr / toViewerQr in dense-qr/src/transport.ts. That gives a byte segment for shc2:/ (or https://joshuamandel.com/shc2-poc/#shc2:/), then a numeric segment of 7-byte→17-digit blocks. Each symbol carries the largest payload of pseudo-random bytes that fits the target version.
| Version | Modules | L: card bytes / text chars | M: card bytes / text chars |
|---|---|---|---|
| 10 | 57 | 260 / 638 | 203 / 499 |
| 15 | 77 | 506 / 1,235 | 399 / 975 |
| 20 | 97 | 840 / 2,046 | 650 / 1,585 |
| 22 | 105 | 983 / 2,394 | 762 / 1,857 |
| 25 | 117 | 1,250 / 3,042 | 977 / 2,379 |
| 27 | 125 | 1,439 / 3,501 | 1,103 / 2,685 |
| 30 | 137 | 1,703 / 4,142 | 1,346 / 3,275 |
| 32 | 145 | 1,921 / 4,672 | 1,512 / 3,678 |
| 35 | 157 | 2,268 / 5,514 | 1,780 / 4,329 |
| 40 | 177 | 2,910 / 7,074 | 2,295 / 5,580 |
The viewer-prefixed symbols, all at level L, were V15 (471 B), V22 (949 B) and V30 (1,669 B). The prefix costs about 34 bytes of capacity. It made no consistent difference to decode thresholds at the same version (tables in tables.md).
2. How each frame is synthesised [assumption: the image model]
The code is render.py. Every random choice is seeded from the image's name, so every image can be regenerated exactly.
- Scene. The symbol has a 4-module quiet zone. It sits on a white phone screen N+12 modules wide and 2.1× as tall. Around the screen is a near-black bezel at 4% of the screen width. Behind that is a mid-grey background with smooth random texture, so the camera sees more than the code.
- Display levels. Screen white is 0.90 and screen black is 0.08 (linear, 0–1).
- Geometry. A pinhole camera with focal length 0.71 × frame width, about 70° horizontal field of view.
- The plane is rotated in-plane by U(−20°, 20°).
- It is then tilted by
tiltdegrees about a random in-plane axis. - The distance is set so the symbol centre gets the target number of pixels per module (ppm).
- There is a random sub-pixel offset, and the centre is within ±5% of the frame centre.
- Sampling. Each camera pixel is the mean of a jittered 4×4 grid of point samples (5×5 for moiré), i.e. box-filtered pixel integration. This is "proper resampling" at non-integer scale.
- Blur. Gaussian, σ in camera pixels (0, 0.5, 1.0, 1.5), applied after the scene and any artefacts. It stands in for defocus, motion and lens softness.
- Noise. "None", or "moderate": additive Gaussian with σ = 0.02 plus signal-dependent σ = 0.03·√v. Then 8-bit quantisation and a greyscale PNG.
- Screen artefacts and stress conditions (each also has σ = 1):
- moiré: the screen is modelled as a pixel grid with 1080/(N+12) physical pixels per module. Each screen pixel lights a 0.7×0.7 aperture and the gaps sit at 25% of the pixel's level. Sampling that grid with the camera produces genuine aliasing moiré.
- banding: rows are multiplied by 1 + 0.15·sin(2πy/(H/6) + φ), standing in for PWM or rolling-shutter bands.
- glare: reduced contrast (black 0.40, white 0.90) plus an additive Gaussian bright spot of amplitude 0.25 and width 0.4 × symbol span, clipped at 1.
- tilt7, tilt15: perspective tilt of 7° or 15°.
- combo: noise + tilt 7° + moiré + glare together.
Experiments
- ppm grid.
- Base condition: ppm ∈ {1.5, 2, 2.5, 3, 4, 5, 6} × σ ∈ {0, 0.5, 1, 1.5}, 3 seeds.
- Each stress condition at σ = 1 on the same ppm list, 3 seeds.
- A refinement for base σ = 0.5, base σ = 1 and combo: ppm ∈ {2, 2.5, …, 6} in 0.5 steps, 10 seeds.
- Frame size is set so the symbol spans 55% of the frame's short side.
- Fixed analysis frames.
- Frame sizes 640×480, 1280×720 and 1920×1080.
- Fill (symbol span without quiet zone, as a fraction of the short side) ∈ {0.40, 0.55, 0.70, 0.85}.
- σ ∈ {0.5, 1.0}, 10 seeds.
- At fills 0.70 and 0.85 the in-plane rotation range and centre offset are reduced so that the symbol plus quiet zone stays inside the frame. At fill 0.85 the rotation is near 0°.
- This is the experiment the key table comes from.
- Same ppm, different frame size. V22, V30 and V40 L at ppm 3/4/5 with σ = 0.5, with the symbol spanning 30% of the short side instead of 55%. This tests whether large frames hurt ML Kit.
3. Decoders
-
ML Kit, Play-services flavour (
com.google.android.gms:play-services-mlkit-barcode-scanning:18.3.1). It runs Google Play services 26.34.36's barcode module, the one the system QR scanner uses. -
ML Kit, bundled (
com.google.mlkit:barcode-scanning:17.3.0).Both ML Kit flavours run on the emulator in a test app (
dev.mandel.qrtestanddev.mandel.qrtest.gms). The app reads PNGs from its files directory, callsInputImage.fromBitmap(bitmap, 0), restricts formats toFORMAT_QR_CODEand logs the SHA-256 of eachrawValue. The emulator was theci_testAVD: API 37,google_apis_playstorex86_64 image, headless, 3 GB RAM, read-only. -
ZXing core 3.5.3
QRCodeReaderwithHybridBinarizer, both with default hints and with TRY_HARDER. Java 17 on the desktop. -
zbarimg 0.23.95 with
-Sdisable -Sqrcode.enable, on the desktop.
Across all 10,113 frames that both ML Kit flavours decoded, they agreed closely: 4,564 successes for the Play-services flavour, 4,574 for bundled. Their thresholds are similar (tables below). "ML Kit" below means the Play-services flavour.
4. Results
4.1 Key table: largest version decoded in ≥95% of frames (ML Kit, level L) [measured]
Cells show the largest tested version V (from 10, 15, 20, 22, 25, 27, 30, 32, 35, 40) such that it and every smaller tested version decoded in at least 10 of 10 frames.
The 640×480, 1280×720 and 1920×1080 rows at fills 0.40–0.85 are measured directly (experiment 2). Cells marked * are derived: the 1280×960 row (the emulator system scanner's stream size) and the fill-0.30 column use the measured span each version needs (table 4.2). A version passes if that required span ≤ fill × short side.
σ = 1.0 (mild defocus or shake):
| analysis frame | fill 0.30 | fill 0.40 | fill 0.55 | fill 0.70 | fill 0.85 |
|---|---|---|---|---|---|
| 640×480 | <V10* | V10 | V10 | V15 | V15 |
| 1280×720 | V10* | V10 | V15 | V20 | V22 |
| 1280×960 | V10* | V15* | V20* | V22* | V27* |
| 1920×1080 | V10* | V15 | V22 | V27 | V32 |
σ = 0.5 (sharp):
| analysis frame | fill 0.30 | fill 0.40 | fill 0.55 | fill 0.70 | fill 0.85 |
|---|---|---|---|---|---|
| 640×480 | <V10* | V10 | V15 | V15 | V25 |
| 1280×720 | V10* | V15 | V20 | V22 | V30 |
| 1280×960 | V15* | V15* | V22* | V30* | V32* |
| 1920×1080 | V15* | V22 | V25 | V35 | V32 |
The 1920×1080, fill 0.85 cell is below its fill-0.70 neighbour because V35 scored 9/10 there. Ten seeds per cell resolve only about ±1 version step.
For ≥50% of frames (ML Kit, L, σ = 1.0):
| analysis frame | fill 0.30 | fill 0.40 | fill 0.55 | fill 0.70 | fill 0.85 |
|---|---|---|---|---|---|
| 640×480 | <V10* | V10 | V10 | V15 | V20 |
| 1280×720 | V10* | V15 | V22 | V25 | V27 |
| 1280×960 | V15* | V15* | V25* | V27* | V35* |
| 1920×1080 | V15* | V15 | V30 | V35 | V35 |
The bundled ML Kit gives the same σ = 1 L table, except 1920×1080 at fill 0.85 is V30. Level-M versions of all tables, and the same tables for zbar and ZXing, are in keytables.md.
4.2 Camera pixels the symbol must span [measured]
This is the smallest tested span (fill × short side, in pixels, quiet zone excluded) from which every larger tested span gave ≥95% (10/10). It comes from experiment 2; the tested spans are 192, 264, 288, 336, 396, 408, 432, 504, 594, 612, 756 and 918. "—" means no tested span reached 10/10 at all larger spans.
| decoder, blur | V10 | V15 | V20 | V22 | V25 | V27 | V30 | V32 | V35 | V40 |
|---|---|---|---|---|---|---|---|---|---|---|
| ML Kit L σ=0.5 | ≤192 | 264 | 396 | 408 | 594 | 612 | 594 | 756 | — (9/10 at 918) | 918 |
| ML Kit L σ=1.0 | ≤192 | 336 | 504 | 594 | 756 | 756 | 918 | 918 | — | — |
| ML Kit M σ=0.5 | ≤192 | 264 | 336 | 396 | 504 | 594 | 756 | 918 | 756 | — |
| ML Kit M σ=1.0 | 264 | 336 | 594 | 594 | 756 | 756 | 918 | 918 | — | — |
| zbar L σ=0.5 | ≤192 | ≤192 | 264 | 264 | 288 | 396 | 408 | 288 | 408 | 504 |
| zbar L σ=1.0 | ≤192 | 264 | 408 | 396 | 396 | 336 | 396 | 432 | 504 | 756 |
Converted to pixels per module (span ÷ modules), ML Kit at σ = 1 needs about 5.2–6.7 ppm for V20–V30. zbar needs about 2.9–4.3 for V20–V40.
4.3 Minimum pixels per module, ppm-grid experiment (≥95%) [measured]
Base and combo points have 10 seeds; ppm 1.5 has 3. "none" means 95% was not reached by ppm 6, the top of this grid. Experiment 2 reaches higher ppm.
| symbol | ML Kit σ=0.5 | ML Kit σ=1 | ML Kit combo σ=1 | ML Kit bundled σ=0.5 | ZXing σ=1 | zbar σ=1 | zbar combo σ=1 |
|---|---|---|---|---|---|---|---|
| V10 L | 2.5 | 4 | 4.5 | 2.5 | 4 | 3 | none |
| V15 L | 3 | 4.5 | 4.5 | 3 | 6 | 3 | none |
| V20 L | 4.5 | 5 | 5.5 | 3 | none | none | none |
| V22 L | 4 | 5.5 | 6 | 4 | none | 3 | none |
| V25 L | 4.5 | none | none | 4 | none | 3.5 | none |
| V27 L | 5.5 | none | none | 4 | 5 | 3 | none |
| V30 L | 5.5 | none | 5.5 | 4 | none | 3 | none |
| V32 L | 5 | none | 5.5 | 4 | none | 3.5 | none |
| V35 L | 5.5 | none | none | 3 | none | 3 | none |
| V40 L | 5.5 | none | none | none | none | 6 | none |
M rows and ≥50% thresholds are in A_subset.md and tables.md. The values are not perfectly monotone in version, which is seed noise. Coarse grid, 3 seeds, σ = 0: ML Kit decoded V30 and V35 L in 3/3 frames at every ppm from 3 to 6; V40 L decoded 3/3 at 3–5 ppm and 2/3 at 6.
4.4 Stress conditions (σ = 1, 3 seeds; minimum ppm for ≥2/3) [measured]
| symbol | ML Kit: base / noise / tilt7 / tilt15 / moiré / banding / glare | zbar: base / noise / tilt7 / tilt15 / moiré / banding / glare |
|---|---|---|
| V10 L | 3 / 4 / 3 / 4 / 3 / 4 / 3 | 3 / 3 / 3 / 5 / 3 / 4 / 3 |
| V22 L | 5 / 5 / 5 / 5 / 5 / 5 / 4 | 3 / 3 / none / none / 3 / 4 / 3 |
| V30 L | 5 / 5 / 5 / 5 / 4 / 6 / 5 | 3 / 3 / 6 / none / 3 / 3 / 3 |
| V40 L | none / 6 / 6 / 6 / 5 / 6 / 4 | 3 / 3 / none / none / 3 / 3 / 4 |
Full rows are in B_subset.md (base uses 10 seeds and the ≥2/3 rule). Findings:
- For ML Kit, noise, 7–15° tilt, the simulated moiré, banding and glare each move the threshold by about half a step at most. Blur is the dominant factor.
- zbar is the most blur-tolerant decoder here. But it failed almost all 7° and 15° perspective tilts above V15, and so failed every "combo" frame. That points to weak perspective handling in its QR reader.
- ZXing 3.5.3 was the weakest overall. Its thresholds are erratic, sometimes failing at high ppm after succeeding at lower.
4.5 Does anything other than pixel density stop dense codes? [measured]
- No size or version refusal by ML Kit was seen.
-
ML Kit decoded V40 (7,074 characters) exactly in a 3933×2950 frame (11.6 MP).
-
With the same ppm, frames in which the symbol spans 30% of the short side did no worse than frames where it spans 55%:
symbol ppm span 30% span 55% V22 L 4 9/10 10/10 V30 L 5 9/10 9/10 V40 L 5 9/10 9/10 -
So ML Kit does not appear to downscale large inputs in a harmful way.
-
- An apparent penalty at 85% span in experiment 3 was an artefact of my setup. With ±20° rotation, the symbol's corners left the frame. Experiment 2 constrains rotation to avoid this.
- Dense versions fail through blur tolerance. As the version rises, ML Kit needs more pixels per module at the same blur: at σ = 1, about 4 ppm for V10 and about 6–7 ppm for V30. At σ = 1.5, V35 and V40 L decoded in at most 1 of 3 frames at any ppm up to 6. zbar's requirement grows far less. The cause is inside ML Kit's detector or decoder and cannot be seen from outside. [measured]
4.6 Equal payload: L versus M [measured spans; interpolation is my inference]
The version each level needs comes from toQr (equal-payload.json). The required span (ML Kit, ≥95%) comes from table 4.2. Where a payload falls between tested versions, I give the range between the neighbouring tested versions.
| card bytes | L version | M version | span needed, σ = 0.5: L / M | span needed, σ = 1.0: L / M |
|---|---|---|---|---|
| 300 | 11 | 13 | 192–264 / 192–264 | 192–336 / 264–336 |
| 700 | 18 | 22 | 264–396 / 396 | 336–504 / 594 |
| 1,100 | 24 | 27 | 408–594 / 594 | 594–756 / 756 |
| 1,700 | 30 | 35 | 594 / 756 | 918 / not reached by 918 |
At equal payload, M never needed fewer camera pixels than L. At 700 and 1,700 bytes it clearly needed more.
5. From pixels to holding distance [assumption + doc]
Analysis resolutions [doc]
-
CameraX
ImageAnalysis: "By default,ImageAnalysistargets 640x480." [doc] https://developer.android.com/media/camera/camerax/analyze -
ML Kit barcode guidance:
- "the smallest meaningful unit of the barcode should be at least 2 pixels wide";
- for dense codes "it's recommended to provide a higher resolution image, such as 1280x720 or 1920x1080";
- "only request the size from the camera that's required for barcode detection, which is usually no more than 2 megapixels".
[doc] https://developers.google.com/ml-kit/vision/barcode-scanning/android
My data say 2 px per module is far too few for versions ≥ V10 under any blur. Even sharp (σ = 0.5), ML Kit needed 2.5–5.5 ppm.
-
ML Kit code scanner (GmsBarcodeScanner): the page gives no analysis resolution. It says auto-zoom ("the scanner will intelligently detect and zoom in on the barcode") exists from 16.1.0 and is off by default. [doc] https://developers.google.com/ml-kit/vision/barcode-scanning/code-scanner
-
System QR scanner on the emulator: it opened a 1280×960 YUV stream. [measured] Real devices were not observed.
From distance to fill [assumption]
- The main camera has a 26 mm-equivalent lens on a 4:3 sensor. A 4:3 frame's short side then covers about d at distance d.
- A 16:9 frame (1280×720 or 1920×1080) is usually a crop of the 4:3 sensor, so its short side covers about 0.75 d.
- The symbol is about 5.5 cm wide on a phone screen about 7 cm wide.
That gives these fills:
| distance | fill, 4:3 frame (640×480, 1280×960) | fill, 16:9 frame (1280×720, 1920×1080) |
|---|---|---|
| 10 cm | 0.55 | 0.73 |
| 15 cm | 0.37 | 0.49 |
| 20 cm | 0.28 | 0.37 |
| 25 cm | 0.22 | 0.29 |
So at 10–25 cm the code spans only about 0.2–0.7 of the short side, not 0.5–0.8. Much closer than about 10 cm, phone main cameras may not focus. That near-focus limit is from memory, not checked.
Digital zoom (including the code scanner's auto-zoom) crops the sensor before scaling to the analysis size. With a sensor of 12 MP or more, it raises the effective fill without losing pixels per module. This is inference from how camera pipelines work; I did not test it.
What this means (combining 4.1 with the distance table)
At about 10 cm:
| scanner | σ = 1 | σ = 0.5 |
|---|---|---|
| system scanner (1280×960, fill 0.55) | V20 | V22 |
| 1920×1080 app (fill ≈ 0.73) | V27 | V32 |
| 640×480 app (fill 0.55) | V10 | V15 |
At 15 cm:
| scanner | σ = 1 | σ = 0.5 |
|---|---|---|
| system scanner (fill 0.37) | V15 | V15 |
| 1920×1080 app (fill ≈ 0.49) | V20 | V22 |
| 640×480 app (fill 0.37) | below V10 | below V10 |
6. Live-camera sanity check on the emulator [measured]
Method:
- Images were fed through
-camera-back imagefile:<png>. - I measured the mapping from file to frame by photographing a ruler image: the 960×1280 capture showed 213.3 px per 250 image px, a scale of 0.853.
- The system scanner was launched (
com.google.android.gms/.mlkit.barcode.ui.PlatformBarcodeScanningActivityProxy), and I waited up to 45 s for a result. - All decoded texts were compared with the expected text, and all were exact.
- Frames are static and noise-free, so each image gives a deterministic outcome. Nine images run twice gave identical results.
| symbol | ppm in the 1280×960 frame | result |
|---|---|---|
| V22 L | 3.0 / 3.5 / 4.0 / 6.8 | fail / ok / fail / ok |
| V25 L | 4.0 / 6.1 | fail / ok |
| V30 L | 4.0 / 4.6 / 5.3 | fail / ok / ok |
| V32 L | 4.6 / 5.0 / 5.0 | ok / fail / fail |
| V35 L | 4.6 / 4.65 / 5.0 | ok / ok / ok |
| V40 L | 4.15 / 4.6 / 5.0 | fail / ok / fail |
The system scanner on the 1280×960 stream decoded codes up to V40 at 3.5–5 ppm when frames were sharp. But success depended on exact pixel phase and was not monotone in ppm. This is consistent with the synthetic σ ≤ 0.5 results (3–5.5 ppm) and shows that even sharp frames near 4–5 ppm are marginal.
How the emulator resamples the image file into the camera frame is unknown, and these frames have none of a real camera's blur or noise. Treat this as a check that the full system-scanner path handles V40 data, not as a density measurement.
Files
The scripts, tables and summaries are in scan-density/ beside this file. The symbol data, per-image decoder outputs, sample frames, live-check captures and the test app are not in the repository.
- Generation and rendering:
symbols.ts: symbol generation;symbols.json: the modules and texts;equal-payload.json;render.py: the frame model above, with experiments 1–3 selected byMODE= (default) /refine/frames.
- Decoding:
device.sh: the emulator batch driver;zbar_batch.py,Zx.java: the desktop decoders;- the test app source is in
../app(flavoursbundledandgms).
- Results and analysis:
results/: per-image outputs from every decoder;analyze.py→tables.md,summary.json,frames-summary.json;spans.py→spans.json;keytable.py→keytables.md;A_subset.md,B_subset.md.
- Images and the live check:
samples/: example frames;live/: the live-camera images, UI dumps and screenshots,media_camera.txt.
The bulk renders (about 5.8 GB) were deleted after decoding. render.py regenerates them exactly, because the seeds are derived from the file names.