我从网络摄像头接收QVideoFrames
,它们包含YUV format (QVideoFrame::Format_YUV420P
)格式的图像数据。如何将这样的帧转换为QVideoFrame::Format_ARGB32
或QVideoFrame::Format_RGBA32
的帧?
我可以不使用Qt5中现有的功能,而不进行低级别的操作吗?
示例:
QVideoFrame convertFormat(const QVideoFrame &inputframe, QVideoFrame::PixelFormat outputFormat)
{
// What comes here?
}
//Usage
QVideoFrame converted = convertFormat(mySourceFrame, QVideoFrame::Format_RGB32);
发布于 2017-03-29 23:56:26
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);
}
https://stackoverflow.com/questions/43106069
复制相似问题