Hello Tuan,
I did some experimenting with the built-in scanner and found some settings in the javascript which influence the scanning speed. I do not know if you tried these and rejected them for some reason. The settings apply to the parameters of the Html5QrcodeScanner.
1. In low light conditions the camera of my android (Xiaomi Mi A1) has trouble focusing. The image wanders between sharp and unsharp. The parameter is set to be fps: 1, which means that a scan attempt is done every second. Because there is not much chance that a focused image is available, it can take a long time before a sharp image is send for QR code recognition. I have set fps: 10.
2. I have limited the type of code to recognise to QRcodes only with parameter: formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ]}. Now the software does not attempt to recognise other types of barcodes.
3. Last, i have set it to use the native camera QRcode detection with parameter: experimentalFeatures: {useBarCodeDetectorIfSupported: true}. I understand you would hesitate to use an experimental feature. However, from the associated github comments of the Html5qrcode software I understand that it will soon be supported as a regular feature.
4. Limiting the field of view by setting qrbox: 250 also helps reducing the time for recognising a qrcode. Unfortunately there is still a bug in the software which causes this option to malfunction when rotating the smartphone, so this is a future improvement not recommended now.
5. An other way of limiting the view is using aspectRation: 1.0. This gives a square camera view. Apart from reducing the amount of image to scan, it also makes the buttons below the scan area visible without scrolling.
So, I have altered the statement on my test system as follows:
var html5QrcodeScanner = new Html5QrcodeScanner("reader", {fps: 10, /* qrbox: 250,*/ aspectRatio: 1.0, experimentalFeatures: {useBarCodeDetectorIfSupported: true}, formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ]}, /* verbose= */false);
and the speed of scanning is vastly improved on my low end smartphone, sometimes even instantaneous.
I would like your thoughts about these options.
Also, I would like to introduce the altered javascript on my production system. However do not see a method to override the javascript & do not want to replace the standard version as it will be overwritten with updates. Is it possible to override javascript?
Regards, Frans