3 This module handles various backends (different for every OS) for streaming the video from a (web)camera.
14 """Implement basic camera capabilities
16 This class has different implementations for different OS. On posix
17 systems it calls to opencv, on Windows to VideoCapture."""
18 # TODO what about win 64?
19 # TODO why not openCV on win?
20 # TODO document VideoCapture as a dependency
21 def __init__(self, vid=0, res=None):
22 self._cam = cv.CreateCameraCapture(vid)
24 cv.SetCaptureProperty(self._cam, cv.CV_CAP_PROP_FRAME_WIDTH, res[0])
25 cv.SetCaptureProperty(self._cam, cv.CV_CAP_PROP_FRAME_HEIGHT,
29 """Get a new image from the camera."""
30 for _ in range(5): #HACK TODO document this
31 im = cv.QueryFrame(self._cam)
32 return Image.fromstring("RGB", cv.GetSize(im), im.tostring(), "raw",
39 elif os.name in ('ce', 'nt', 'dos'):
41 from VideoCapture import Device
43 # TODO exception handling
47 self._cam.setResolution(640, 480)
50 return self._cam.getImage()
56 pass # TODO exception "Cannot recognise OS." or back to posix?