Skip to content

Commit b22a51c

Browse files
committed
(tweak) Fix syntax errors
1 parent c944765 commit b22a51c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

BabbleApp/utils/misc_utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def get_camera_index_by_name(name):
150150
# On Linux, we use device paths like '/dev/video0' and match directly
151151
# OpenCV expects the actual /dev/video#, not the offset into the device list
152152
if os_type == "Linux":
153-
return int(str.replace(name,"/dev/video",""));
153+
if (name.startswith("/dev/ttyACM")):
154+
return int(str.replace(name,"/dev/ttyACM",""));
155+
else:
156+
return int(str.replace(name,"/dev/video",""));
154157

155158
# On Windows, match by camera name
156159
elif os_type == 'Windows':

BabbleApp/vivefacialtracker/camera.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def _find_frame_size(self: 'FTCamera') -> None:
271271
for x in self._device.info.frame_sizes:
272272
FTCamera._logger.info("- {}".format(x))
273273
self._frame_size = next(x for x in self._device.info.frame_sizes
274-
if x.pixel_format == v4l2.PixelFormat.YUYV
274+
if x.pixel_format == v4l.PixelFormat.YUYV
275275
and x.min_fps >= 30)
276276
elif os_type == 'Windows':
277277
fsize = next(x for x in self._filter_video.get_formats()
@@ -362,7 +362,7 @@ def device_index(self: 'FTCamera') -> int:
362362

363363
if os_type == 'Linux':
364364
@property
365-
def device(self: 'FTCamera') -> v4l2.VideoDevice:
365+
def device(self: 'FTCamera') -> v4l.Device:
366366
"""Video4Linux device if open or None if closed."""
367367
return self._device
368368
elif os_type == 'Windows':
@@ -470,7 +470,7 @@ def _process_frame(self: 'FTCamera', frame) -> None:
470470

471471
try:
472472
match frame.pixel_format:
473-
case v4l2.PixelFormat.YUYV:
473+
case v4l.PixelFormat.YUYV:
474474
self._decode_yuv422(frame.data)
475475
case _:
476476
FTCamera._logger.error(

0 commit comments

Comments
 (0)