Browse Source

added capture_device_index support

subDesTagesMitExtraKaese 3 years ago
parent
commit
02a0fcb23d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      raspberry-pi/sensors/opticalSensor.py

+ 6 - 1
raspberry-pi/sensors/opticalSensor.py

@@ -110,7 +110,12 @@ class OpticalSensor():
       self._t.start()
       self._t.start()
 
 
   def _getFrames(self):
   def _getFrames(self):
-    self.cap = cv2.VideoCapture(self.conf["opt_sensor"]["capture_device"])
+    try:
+      dev = int(self.conf["opt_sensor"]["capture_device"])
+    except ValueError:
+      dev = self.conf["opt_sensor"]["capture_device"]
+    self.cap = cv2.VideoCapture(dev)
+
     while self.running:
     while self.running:
       self.success, image = self.cap.read()
       self.success, image = self.cap.read()
       if self.success:
       if self.success: