Esempio n. 1
0
 def _resolution_changed(self, value):
     width, height = value
     cv.SetCaptureProperty(self._capture, FRAME_WIDTH, width)
     cv.SetCaptureProperty(self._capture, FRAME_HEIGHT, height)
     if cv.GetCaptureProperty(self._capture, FRAME_WIDTH) != width:
         raise CameraError('Width {0} not supported'.format(width),
                           self.camera_number)
     if cv.GetCaptureProperty(self._capture, FRAME_HEIGHT) != height:
         raise CameraError('Height {0} not supported'.format(height),
                           self.camera_number)
Esempio n. 2
0
 def _resolution_changed(self, value):
     width, height = value
     self._capture.set(FRAME_WIDTH, width)
     self._capture.set(FRAME_HEIGHT, height)
     if self._capture.get(FRAME_WIDTH) != width:
         raise CameraError('Width {0} not supported'.format(width),
                           self.camera_number)
     if self._capture.get(FRAME_HEIGHT) != height:
         raise CameraError('Height {0} not supported'.format(height),
                           self.camera_number)
Esempio n. 3
0
    def open(self):
        self._capture = cv.CaptureFromCAM(self.camera_number)

        # doesn't raise an exception on error, so we test it explicitly
        iplimage = cv.QueryFrame(self._capture)
        if iplimage is None:
            raise CameraError('Could not query image', self.camera_number)
Esempio n. 4
0
    def open(self):
        self._cam = VideoCapture.Device(self.camera_number)

        # Capture a throwaway frame in order to get the resolution
        # and bytes per pixel
        buffer, width, height = self._cam.getBuffer()
        self.resolution = (width, height)
        itemsize = len(buffer) / (width * height * 3)

        # Pick an appropriate dtype and cache it
        if itemsize == 1:
            self._dtype = N.uint8
        elif itemsize == 2:
            self._dtype = N.uint16
        elif itemsize == 4:
            self._dtype = N.uint32
        else:
            raise CameraError(
                "Unsupported bytes per pixel '{}'".format(itemsize),
                self.camera_number)
Esempio n. 5
0
 def query_frame(self):
     iplimage = cv.QueryFrame(self._capture)
     if iplimage is None:
         raise CameraError('Could not query image', self.camera_number)
     self.frame = ipl2array(iplimage)
Esempio n. 6
0
 def reset(self):
     self._cam.ResetState()
     # if error status persists, raise an exception
     if self._cam.ImagingStatus < 0:
         raise CameraError('Error not cleared by reset', self.camera_number)
Esempio n. 7
0
 def query_frame(self):
     success, frame = self._capture.read()
     if not success:
         raise CameraError('Could not query image', self.camera_number)
     self.frame = frame
Esempio n. 8
0
    def open(self):
        self._capture = cv2.VideoCapture(self.camera_number)

        # doesn't raise an exception on error, so we test it explicitly
        if not self._capture.isOpened():
            raise CameraError('Could not open camera', self.camera_number)