强制Qt相机视频格式
Force Qt Camera video format
我正在尝试使用QML的Qt Camera。
我正在开发一个自定义视频过滤器:
QVideoFrame MyFilterRunnable::run(QVideoFrame* input, const QVideoSurfaceFormat&, RunFlags)
我开始在Windows上部署应用程序,我有:
- 帧可在
QAbstractVideoBuffer::ReadWrite
中映射 - 帧像素格式
PixelFormat::Format_BGR32
不幸的是,当我迁移到 Linux 时,一切都变了,但没有改变我拥有的相机:
- 框架仅
QAbstractVideoBuffer::ReadOnly
- 帧像素格式
PixelFormat::Format_YUYV
现在我真的不知道如何将这个框架转换为 OpenCVMat
.
有没有办法选择相机的像素格式?
就在史蒂文,
if (input->pixelFormat() == QVideoFrame::Format_YUYV)
{
auto input_w = input->width ();
auto input_h = input->height();
auto cam_data = input->bits();
cv::Mat yuyv(input_h, input_w,CV_8UC2, cam_data);
cv::Mat rgb (input_h, input_w,CV_8UC3);
cvtColor(yuyv, rgb, CV_YUV2BGR_YUYV);
m_mat = rgb;
}
else
if (input->pixelFormat() == QVideoFrame::Format_YUV420P || input->pixelFormat() == QVideoFrame::Format_NV12) {
m_yuv = true;
m_mat = yuvFrameToMat8(*input);
} else {
m_yuv = false;
QImage wrapper = imageWrapper(*input);
if (wrapper.isNull()) {
if (input->handleType() == QAbstractVideoBuffer::NoHandle)
input->unmap();
return *input;
}
m_mat = imageToMat8(wrapper);
}
ensureC3(&m_mat);
我在Linux机器和Raspberry之间遇到了同样的问题:我使用相同的相机,QVideoFrame给出的像素格式也不同。它可能与 v4l2 有关
关于从YUYV到OpenCV Mat的转换,这段代码对我有用:
QVideoFrame *input ;
...
auto input_w = input->width ();
auto input_h = input->height();
auto cam_data = input->bits();
cv::Mat yuyv(input_h, input_w,CV_8UC2, cam_data);
cv::Mat rgb (input_h, input_w,CV_8UC3);
cvtColor(yuyv, rgb, CV_YUV2BGR_YUYV);
相关文章:
- 如何在openssl-ecc中获取十六进制格式的私钥
- 将"打开的CV图像"中的"颜色"转换为整数格式
- TDateTime格式在C++Builder中不会更改
- 如何防止clang格式在流运算符调用之间添加换行符<<
- 检查不带转换的扫描格式
- 如何在c++中录制具有精确帧时间戳的视频
- 当我尝试使用 sstream 和分面将 Boost Time_duration转换为字符串时,我没有得到所需的格式
- 是否可以从格式字符串中检索"width"
- clang格式:宏的缩进
- clang格式:禁用排序包含
- 在用于格式4的arm模拟器中实现功能时的一个问题
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- 强制Qt相机视频格式
- 为什么更改视频格式会更改其像素值?
- 开源或低成本的跨平台视频编解码器库,可用于商业目的,并支持RGBA格式
- 如何在OpenCV中设置相机的视频格式?CAP_PROP_FOURCC不起作用
- 如何以灰度格式读取视频文件
- 如何分析文件,判断文件是否为H.264视频格式?
- 如何在特定文件中检查(控制).avi格式的视频文件,它是否超过0KB且可读
- 是否可以以ITU-R BT.656格式流式传输视频