I receive QVideoFrames
from webcam, and they contain image data in YUV format (QVideoFrame::Format_YUV420P
). How can I convert one
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);
}