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:
1 parent
8f6fd99103
commit
91bf5e5b81
7 files changed
+194
-39
No files matched your search
@@ -80,6 +80,38 @@ void main() {
|
||||
expect(decodeQrLuminance(image, size, size, size + pad), link);
|
||||
});
|
||||
|
||||
test('a last row without its padding still decodes', () {
|
||||
const scale = 6;
|
||||
const quiet = 4;
|
||||
const pad = 12;
|
||||
final code = QrCode(
|
||||
payload: QrPayload.fromString(link),
|
||||
errorCorrectLevel: QrErrorCorrectLevel.medium,
|
||||
);
|
||||
final size = (code.moduleCount + quiet * 2) * scale;
|
||||
final stride = size + pad;
|
||||
final full = _qrImage(link, scale: scale, quiet: quiet, pad: pad);
|
||||
// Some cameras return rowStride * (height - 1) + width bytes: the padding
|
||||
// after the final row is simply not there.
|
||||
final short = Uint8List(stride * (size - 1) + size)
|
||||
..setRange(0, stride * (size - 1) + size, full);
|
||||
expect(decodeQrLuminance(short, size, size, stride), link);
|
||||
});
|
||||
|
||||
test('a light-on-dark QR decodes through the inverted fallback', () {
|
||||
const scale = 6;
|
||||
const quiet = 4;
|
||||
final code = QrCode(
|
||||
payload: QrPayload.fromString(link),
|
||||
errorCorrectLevel: QrErrorCorrectLevel.medium,
|
||||
);
|
||||
final size = (code.moduleCount + quiet * 2) * scale;
|
||||
final normal = _qrImage(link, scale: scale, quiet: quiet);
|
||||
final inverted = Uint8List.fromList(
|
||||
[for (final value in normal) 255 - value]);
|
||||
expect(decodeQrLuminance(inverted, size, size, size), link);
|
||||
});
|
||||
|
||||
test('a frame without a QR code yields null', () {
|
||||
final blank = Uint8List(320 * 240)..fillRange(0, 320 * 240, 255);
|
||||
expect(decodeQrLuminance(blank, 320, 240, 320), isNull);
|
||||
|
||||
Reference in new issue
Block a user