-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdevice-enumeration.py
More file actions
59 lines (37 loc) · 1.48 KB
/
device-enumeration.py
File metadata and controls
59 lines (37 loc) · 1.48 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import imagingcontrol4 as ic4
def format_device_info(device_info: ic4.DeviceInfo) -> str:
return f"Model: {device_info.model_name} Serial: {device_info.serial}"
def print_device_list():
print("Enumerating all attached video capture devices...")
device_list = ic4.DeviceEnum.devices()
if len(device_list) == 0:
print("No devices found")
return
print(f"Found {len(device_list)} devices:")
for device_info in device_list:
print(format_device_info(device_info))
def print_interface_device_tree():
print("Enumerating video capture devices by interface...")
interface_list = ic4.DeviceEnum.interfaces()
if len(interface_list) == 0:
print("No interfaces found")
return
for itf in interface_list:
print(f"Interface: {itf.display_name}")
print(f"\tProvided by {itf.transport_layer_name} [TLType: {str(itf.transport_layer_type)}]")
device_list = itf.devices
if len(device_list) == 0:
print("\tNo devices found")
continue
print(f"\tFound {len(device_list)} devices:")
for device_info in device_list:
print(f"\t\t{format_device_info(device_info)}")
def example_device_enumeration():
print_device_list()
print_interface_device_tree()
if __name__ == "__main__":
ic4.Library.init(api_log_level=ic4.LogLevel.INFO, log_targets=ic4.LogTarget.STDERR)
try:
example_device_enumeration()
finally:
ic4.Library.exit()