OpenCV读写视频文件解析(二)

VideoCapture::set

设置视频捕获中的属性。

C++:bool VideoCapture::set(int propId, double value)

Python:cv2.VideoCapture.set(propId, value) → retval

C:int cvSetCaptureProperty(CvCapture* capture, int property_id, double value)

Python:cv.SetCaptureProperty(capture, property_id, value) → retval

Parameters:

  • propId

Property identifier. It can be one of the following:

o   CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.

o   CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.

o   CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file: 0 - start of the film, 1 - end of the film.

o   CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.

o   CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.

o   CV_CAP_PROP_FPS Frame rate.

o   CV_CAP_PROP_FOURCC 4-character code of codec.

o   CV_CAP_PROP_FRAME_COUNT Number of frames in the video file.

o   CV_CAP_PROP_FORMAT Format of the Mat objects returned by retrieve() .

o   CV_CAP_PROP_MODE Backend-specific value indicating the current capture mode.

o   CV_CAP_PROP_BRIGHTNESS Brightness of the image (only for cameras).

o   CV_CAP_PROP_CONTRAST Contrast of the image (only for cameras).

o   CV_CAP_PROP_SATURATION Saturation of the image (only for cameras).

o   CV_CAP_PROP_HUE Hue of the image (only for cameras).

o   CV_CAP_PROP_GAIN Gain of the image (only for cameras).

o   CV_CAP_PROP_EXPOSURE Exposure (only for cameras).

o   CV_CAP_PROP_CONVERT_RGB Boolean flags indicating whether images should be converted to RGB.

o   CV_CAP_PROP_WHITE_BALANCE_U The U value of the whitebalance setting (note: only supported by DC1394 v 2.x backend currently)

o   CV_CAP_PROP_WHITE_BALANCE_V The V value of the whitebalance setting (note: only supported by DC1394 v 2.x backend currently)

o   CV_CAP_PROP_RECTIFICATION Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)

o   CV_CAP_PROP_ISO_SPEED The ISO speed of the camera (note: only supported by DC1394 v 2.x backend currently)

o   CV_CAP_PROP_BUFFERSIZE Amount of frames stored in internal buffer memory (note: only supported by DC1394 v 2.x backend currently)

  • value – Value of the property.

参数:

propId -属性标识符。它可以是下列之一:

CV_CAP_PROP_POS_MSEC视频文件的当前位置(毫秒)。

CV_CAP_PROP_POS_FRAMES下一个要解码/捕获的帧的基于0的索引。

CV_CAP_PROP_POS_AVI_RATIO视频文件的相对位置:0-胶片开始,1-胶片结束。

CV_CAP_PROP_FRAME_WIDTH视频流中帧的宽度。

CV_CAP_PROP_FRAME_HEIGHT视频流中帧的高度。

CV_CAP_PROP_FPS帧速率。

CV_CAP_PROP_FOURCC编解码器的4个字符代码。

CV_CAP_PROP_FRAME_COUNT视频文件中的帧数。

CV_CAP_PROP_FORMAT retrieve()返回的Mat对象格式。

CV_CAP_PROP_MODE后端特定值,指示当前捕获模式。

CV_CAP_PROP_BRIGHTNESS 图像亮度(仅适用于相机)。

CV_CAP_PROP_CONTRAST图像的对比度(仅适用于相机)。

CV_CAP_PROP_SATURATION图像饱和度(仅适用于相机)。

CV_CAP_PROP_HUE  图像的色调(仅适用于相机)。

CV_CAP_PROP_GAIN图像的增益(仅适用于相机)。

CV_CAP_PROP_EXPOSURE曝光(仅适用于相机)。

CV_CAP_PROP_CONVERT_RGB布尔标志,指示是否应将图像转换为RGB。

CV_CAP_PROP_WHITE_BALANCE_U设置白平衡的U值(注意:当前仅受DC1394 v 2.x后端支持)

CV_CAP_PROP_WHITE_BALANCE_V设置白平衡的V值(注意:当前仅受DC1394 V 2.x后端支持)

CV_CAP_PROP_RECTIFICATION立体摄像机的校正标志(注:目前仅受DC1394 v 2.x后端支持)

CV_CAP_PROP_ISO_SPEED相机的ISO速度(注意:当前仅受DC1394 v 2.x后端支持)

CV_CAP_PROP_BUFFERSIZE存储在内部缓冲存储器中的帧数量(注意:当前仅受DC1394 v 2.x后端支持)

value–属性的值。

VideoWriter

class VideoWriter

Video writer class.

VideoWriter::VideoWriter

VideoWriter constructors构造

C++:VideoWriter::VideoWriter()

C++:VideoWriter::VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true)

Python:cv2.VideoWriter([filename, fourcc, fps, frameSize[, isColor]]) → <VideoWriter object>

C:CvVideoWriter* cvCreateVideoWriter(const char* filename, int fourcc, double fps, CvSize frame_size, int is_color=1 )

Python:cv.CreateVideoWriter(filename, fourcc, fps, frame_size, is_color=true) → CvVideoWriter

Python:cv2.VideoWriter.isOpened() → retval

Python:cv2.VideoWriter.open(filename, fourcc, fps, frameSize[, isColor]) → retval

Python:cv2.VideoWriter.write(image) → None

Parameters:

  • filename – Name of the output video file.
  • fourcc – 4-character code of codec used to compress the frames. For example,
  • CV_FOURCC('P','I','M','1') is a MPEG-1 codec,
  • CV_FOURCC('M','J','P','G') is a motion-jpeg codec etc. List of codes can be obtained at Video Codecs by FOURCC page.
  • fps – Framerate of the created video stream.
  • frameSize – Size of the video frames.
  • isColor – If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only).
  • 参数:
  • file Name–输出视频文件的名称。
  • fourcc–用于压缩帧的编解码器的4字符代码。例如,CV_FOURCC('P','I','M','1')是MPEG-1编解码器,CV_FOURCC('M','J','P','G')是运动jpeg编解码器等。可通过FOURCC页面在视频编解码器处获得代码列表。
  • fps–创建的视频流的帧速率。
  • frameSize–视频帧的大小。
  • isColor–如果不为零,编码器将期望并编码彩色帧,否则将使用灰度帧(该标志当前仅在Windows上受支持)。
  • 构造函数/函数初始化视频写入程序。在Linux上,FFMPEG用于编写视频;在Windows上,FFMPEG或VFW用于编写视频;在MacOSX上,QTKit用于编写视频。
  • ReleaseVideoWriter
  • 释放AVI writer。
  • C:void cvReleaseVideoWriter(CvVideoWriter** writer)
  • The function should be called after you finished using CvVideoWriter opened with CreateVideoWriter().
  • 在使用完用CreateVideoWriter()打开的CvVideoWriter之后,应该调用该函数。
  • VideoWriter::open
  • 初始化或重新初始化视频编写器。

C++:bool VideoWriter::open(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true)

Python:cv2.VideoWriter.open(filename, fourcc, fps, frameSize[, isColor]) → retval

  • The method opens video writer. Parameters are the same as in the constructor
  • VideoWriter::VideoWriter()
  • 该方法打开视频编写器。参数与构造函数VideoWriter::VideoWriter()中的参数相同。
  • VideoWriter::isOpened
  • 如果已成功初始化视频编写器,则返回true。

C++:bool VideoWriter::isOpened()

Python:cv2.VideoWriter.isOpened() → retval

VideoWriter::write

写入下一个视频帧

C++:VideoWriter& VideoWriter::operator<<(const Mat& image)

C++:void VideoWriter::write(const Mat& image)

Python:cv2.VideoWriter.write(image) → None

C:int cvWriteFrame(CvVideoWriter* writer, const IplImage* image)

Python:cv.WriteFrame(writer, image) → int

Parameters:

  • writer – Video writer structure (OpenCV 1.x API)
  • image – The written frame

参数:

writer—视频编写器结构(OpenCV 1.x API)

image –写入帧

函数/方法将指定的图像写入视频文件。它的大小必须与打开视频编写器时指定的大小相同。

OpenCV读写视频文件解析(二)的更多相关文章

  1. OpenCV读写视频文件解析

    OpenCV读写视频文件解析 一.视频读写类 视频处理的是运动图像,而不是静止图像.视频资源可以是一个专用摄像机.网络摄像头.视频文件或图像文件序列. 在 OpenCV 中,VideoCapture ...

  2. opencv打开视频文件出错

    使用C#调用mingw的so文件,在C++端使用opencv打开视频.这样的项目完成过了一个,第二次做的时候,发现opencv打开视频文件出错. 首先怀疑是opencv的opencv_ffmpeg24 ...

  3. ffmpeg和opencv 播放视频文件和显示器

    ffmpeg它是基于最新版本,在官网下载http://ffmpeg.zeranoe.com/builds/.编译时VS2010配置相关头文件及库的路径就可以.opencv的搭建參考上一个博客. 首先简 ...

  4. 【VS开发】【计算机视觉】OpenCV读写xml文件《C++版本》

    OpenCV FileStorage类读写XML/YML文件 在OpenCV程序中,需要保存中间结果的时候常常会使用.xml / .yml文件,opencv2.0之前都是使用C风格的代码,当时读写XM ...

  5. OpenCV读写视频操作

    一.读取视频流 在使用OpenCV读取摄像头,或者处理一些磁盘中保存的视频文件时,通常使用VideoCapture进行读取. std::string video_path("/path/to ...

  6. 【python下使用OpenCV实现计算机视觉读书笔记3】读写视频文件

    代码例如以下: import cv2 videoCapture = cv2.VideoCapture('car.avi') fps = videoCapture.get(cv2.cv.CV_CAP_P ...

  7. 【VS开发】【计算机视觉】OpenCV读写xml文件《C版本》

    一些简单的XML读写操作,记之于笔记以备忘 主要功能: 1. 创建XML 2. 向XML中存储或者是读取Int float型基本数据 3. 通过创建XML元素,存取复杂的结构如:结构体.矩阵 代码如下 ...

  8. 音频文件解析(二):WAV格式文件波形绘制

    解析WAV头部信息后,接下来就可以根据相关参数和DATA块数据绘制波形. 1.重新编码(转换为8bits,单声道数据) Public Function GetFormatData(ByVal pDat ...

  9. 歌词文件解析(二):LRC格式文件的绘制

    通过对LRC文件的解析,可以轻松实现歌词可视化. 代码实现 函数名: paintLyrics(ByVal pBox As PictureBox, ByVal CurrentPosition As In ...

随机推荐

  1. .NET 5学习笔记(12)——WinUI 3 Project Reunion 0.5

    2021年3月的时候,Win UI 3终于来到了第一个稳定的支持版本,可用于创建发布到Micosoft Store的应用.据某软的说法,这个叫WinUI 3 Project Reunion 0.5的版 ...

  2. hdu5040 不错的广搜

    题意:       给你一个地图,让你从起点走到终点,然后图上有空地,墙,还有摄像头,摄像头有初始方向,每一秒摄像头都会顺时针旋转90度,每个摄像头有自己的观察范围,它所在的点,和当前它面向的那个点, ...

  3. Host头部攻击

    在HTTP的请求报文中,我们经常会看到Host字段,如下 GET /test/ HTTP/1.1 Host: www.baidu.com Connection: keep-alive Upgrade- ...

  4. 利用DNS进行命令控制和搭建隧道

    目录 利用DNS进行命令控制(DNS-Shell) 利用DNS搭建隧道 利用DNS进行命令控制(DNS-Shell) DNS-Shell是一款通过DNS信道实现交互式Shell的强大工具,该工具的服务 ...

  5. 接口测试原理及Postman详解

    接口测试定义 接口是前后端沟通的桥梁,是数据传输的通道,包括外部接口.内部接口.内部接口又包括:上层服务与下层服务接口,同级接口 生活中常见接口:电脑上的键盘.USB接口,电梯按钮,KFC下单 接口测 ...

  6. SwiftUI 简明教程之指示器

    本文为 Eul 样章,如果您喜欢,请移步 AppStore/Eul 查看更多内容. Eul 是一款 SwiftUI & Combine 教程 App(iOS.macOS),以文章(文字.图片. ...

  7. 线程安全(ThreadSafety)

    这节讲一下线程安全的例子,以及如何解决线程安全问题. 上节提到了线程安全的问题,说了一个例子,1000个人抢100张票,这节就从此案例着手,下面先看一下代码实现: private static int ...

  8. 改善c++程序的150个建议(读后总结)-------0-9

    0. 不要让main 函数返回 void 入口函数main()返回类型应该为 int, 即程序结束时return 0 表示程序正常返回,函数结束时 return -1 值表示程序异常返回, 如果不显式 ...

  9. SE_Work1_阅读构建之法&项目管理实践

    项目 内容 课程:北航-2020-春-软件工程 博客园班级博客 要求:阅读<构建之法>并回答问题 个人博客作业 我在这个课程的目标是 提升团队管理及合作能力,开发一项满意的工程项目 这个作 ...

  10. 5.配置IP

    静态IP配置 1.NAT模式设置 首先设置虚拟机中NAT模式的选项,打开VMware,点击"编辑"下的"虚拟网络编辑器",设置NAT参数 注意: VMware ...