forked from emdete/python-v4l2capture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_devices.py
executable file
·48 lines (45 loc) · 1.55 KB
/
list_devices.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python3
#
# python-v4l2captureext
#
# 2009, 2010 Fredrik Portstrom
#
# I, the copyright holder of this file, hereby release it into the
# public domain. This applies worldwide. In case this is not legally
# possible: I grant anyone the right to use this work for any
# purpose, without any conditions, unless such conditions are
# required by law.
import os
import v4l2captureext
def exc_get(f, *args):
try:
return f(*args)
except Exception as e:
return str(e)
file_names = [x for x in os.listdir("/dev") if x.startswith("video")]
file_names.sort()
for file_name in file_names:
path = "/dev/" + file_name
print (path)
try:
video = v4l2captureext.Video_device(path)
driver, card, bus_info, capabilities = video.get_info()
print("\tDriver:", driver)
print("\tCard:", card)
print("\tBus-info:", bus_info)
print("\tCapabilities:", ", ".join(map(str, capabilities)))
width, height, fourcc = video.get_format()
print("\tWidth:", width)
print("\tHeight:", height)
print("\tFourcc:", fourcc)
for cap in exc_get(video.get_framesizes, fourcc):
print("\tFrame-size:", cap)
for cap in exc_get(video.get_frameintervals, fourcc, width, height):
print("\tFrame-interval:", cap)
print("\tAuto-white-balance:", exc_get(video.get_auto_white_balance))
print("\tWhite-balance-temperature:", exc_get(video.get_white_balance_temperature))
print("\tAuto-exposure:", exc_get(video.get_exposure_auto))
print("\tExposure-absolute:", exc_get(video.get_exposure_absolute))
print("\tAuto-focus:", exc_get(video.get_focus_auto))
finally:
video.close()