Meaning of VideoCapture prop definitions not in the opencv documentation

35 Views Asked by At

Is there any to tell what the meaning of video capture properties that aren't defined in the official documentation? For example,

import cv2
cap = cv2.VideoCapture(filename)

Video properties can be polled with either: cap.get(cv2.CAP_PROP_FPS) or cap.get(5)

The opencv documentation defines all the props up to 51. But there are metadata properties at index 55, 68, 69 and 70 but they don't have a corresponding definition in the documentation. Are they defined somewhere else? Perhaps in an mp4 or h.264 spec?

1

There are 1 best solutions below

0
cards On

There are more than 200... here a how to list them

import cv2


print(f"{'Counter':<8}{'ID':<8}{'Name'}")
i = 0
for attr in dir(cv2):
    if attr.startswith('CAP_PROP'):
        print(f"{i:<8}{getattr(cv2, attr):<8}{attr}")
        i += 1

Output

Counter ID      Name
0       17008   CAP_PROP_APERTURE
1       600     CAP_PROP_ARAVIS_AUTOTRIGGER
2       63      CAP_PROP_AUDIO_BASE_INDEX
3       61      CAP_PROP_AUDIO_DATA_DEPTH
[...]
24      31      CAP_PROP_DC1394_MAX
25      -2      CAP_PROP_DC1394_MODE_AUTO
26      -3      CAP_PROP_DC1394_MODE_MANUAL
27      -1      CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO
28      -4      CAP_PROP_DC1394_OFF
29      15      CAP_PROP_EXPOSURE
30      17009   CAP_PROP_EXPOSUREPROGRAM
31      28      CAP_PROP_FOCUS
[...]
276     450     CAP_PROP_XI_WB_KB
277     449     CAP_PROP_XI_WB_KG
278     448     CAP_PROP_XI_WB_KR
279     451     CAP_PROP_XI_WIDTH
280     27      CAP_PROP_ZOOM

It could be useful to sort them per ID or put them in a dictionary form

def cap_prop() -> dict:
    pairs = [(getattr(cv2, attr), attr) for attr in dir(cv2) if attr.startswith('CAP_PROP')]
    pairs.sort()
    return dict(pairs)

props = cap_prop()

print(props.get(10, None))
#CAP_PROP_BRIGHTNESS
print(props.get(71, None)) # use the get-form, IDs are not complete!
#None