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 –寫入幀 函數/方法將指定的圖像寫入視頻文件。它的大小必須與打開視頻編寫器時指定的大小相同。
|