OpenCV MJPG格式高速读取
更新声明:Ubuntu下测试可以直接到120fps,设定60fps读出来也是120…
大部分应用场景要求很强的实时性,所谓实时,不一定是“及时”,而是周期确定,在一般的场景还要求周期尽可能短(如伺服系统)
查阅相机手册,发现MJPG格式可以高速输出高分辨率图像,因此读取时设定这个格式。查阅很多blog,可能是版本问题,函数参数有所不同,一直没有work,特此分享自己开发环境下的设置方法。
if (capture.isOpened())capture.release(); //decide whether capture is already opened; if so,close itcapture.open(0); //open the default cameracapture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G')) ;capture.set(CAP_PROP_FPS, 60);capture.set(CAP_PROP_FRAME_WIDTH, ImgWidth);capture.set(CAP_PROP_FRAME_HEIGHT, ImgHeight);
与此同时,给出其他参数的设置指南,以下代码摘抄自OpenCV - videoio.hpp
/** @brief %VideoCapture generic properties identifier.Reading / writing properties involves many layers. Some unexpected result might happens along this chain.Effective behaviour depends from device hardware, driver and API Backend.@sa videoio_flags_others, VideoCapture::get(), VideoCapture::set()
*/
enum VideoCaptureProperties {CAP_PROP_POS_MSEC =0, //!< Current position of the video file in milliseconds.CAP_PROP_POS_FRAMES =1, //!< 0-based index of the frame to be decoded/captured next.CAP_PROP_POS_AVI_RATIO =2, //!< Relative position of the video file: 0=start of the film, 1=end of the film.CAP_PROP_FRAME_WIDTH =3, //!< Width of the frames in the video stream.CAP_PROP_FRAME_HEIGHT =4, //!< Height of the frames in the video stream.CAP_PROP_FPS =5, //!< Frame rate.CAP_PROP_FOURCC =6, //!< 4-character code of codec. see VideoWriter::fourcc .CAP_PROP_FRAME_COUNT =7, //!< Number of frames in the video file.CAP_PROP_FORMAT =8, //!< Format of the %Mat objects returned by VideoCapture::retrieve().CAP_PROP_MODE =9, //!< Backend-specific value indicating the current capture mode.CAP_PROP_BRIGHTNESS =10, //!< Brightness of the image (only for those cameras that support).CAP_PROP_CONTRAST =11, //!< Contrast of the image (only for cameras).CAP_PROP_SATURATION =12, //!< Saturation of the image (only for cameras).CAP_PROP_HUE =13, //!< Hue of the image (only for cameras).CAP_PROP_GAIN =14, //!< Gain of the image (only for those cameras that support).CAP_PROP_EXPOSURE =15, //!< Exposure (only for those cameras that support).CAP_PROP_CONVERT_RGB =16, //!< Boolean flags indicating whether images should be converted to RGB.CAP_PROP_WHITE_BALANCE_BLUE_U =17, //!< Currently unsupported.CAP_PROP_RECTIFICATION =18, //!< Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently).CAP_PROP_MONOCHROME =19,CAP_PROP_SHARPNESS =20,CAP_PROP_AUTO_EXPOSURE =21, //!< DC1394: exposure control done by camera, user can adjust reference level using this feature.CAP_PROP_GAMMA =22,CAP_PROP_TEMPERATURE =23,CAP_PROP_TRIGGER =24,CAP_PROP_TRIGGER_DELAY =25,CAP_PROP_WHITE_BALANCE_RED_V =26,CAP_PROP_ZOOM =27,CAP_PROP_FOCUS =28,CAP_PROP_GUID =29,CAP_PROP_ISO_SPEED =30,CAP_PROP_BACKLIGHT =32,CAP_PROP_PAN =33,CAP_PROP_TILT =34,CAP_PROP_ROLL =35,CAP_PROP_IRIS =36,CAP_PROP_SETTINGS =37, //!< Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. The property value is ignored)CAP_PROP_BUFFERSIZE =38,CAP_PROP_AUTOFOCUS =39,CAP_PROP_SAR_NUM =40, //!< Sample aspect ratio: num/den (num)CAP_PROP_SAR_DEN =41, //!< Sample aspect ratio: num/den (den)CAP_PROP_BACKEND =42, //!< Current backend (enum VideoCaptureAPIs). Read-only propertyCAP_PROP_CHANNEL =43, //!< Video input or Channel Number (only for those cameras that support)CAP_PROP_AUTO_WB =44, //!< enable/ disable auto white-balanceCAP_PROP_WB_TEMPERATURE=45, //!< white-balance color temperature
#ifndef CV_DOXYGENCV__CAP_PROP_LATEST
#endif};
设置格式和分辨率那些一样,不知道填什么的时候就跳转过来看一下提示~
具体的数值,就看各位具体需求了!
OpenCV MJPG格式高速读取相关推荐
- python3 opencv 视频格式转换
python3 opencv 视频格式转换: import cv2 #获得视频的格式 videoCapture = cv2.VideoCapture('ad3.avi') #获得码率及尺寸 fps = ...
- 树莓派MJPG-Streamer输出MJPG格式的白屏问题
树莓派MJPG-Streamer输出MJPG格式的白屏问题及帧率太低解决方案 问题描述: 使用树莓派搭建网络视频摄像头时,MJPG-Streamer是大家常用的方案.设备默认的输出YUYV格式的图片帧 ...
- OpenCV+V4L实现MJPG格式拉取USB摄像头
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.为什么YUV帧数低? 二.OpenCV+V4l编译 1.安装必要环境 2.下载源代码 3.开始编译 3.测试代码 ...
- OpenCV 视频流格式----avi与mp4区别
OpenCV python code, GitHub项目,中路径OpenCVDemo/OpenCvPythonDemo/VlogHelper/CreateVideo.py // 我用的mac,发现用X ...
- opencv——PNG格式图像读取转换函数
暑假培训学习了opencv,放图像时,PNG格式的Alpha通道没用啊图都自己去p颜色,用来加载时变颜色 工作量太大了,,于是花了一下午弄了个简易功能的PNG格式文件读取转化加载函数. 注:这里主要是 ...
- android mjpg格式,android下mjpeg格式硬解码
附件需要在android目录下编译,生成的so可以在ndk使用,支持yuyv/nv12/rgba3种格式 external/skia也需要略作修改 diff --git a/include/core/ ...
- Opencv(4) RGB, YUV, GRAY像素格式介绍opencv像素格式转换cvtColor接口
像素格式和灰度图 RGB: RGB色彩模式是工业界的一种颜色标准,是通过对红(R).绿(G).蓝(B)三个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色的,RGB即是代表红.绿.蓝三个通道的 ...
- python opencv以MJPG读取usb摄像头
python下使用opencv以MJPG读取usb摄像头 修改格式的原因 用 cap = cv2.VideoCapture(1)打开usb双目摄像头时发现帧率很低,使用cap.set(cv2.CAP_ ...
- OpenCV 笔记(07)— Mat 对象输出格式设置(Python 格式、CSV 格式、NumPy 格式、C 语言格式)
首先是下面代码中将要使用的 r 矩阵的定义.需要注意,我们可以通过用 randu 函数产生的随机值来填充矩阵, 需要给定一个上限和下限来确保随机值在期望的范围内. Mat r = Mat(2, 3, ...
最新文章
- 第三波精品Android源码袭来!免费下载
- 闲着无聊去体验远程面试,最后竟然被录取了...
- rtsp交互命令简介及过程参数描述
- iOS App的图标,启动画面及其它
- golang type 说明和使用
- oracle怎么判断地址相似,如何查看oracle数据文件的地址
- Spring常用注解汇总
- k8s高可用集群_搭建高可用集群(初始化和部署keepalived)---K8S_Google工作笔记0055
- ACM--素数距离问题
- 博客园博客美化相关文章目录
- linux安装文泉驿字体,centos 安装文泉驿字体相关教程
- 腾讯云,体验万象优图鉴黄服务
- 我的VSTO之路(三):Word基本知识
- 冉宝的每日一题--8月12日--子序列有进步啦
- Python个人项目2 --------青蛙旅行项目
- SQL UNION运算符
- 卫生事业单位计算机科学与技术,卫生事业单位考试计算机科学与技术学习知识点.docx...
- Vpp和dBm的转换
- 中奖人js滚动效果_jQuery实现中奖播报功能(让文本滚动起来) 简单设置数值即可...
- Mac壁纸精灵Wallpaper Wizard如何保存我喜欢的图片?
热门文章
- android缓存策略跟cdn,缓存学习(五)CDN缓存(下)-CDN缓存策略、CDN缓存和浏览器缓存之间的关系、回源和回源比...
- Qt 窗口属性简介之Qt::WA_DeleteOnClose
- 鲜枣课堂线上课程秋季促销,明天正式开始!
- C# byte数组转string,string转byte数组
- ALL_INDEXES
- Jetpack组件Room简单Demo
- 通达OA 工作流流转过程中使用系统自带的提醒功能设置(图文)
- 通达OA工作流主要表的数据结构
- 谷歌浏览器打不开,点击图标没反应
- 写一首名为《牧星人》的诗