how to read frame width of video in cv2

Solutions on MaxInterview for how to read frame width of video in cv2 by the best coders in the world

showing results for - "how to read frame width of video in cv2"
Sofie
13 Nov 2018
1import cv2
2
3vcap = cv2.VideoCapture('video.avi') # 0=camera
4 
5if vcap.isOpened(): 
6    # get vcap property 
7    width  = vcap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)   # float `width`
8    height = vcap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)  # float `height`
9    # or
10    width  = vcap.get(3)  # float `width`
11    height = vcap.get(4)  # float `height`
12
13    # it gives me 0.0 :/
14    fps = vcap.get(cv2.cv.CV_CAP_PROP_FPS)
15