Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to get properties of Python cv2.VideoCapture object ?

  • Last Updated : 25 Nov, 2021

Let us see how we can get the properties from the cv2.VideoCapture objects and understand how they work. cv2.VideoCapture is a function of openCV library(used for computer vision, machine learning, and image processing) which allows working with video either by capturing via live webcam or by a video file. To know more about this function, refer to this link.  


Before we start, make sure to install the OpenCV library on Python 3.X. You can install these using the pip command:

pip install opencv-python

Properties of cv2.VideoCapture Object

By knowing the properties of the cv2.VideoCapture object facilitates to do Video Processing ultimately by doing processing on the frames. 

1) Width: This property is used to get the width of the frames in the video stream.  The measuring unit is in pixels. 


2) Height: This property is used to get the height of the frames in the video stream. The measuring unit is in pixels.


3) Fps: FPS stands for frames per second. This property is used to get the frame rate of the video.

Syntax: cv2.CAP_PROP_FPS

4) Current Position: This property is used to find what is the current position of the video, its measuring unit is milliseconds.


5) Total number of frame: This property is used to calculate the total number of frames in the video file.


6) Brightness: This property is not for video files. It only works with a camera or webcam. Used to find out the brightness.


7) Contrast: This property also works with the camera or webcam only. Used to find out the contrast on images captured.


8) Saturation Value: This is used to get the saturation of live frames capturing via cameras. This also doesn’t work on the video file.


9) HUE Value: This is for knowing the HUE value of the image. Only for cameras.

Syntax: cv2.CAP_PROP_HUE

10) GAIN:  This property is used to get the gain of the image. Wouldn’t work with the video file, simply return “0” if applied on a video file.

Syntax: cv2.CAP_PROP_GAIN

11) Need to convert into RGB: This property returns a Boolean value which indicates whether the images should be converted to RGB colorspace or not.


These properties will be much clear on using these directly on the code. Here’s its implementation:


# importing cv2
import cv2
#For Video File
#For webcam
# showing values of the properties
print("CV_CAP_PROP_FRAME_WIDTH: '{}'".format(capture.get(cv2.CAP_PROP_FRAME_WIDTH)))
print("CV_CAP_PROP_FRAME_HEIGHT : '{}'".format(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
print("CAP_PROP_FPS : '{}'".format(capture.get(cv2.CAP_PROP_FPS)))
print("CAP_PROP_POS_MSEC : '{}'".format(capture.get(cv2.CAP_PROP_POS_MSEC)))
print("CAP_PROP_FRAME_COUNT  : '{}'".format(capture.get(cv2.CAP_PROP_FRAME_COUNT)))
print("CAP_PROP_BRIGHTNESS : '{}'".format(capture.get(cv2.CAP_PROP_BRIGHTNESS)))
print("CAP_PROP_CONTRAST : '{}'".format(capture.get(cv2.CAP_PROP_CONTRAST)))
print("CAP_PROP_SATURATION : '{}'".format(capture.get(cv2.CAP_PROP_SATURATION)))
print("CAP_PROP_HUE : '{}'".format(capture.get(cv2.CAP_PROP_HUE)))
print("CAP_PROP_GAIN  : '{}'".format(capture.get(cv2.CAP_PROP_GAIN)))
print("CAP_PROP_CONVERT_RGB : '{}'".format(capture.get(cv2.CAP_PROP_CONVERT_RGB)))
# release window

Output is as follows (For webcam):

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!