9 def __init__(self, vid=0, res=None):
10 self._cam = cv.CreateCameraCapture(vid)
12 cv.SetCaptureProperty(self._cam, cv.CV_CAP_PROP_FRAME_WIDTH, res[0])
13 cv.SetCaptureProperty(self._cam, cv.CV_CAP_PROP_FRAME_HEIGHT,
17 for _ in range(5): #HACK
18 im = cv.QueryFrame(self._cam)
19 # Add the line below if you need it (Ubuntu 8.04+)
21 #convert Ipl image to PIL image
22 return Image.fromstring("RGB", cv.GetSize(im), im.tostring(), "raw",
29 elif os.name in ('ce', 'nt', 'dos'):
31 from VideoCapture import Device
33 # TODO exception handling
37 self._cam.setResolution(640, 480)
40 return self._cam.getImage()