日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

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

發布時間:2023/11/28 生活经验 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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:

· 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值(注意:當前僅受DC1394v 2.x后端支持)

CV_CAP_PROP_WHITE_BALANCE_V設置白平衡的V值(注意:當前僅受DC1394V 2.x后端支持)

CV_CAP_PROP_RECTIFICATION立體攝像機的校正標志(注:目前僅受DC1394 v 2.x后端支持)

CV_CAP_PROP_ISO_SPEED相機的ISO速度(注意:當前僅受DC1394v 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]]) →

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(CvVideoWriterwriter, 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读写视频文件解析(二)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。