OpenCV读写视频文件解析(二)
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: |
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)
|
参数:
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: |
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
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
参数: writer—视频编写器结构(OpenCV 1.x API) image –写入帧 函数/方法将指定的图像写入视频文件。它的大小必须与打开视频编写器时指定的大小相同。
|
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)