Commit Graph
1 Commits
Author SHA1 Message Date
44b97e5c3b Improve barcode scanning with native BarcodeDetector (#12784)
* Improve barcode scanning with native BarcodeDetector

Use the browser-native BarcodeDetector (Shape Detection API) for camera
barcode scanning when available, falling back to html5-qrcode. Native
decoding is hardware-accelerated and far more robust to low light, blur
and small codes than the pure-JS software decoder.

Also:
- Prefer the rear camera and higher resolution for better recognition
- Add a flashlight (torch) toggle for low-light scanning
- Full-frame detection (no aiming box) with multi-code support
- Auto-select a camera so scanning starts without manual selection
- Relax camera constraints (ideal instead of exact) for mobile robustness
- Fix a bug where the native <video> element was not rendered before
  scanning started, making the play button unresponsive

* Honor selected camera instead of forcing rear camera

The videoConstraints.facingMode override in the legacy html5-qrcode
path replaced the selected camera ID entirely, so selfie/front cameras
could not be used. Remove the facingMode preference from both scan
paths and rely on the camera selector, which already auto-selects the
rear camera when available.

* Adjust camera input settings for barcode scanning

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2026-09-26 16:21:30 +10:00