I use OpenCV to do some calculations in films that I did in my experiments. To do this, I need some properties from the films, and it would be convenient if I could automatically detect them from the film itself. In the documentation, I found the following code:
cv2.VideoCapture.get(propId) → retval
The list below indicates that for the total number of frames, propId must be CV_CAP_PROP_FRAME_WIDTH . However, when I try to do the following, I get an error:
>> cap = cv2.VideoCapture('runoff.MOV') >> print cap.get('CV_CAP_PROP_FRAME_WIDTH') TypeError: an integer is required
If I enter an integer in the code:
>> cap = cv2.VideoCapture('runoff.MOV') >> print cap.get(3) 1920.0
CV_CAP_PROP_FRAME_WIDTH is the 4th item in the list in the documentation, and indeed, when I use the correct integer counter 3 , I get this property. I wonder if there is an easier way to do this, using the class itself and writing a dictionary for it with all combinations of keys and integers.
source share