forked from atareao/python3-v4l2capture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_devices.py
More file actions
executable file
·40 lines (35 loc) · 1.11 KB
/
Copy pathlist_devices.py
File metadata and controls
executable file
·40 lines (35 loc) · 1.11 KB
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
#!/usr/bin/env python3
#
# python-v4l2capture
#
# 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 v4l2capture
def get_devices():
file_names = [x for x in os.listdir("/dev") if x.startswith("video")]
file_names.sort()
devices = {}
for file_name in file_names:
path = "/dev/" + file_name
print(path)
try:
video = v4l2capture.Video_device(path)
print(video)
driver, card, bus_info, capabilities = video.get_info()
devices[path] = {}
devices[path]['driver'] = driver
devices[path]['card'] = card
devices[path]['bus_info'] = bus_info
devices[path]['capabilities'] = capabilities
video.close()
except IOError as e:
print(e)
return devices
if __name__ == '__main__':
print(get_devices())