X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/6d19451cd1ebad960d015a79f27ab95f86c31d61..591bcf6fd934c08f45826c0c3c93156348b0b614:/imago_pack/camera.py diff --git a/imago_pack/camera.py b/imago_pack/camera.py index d5dac75..a4521d0 100644 --- a/imago_pack/camera.py +++ b/imago_pack/camera.py @@ -1,3 +1,8 @@ +"""Camera module. + +This module handles various backends (different for every OS) for streaming the video from a (web)camera. +""" + import os if os.name == 'posix': @@ -6,6 +11,13 @@ if os.name == 'posix': import cv class Camera: + """Implement basic camera capabilities + + This class has different implementations for different OS. On posix + systems it calls to opencv, on Windows to VideoCapture.""" + # TODO what about win 64? + # TODO why not openCV on win? + # TODO document VideoCapture as a dependency def __init__(self, vid=0, res=None): self._cam = cv.CreateCameraCapture(vid) if res: @@ -14,11 +26,9 @@ if os.name == 'posix': res[1]) def get_image(self): - for _ in range(5): #HACK + """Get a new image from the camera.""" + for _ in range(5): #HACK TODO document this 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(), "raw", "BGR", 0, 1) @@ -41,3 +51,6 @@ elif os.name in ('ce', 'nt', 'dos'): def __del__(self): del self._cam + +else: + pass # TODO exception "Cannot recognise OS." or back to posix?