Skip to content

Commit 430b0ed

Browse files
committed
fix: only consider devices that are video sources
1 parent 87113b7 commit 430b0ed

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/crappy/camera/gstreamer_camera_basic.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ def open(self,
197197
cam = None
198198
device_monitor = Gst.DeviceMonitor.new()
199199
device_monitor.start()
200-
devices = device_monitor.get_devices()
200+
devices = [device for device in device_monitor.get_devices()
201+
if device.get_device_class() == "Video/Source"]
201202

202203
# Stop right here if there is no connected camera
203204
if not devices:
@@ -207,13 +208,12 @@ def open(self,
207208
# Finding the specified device in the available ones
208209
if self._device is not None:
209210
for device in devices:
210-
if device.get_device_class() == "Video/Source":
211-
properties = device.get_properties()
212-
api = properties.get_value('device.api')
213-
dev = properties.get_value('object.path')
214-
if dev == f'{api}:{self._device}':
215-
cam = device
216-
break
211+
properties = device.get_properties()
212+
api = properties.get_value('device.api')
213+
dev = properties.get_value('object.path')
214+
if dev == f'{api}:{self._device}':
215+
cam = device
216+
break
217217

218218
# Raising an exception if the specified device cannot be found
219219
if self._device is not None and cam is None:

0 commit comments

Comments
 (0)