convert QVideoFrame to QImage

前端 未结 4 1799
北海茫月
北海茫月 2021-01-12 16:06

I want to get every frames from a QMediaPlayer and convert it to QImage (or cv::Mat)

so I used videoFrameProbed

4条回答
  •  自闭症患者
    2021-01-12 16:49

    You can use QImage's constructor:

     QImage img( currentFrame.bits(),
                 currentFrame.width(),
                 currentFrame.height(),
                 currentFrame.bytesPerLine(),
                 imageFormat);
    

    Where you can get imageFormat from pixelFormat of the QVideoFrame:

     QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(currentFrame.pixelFormat());
    

提交回复
热议问题