capture saves images
[imago.git] / camera.py
index 0f524f3..ec94787 100644 (file)
--- a/camera.py
+++ b/camera.py
@@ -10,12 +10,16 @@ if os.name == 'posix':
             self._cam = cv.CreateCameraCapture(0)
 
         def get_image(self):
             self._cam = cv.CreateCameraCapture(0)
 
         def get_image(self):
-            im = cv.QueryFrame(self._cam)
+            for _ in range(5): #HACK
+                im = cv.QueryFrame(self._cam)
             # Add the line below if you need it (Ubuntu 8.04+)
             im = cv.GetMat(im)
             #convert Ipl image to PIL image
             return Image.fromstring("RGB", cv.GetSize(im), im.tostring())
         
             # Add the line below if you need it (Ubuntu 8.04+)
             im = cv.GetMat(im)
             #convert Ipl image to PIL image
             return Image.fromstring("RGB", cv.GetSize(im), im.tostring())
         
+        def __del__(self):
+            del self._cam 
+
 
 elif os.name in ('ce', 'nt', 'dos'):
     
 
 elif os.name in ('ce', 'nt', 'dos'):
     
@@ -27,8 +31,8 @@ elif os.name in ('ce', 'nt', 'dos'):
             self._cam = Device()
             self._cam.setResolution(640, 480)
 
             self._cam = Device()
             self._cam.setResolution(640, 480)
 
-        def shot(self):
-            self._cam.saveSnapshot('image.jpg', quality=100)
+        def get_image(self):
+            return self._cam.getImage()
 
         def __del__(self):
             del self._cam
 
         def __del__(self):
             del self._cam