fix: make the pairing QR scanner actually see dense codes

The scanner read frames at 480p, which is thin for the web UI's dense
pairing QR (1024px, low error correction, a two-module quiet zone), and it
rejected a Y plane whose last row has no padding even though some cameras
return exactly rowStride * (height - 1) + width bytes — on those devices
every frame was dropped, so nothing ever reacted.

Frames are now requested at 720p and fall back to 480p only when the device
refuses the higher analysis size; a stream that fails to start reports an
error instead of leaving a silent preview. Decoding runs with zxing's
tryHarder hint and retries an inverted frame for light-on-dark codes.

The screen also reports what it sees: resolution/format and a live
"frames scanned / decode attempts" line, a one-time log of the first frame's
planes, row stride and byte count, a no-frames hint after four seconds, and a
"move closer" hint when frames decode but no QR is found.

0.4.6 (406).
This commit is contained in:
blumia committed 2026-11-23 12:26:16 +08:00
1 parent 8f6fd99103
commit 91bf5e5b81
7 files changed
+194 -39

No files matched your search

+13
View File
@@ -5,6 +5,19 @@
---
## 0.4.6 扫码无反应的修复与诊断(分支 `flutter`)
| 项 | 结果 |
| --- | --- |
| 原因候选 | 0.4.5 以 480p 取流,配对二维码很密(网页端 1024px、L 级纠错、只有 2 个模块的静区),模块在画面里可能小于 zxing 能识别的尺寸;另外部分设备的 Y 平面最后一帧不含行尾 padding(长度为 `rowStride*(h-1)+w`),旧代码会直接丢弃所有帧 |
| 取流 | 先请求 720p(`ResolutionPreset.high`),失败才退回 480p;取流失败不再静默显示预览,而是显示错误;4 秒没有帧时提示「没有收到相机画面」 |
| 解码 | zxing 加 `tryHarder`;正常解码失败后再用 `InvertedLuminanceSource` 试一次反色(深色卡片上的浅色二维码);Y 平面允许最后一帧缺少 padding |
| 诊断 | 扫描页底部显示「1280×720 yuv420 · 已扫描 N 帧 / 解码 M 次」;首帧通过 `debugPrint` 记录分辨率/planes/rowStride/像素步长/字节数,解码异常也会记录一次 |
| 测试 | `test/qr_scan_test.dart` 增加最后一帧无 padding、反色二维码两项;全部通过 |
| 版本 | **0.4.6(code 406)** |
---
## 0.4.5 扫码配对(分支 `flutter`)
| 项 | 结果 |