Extracting image from QMediaPlayer Video

。_饼干妹妹 提交于 2019-12-12 04:39:10

问题


i am using Qt Creator to implement an application that reads a video and by clicking on a button i will save the frame that is being showed. Then i will process that frame with Opencv.

Having a video being displayed with QmediaPlayer, how can i extract a frame from the video? I should then be able to convert that frame to a Mat image in Matlab.

Thanks


回答1:


QMediaPlayer *player = new QMediaPlayer();
QVideoProbe *probe = new QVideoProbe;

connect(probe, SIGNAL(videoFrameProbed(QVideoFrame)), this, SLOT(processFrame(QVideoFrame)));

probe->setSource(player); // Returns true, hopefully.

processFrame slot:

void processFrame(QVideoFrame const&) {
  if (isButtonClicked == false) return;
  isButtonClicked = false;

  ...
  process frame
  ...

}

QVideoProbe reference

QVideoFrame reference

You can use QVideoFrame::bits() to process image with OpenCV



来源:https://stackoverflow.com/questions/35293893/extracting-image-from-qmediaplayer-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!