如何改进二维码扫描?
我正在创建某种流媒体应用程序。 我打开了相机,并使用 https://pub.dev/packages/google_ml_kit
这是我的代码:
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));
我的问题是因为来自摄像机的视频每秒都滞后。有一点像冻结。 有一些选项可以改进这个吗?想让摄像头拍摄的视频始终流畅?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您的设备正在运行开发版本并连接到捕获调试数据的计算机时运行 QR 码扫描仪可能会减慢速度。我有一个带有二维码扫描仪的应用程序,它在生产中运行良好,但在开发环境中显示出相同的滞后症状。我无法具体评论您的项目,因为您似乎所做的不仅仅是捕获二维码,但在开发环境中运行它肯定会产生滞后效应。
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.