从QMediaPlayer视频中提取图像 [英] Extracting image from QMediaPlayer Video

查看:1522
本文介绍了从QMediaPlayer视频中提取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Qt Creator来实现读取视频的应用程序,通过单击按钮,我将保存正在显示的帧。然后我将使用Opencv处理该帧。

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.

使用QmediaPlayer显示视频,我如何从视频中提取帧?然后我应该能够在Matlab中将该帧转换为Mat图像。

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.

谢谢

推荐答案

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:

processFrame slot:

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

  ...
  process frame
  ...

}

QVideoProbe参考

QVideoFrame参考

您可以使用QVideoFrame :: bits()来处理OpenCV图像

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

这篇关于从QMediaPlayer视频中提取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆