Skip to content

Commit 708ce17

Browse files
committed
Added support for camera selection
1 parent da50c9c commit 708ce17

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

BabbleApp/utils/misc_utils.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
import os
22
import typing
3+
from pygrabber.dshow_graph import FilterGraph
34

45
is_nt = True if os.name == "nt" else False
56

7+
8+
def list_camera_names():
9+
graph = FilterGraph()
10+
cam_list = graph.get_input_devices()
11+
cam_names = []
12+
for index, name in enumerate(cam_list):
13+
cam_names.append(name)
14+
return cam_names
15+
16+
17+
def get_camera_index_by_name(name):
18+
graph = FilterGraph()
19+
cam_list = graph.get_input_devices()
20+
21+
for i, device_name in enumerate(cam_list):
22+
if device_name == name:
23+
return i
24+
25+
return None
26+
27+
628
def PlaySound(*args, **kwargs): pass
29+
30+
731
SND_FILENAME = SND_ASYNC = 1
832

933
if is_nt:
1034
import winsound
35+
1136
PlaySound = winsound.PlaySound
1237
SND_FILENAME = winsound.SND_FILENAME
13-
SND_ASYNC = winsound.SND_ASYNC
38+
SND_ASYNC = winsound.SND_ASYNC

0 commit comments

Comments
 (0)