How to convert 'QVideoFrame' with YUV data to 'QVideoframe' with RGBA32 data in Qt?

前端 未结 3 1301
一个人的身影
一个人的身影 2021-01-15 13:33

I receive QVideoFrames from webcam, and they contain image data in YUV format (QVideoFrame::Format_YUV420P). How can I convert one

3条回答
  •  没有蜡笔的小新
    2021-01-15 14:20

    https://doc.qt.io/qt-5/qvideoframe.html#map

    if (inputframe.map(QAbstractVideoBuffer::ReadOnly))
    {
        int height = inputframe.height();
        int width = inputframe.width();
        uchar* bits = inputframe.bits();
        // figure out the inputFormat and outputFormat, they should be QImage::Format
        QImage image(bits, width, height, inputFormat);
        // do your conversion
        QImage outImage = image.convertToForma(outFormat); // blah convert
        return QVideoFrame(outImage);
    }
    

提交回复
热议问题