3 ms·
Nice project, but BarcodeDector API [0] will probably soon land in browser, and in the meantime there are wasm-based polyfills [1] that I've successfully tested
by littlecranky67 3y ago
Nice project, but BarcodeDector API [0] will probably soon land in browser, and in the meantime there are wasm-based polyfills [1] that I've successfully tested myself for QR codes which work in-browser and offline.
In-browser webcam demo from the polyfill author: [2]
Making this a paid-per-scan and online-required library will have a hard time IMHO.
[0]: https://caniuse.com/mdn-api_barcodedetector https://caniuse.com/mdn-api_barcodedetector
[1]: https://github.com/undecaf/barcode-detector-polyfill#readme https://github.com/undecaf/barcode-detector-polyfill#readme
[2]: https://codepen.io/undecaf/pen/LYzXXzg https://codepen.io/undecaf/pen/LYzXXzg
- alex_suzuki 3y agoHey, the BarcodeDetector API has been around for some time, just crucially not on iOS. I didn't know about the polyfills though! If you're looking to only scan QR codes, https://github.com/nimiq/qr-scanner https://github.com/nimiq/qr-scanner is a library I can recommend and which I've used in a previous project. One thing the BarcodeDetector API does not give you is a UI for your barcode scanning. Basically it's your job to acquire an image and pass it to the API. With STRICH, you just provide an HTML element and the scanner will live in there, including controls for camera selection and flashlight (only on Android, unfortunately).
- cpfohl 3y agoWait, didn't iOS recently introduce torch control? I could have sworn that was in the last few months...
- alex_suzuki 3y agoAs of latest iOS 17 Beta it is not yet supported, unfortunately.
- cpfohl 3y agoBarcodeDetector (currently) has pretty poor performance. I'm sure that will eventually be fixed, though. I've had great success with qr-scanner and a web worker, though....
- littlecranky67 3y agoThe wasm-based polyfill I posted works great for me, I use a <video> element to continously scan for QR codes (didn't test with other barcodes, but it is supported by the polyfill). Currently sampling 4 times per second (every 250ms) and it feels no different than a native scanner on the same device. Edit: Just updated my post with the codepen from the polyfill author: https://codepen.io/undecaf/pen/LYzXXzg https://codepen.io/undecaf/pen/LYzXXzg It is butter smooth with EAN barcode when using the builtin webcam on my Macbook (720p on a 2019 MBP16)