How to get rid of the delay when opening the camera?
Version 10
1. Invoke loadWasm
Preload BarcodeReader
or other specified module proactively to save time on the initial decoding by skipping the module loading at the time of instance creation.
await Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
2. skip camera inspection
You can bypass the camera selectionifSkipCameraInspection
cameraEnhancer.ifSkipCameraInspection
3. Pre-open camera in advance
Run the following code before calling createInstance
.
navigator.mediaDevices.getUserMedia({video: true}).then(mediaStream=>{
mediaStream.getTracks().forEach((track) => {
track.stop();
});
}, err=>{});
Version 9
1. Invoke loadWasm in advance
Dynamsoft.DBR.BarcodeReader.loadWasm();
2. Pre-open the camera in advance
Run the following code before calling createInstance
.
navigator.mediaDevices.getUserMedia({video: true}).then(mediaStream=>{
mediaStream.getTracks().forEach((track) => {
track.stop();
});
}, err=>{});
3. Skip Camera inspection(use default camera)
scanner.ifSkipCameraInspection = true;