QT笔记 您所在的位置:网站首页 捕获视频是什么意思 QT笔记

QT笔记

2023-08-09 07:12| 来源: 网络整理| 查看: 265

说明

        QAbstractVideoSurface类是一个抽象基类,通过实现它的派生类可以获取来自QMediaPlayer或QCamera视频的帧。原理是视频数据的帧流会被引入到QAbstractVideoSurface类的present()函数中,通过该类可获取视频中的所有的帧,因此可以在读取或编辑这些帧,然后再输出到视图中。

        QAbstractVideoSurface类下的有两个纯虚函数supportedPixelFormats()和present(),前者用于向Qt返回帧流的图像类型,后者可获取到每一帧。

函数

virtual QList QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const = 0

virtual bool QAbstractVideoSurface::present(const QVideoFrame & frame) = 0

释义 返回支持的像素格式,格式由枚举类型QVideoFrame::PixelFormat指定。当前帧。视频每加载一帧都会调用一次该函数,形参frame存储有当前帧的数据。 示例

        为抽象基类QAbstractVideoSurface设计派生类。

        首先必须重写两个纯虚函数supportedPixelFormats()和present(),之后需要将QVideoFrame类型的帧转化为QImage类型。

        示例并没有在派生类的present()函数中直接将QVideoFrame转化为QImage类型,而是把前者作为信号发送了出去。

class VideoSurface : public QAbstractVideoSurface { Q_OBJECT public: VideoSurface(QObject * parent = Q_NULLPTR); QList supportedPixelFormats( QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const; private slots: bool present(const QVideoFrame & frame); signals: void presentframe_(const QVideoFrame & frame); }; QList VideoSurface::supportedPixelFormats( QAbstractVideoBuffer::HandleType type) const { if(type == QAbstractVideoBuffer::NoHandle) { return QList()


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有