如何从 PylonImage 缓冲区生成 QVideoFrame

发布于 2025-01-13 08:55:30 字数 285 浏览 2 评论 0原文

我有一个 pylon 图像流,我想在 QML 应用程序中向用户显示,如何将 PylonImage 转换为 QVideoFrame 以便我可以显示它?

我使用的是 PixelType_YUV422planar,因为 pylonImages 和 QVideoFrames 都支持它。 但我不知道如何从塔图像中获取 QVideoFrame?

我将用 memcpy 进行一些实验,但我想知道是否还有其他方法..

编辑: 使用 memcpy 将 pylonImage 的缓冲区复制到 QVideoFrame 会导致图像扭曲。

I have a stream of pylon images that I would like to display to a user in a QML app, how can I convert the PylonImage to a QVideoFrame so I can display it?

I am using PixelType_YUV422planar since it is supported by both pylonImages and QVideoFrames.
yet I'm clueless on how can I get the QVideoFrame from the pylon image?

I will experiment a bit with memcpy but I would like to know if there's any other way..

edit:
copying the buffer of pylonImage to the QVideoFrame using memcpy results in distorted image..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

梦幻的味道 2025-01-20 08:55:30

memcpy 方法效果很好。请参考:
https://blog.katastros.com/a?ID= 9f708708-c5b3-4cb3-bbce-400cc8b8000c
有趣的代码发布:

QVideoFrame f(size, QSize(width, height), width, QVideoFrame::Format_YUV420P);
if (f.map(QAbstractVideoBuffer::WriteOnly)) {
    memcpy(f.bits(), data, size);
    f.setStartTime(0);
    f.unmap();
    emit newFrameAvailable(f);
}

我自己制作了 memcpy 示例来进行 v4l2 视频捕获工作,但是 memcpy 成本太高,它导致我的帧速率从 34fps 下降到 6 fps,并且 CPU 使用率为 100%(4K 实时视频)。
你能找到 memcpy 的替代品吗?
谢谢

The memcpy approach works very well. Please refer to:
https://blog.katastros.com/a?ID=9f708708-c5b3-4cb3-bbce-400cc8b8000c
The interesting code shiped:

QVideoFrame f(size, QSize(width, height), width, QVideoFrame::Format_YUV420P);
if (f.map(QAbstractVideoBuffer::WriteOnly)) {
    memcpy(f.bits(), data, size);
    f.setStartTime(0);
    f.unmap();
    emit newFrameAvailable(f);
}

I made the memcpy example work myself to make a v4l2 video capture work however memcpy is too costly and it is causing my framerates to drop from 34fps to 6 fps and CPU usage is at 100% (4K live video).
Could you find any alternatives to memcpy?
Thx

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