[mousetrap/gnome3-wip: 126/240] Extracting camera configuration.



commit 7685af2abe6379ec1cd3b1761a95240fff1b9c98
Author: Stoney Jackson <dr stoney gmail com>
Date:   Mon Jun 23 14:44:34 2014 -0400

    Extracting camera configuration.

 src/mousetrap/config.py |    6 ++++++
 src/mousetrap/vision.py |   10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/mousetrap/config.py b/src/mousetrap/config.py
index e9c8177..a466621 100644
--- a/src/mousetrap/config.py
+++ b/src/mousetrap/config.py
@@ -2,6 +2,12 @@ class Config(dict):
     def __init__(self):
         self['loops_per_second'] = 10
 
+        self['camera'] = {
+            'device_index': -1,     # -1 to search for device
+            'width': 400,
+            'height': 300,
+            }
+
         # The plugins to load in the order they will load and run.
         self['assembly'] =  [
             'mousetrap.plugins.camera.CameraPlugin',
diff --git a/src/mousetrap/vision.py b/src/mousetrap/vision.py
index 5d1962a..16f95b7 100644
--- a/src/mousetrap/vision.py
+++ b/src/mousetrap/vision.py
@@ -10,12 +10,14 @@ from mousetrap.image import Image
 class Camera(object):
     S_CAPTURE_OPEN_ERROR = 'Device #%d does not support video capture interface'
     S_CAPTURE_READ_ERROR = 'Error while capturing. Camera disconnected?'
-    SEARCH_FOR_DEVICE = -1
 
-    def __init__(self, config, device_index=SEARCH_FOR_DEVICE, width=400, height=300):
+    def __init__(self, config):
         self._config = config
-        self._device = self._new_capture_device(device_index)
-        self.set_dimensions(width, height)
+        self._device = self._new_capture_device(config['camera']['device_index'])
+        self.set_dimensions(
+                config['camera']['width'],
+                config['camera']['height']
+                )
 
     @classmethod
     def _new_capture_device(cls, device_index):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]