Reputation: 71
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..
Upvotes: 0
Views: 302
Reputation: 21
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
Upvotes: 1