How to improve scanning qr codes?
Running the QR code scanner while your device is running a dev version and tethered to your computer capturing debug data can slow it down. I have an app with a QR scanner that works great in production but shows the same lagging symptoms in the development environment. I can't comment specifically on your project, as it seems like you're doing more than just capturing a QR code, but there is definitely a lag effect from running it in the development environment.
Karol Wiśniewski
Updated on January 04, 2023Comments
-
Karol Wiśniewski over 1 year
I am creating some kind of streaming app. I have open camera and I implemented scanning qr codes in background using https://pub.dev/packages/google_ml_kit
Here is my code for that:
var stream = await navigator.mediaDevices .getUserMedia({'video': true, 'audio': true}); setState(() { _localRenderer.srcObject = stream; }); streamTrack = stream.getVideoTracks().first; await Future.delayed(Duration(seconds: 2)); _getSnapshotTimer = Timer.periodic(Duration(seconds: 1), (timer) async { // skanowanie kodów QR final frame = await streamTrack.captureFrame(); File file = await File('${_tempDir.path}/image.png').create(); file.writeAsBytesSync(frame.asUint8List()); final _qrCodes = await _qrCodeScanner.processImage(InputImage.fromFile(file));
My problem is because of that video from camera is lagging every second. There is like a little freeze. There is some option to improve this? To make video from camera smooth all time?