0

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..

UbiMiles
  • 71
  • 7

1 Answers1

1

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

mcisse
  • 21
  • 3
  • I did not find any alternative which eventually got me to ditch QML and get back to Qt widgets, I am capturing my pylonImage, converting it to a QImage and setting the pixmap of it to a label to preview it , I found this approach way more efficient – UbiMiles Apr 01 '22 at 13:04