#include "tool.h"
#include <QVideoSink>
#include <QVideoFrame>
#include <QDebug>
Tool::Tool(QObject *parent)
: QObject{parent}
{
// qRegisterMetaType<QVideoSink>("QVideoSink");
}
/*!
* \brief Tool::setVideoFrame 设置并处理已获取视频帧
* \param frame 已获取视频帧
*/
void Tool::setVideoFrame(const QVideoFrame frame)
{
qDebug()<<Q_FUNC_INFO<<__LINE__<<frame;
qDebug()<<"1111111111111111"<<frame.toImage();
// const QImage image = frame.toImage();
// //将视频帧放入图像提供者
// ImageProvider::setImage(image);
if(m_videoSink != nullptr)
m_videoSink->setVideoFrame(frame);
}
void Tool::setVideoImage(const QImage image)
{
qDebug()<<Q_FUNC_INFO<<__LINE__<<image;
QVideoFrameFormat frameFormat(image.size(), QVideoFrameFormat::Format_BGRA8888);
QVideoFrame f(frameFormat);
if (f.map(QVideoFrame::WriteOnly)) {
memcpy(f.bits(0), image.bits(), image.sizeInBytes());
f.setStartTime(0);
f.unmap();
qDebug()<<"666666666666"<<f;
if(m_videoSink != nullptr)
m_videoSink->setVideoFrame(f);
}
}
QVideoSink *Tool::videoSink() const
{
return m_videoSink;
}
void Tool::setVideoSink(QVideoSink *newVideoSink)
{
if (m_videoSink == newVideoSink)
return;
m_videoSink = newVideoSink;
emit videoSinkChanged();
}
创建qml自定义视频源(Qt6.3.1+取景器帧)测试源码
版权申诉
5星 · 超过95%的资源 14 浏览量
2022-06-19
21:22:26
上传
评论
收藏 11KB 7Z 举报
꧁白杨树下꧂
- 粉丝: 687
- 资源: 192
最新资源
- Music-Player +PlayerActivity+ rockplayer+ SeeJoPlayer 播放器JAVA源码
- vscode-1.46.0.tar源码文件
- 最近很火植物大战僵尸杂交版2.08苹果+安卓+PC+防闪退工具V2+修改工具+高清工具+通关存档整合包更新
- 超级好用的截图工具PixPin,可录制Gif图
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
- 222222222222
- 16张相机标定图片,可复现本文畸变矫正
- dbeaver-ce-23.3.1-x86_64-setup.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈