如何改进二维码扫描?

发布于 2025-01-14 00:59:29 字数 909 浏览 1 评论 0原文

我正在创建某种流媒体应用程序。 我打开了相机,并使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2025-01-21 00:59:29

当您的设备正在运行开发版本并连接到捕获调试数据的计算机时运行 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文