class HybridRpiCamera(RpiCamera): """Camera management using the Raspberry Pi camera for the preview (better video rendering) and a gPhoto2 compatible camera for the capture (higher resolution) """ IMAGE_EFFECTS = GpCamera.IMAGE_EFFECTS def __init__(self, *args, **kwargs): super(HybridRpiCamera, self).__init__(*args, **kwargs) self._gp_cam = GpCamera(*args, **kwargs) self._gp_cam._captures = self._captures # Same dict for both cameras def _post_process_capture(self, capture_data): """Rework capture data. :param capture_data: couple (GPhotoPath, effect) :type capture_data: tuple """ return self._gp_cam._post_process_capture(capture_data) def capture(self, effect=None): """Capture a picture in a file. """ self._gp_cam.capture(effect) self._hide_overlay() # If stop_preview() has not been called def quit(self): """Close the camera driver, it's definitive. """ super(HybridRpiCamera, self).quit() self._gp_cam.quit()
def find_camera(): """Initialize the camera depending of the connected one. The priority order is chosen in order to have best rendering during preview and to take captures. The gPhoto2 camera is first (drivers most restrictive) to avoid connection concurence in case of DSLR compatible with OpenCV. """ rpi_cam_proxy = get_rpi_camera_proxy() gp_cam_proxy = get_gp_camera_proxy() cv_cam_proxy = get_cv_camera_proxy() if rpi_cam_proxy and gp_cam_proxy: LOGGER.info("Configuring hybrid camera (Picamera + gPhoto2) ...") close_proxy(None, None, cv_cam_proxy) return HybridRpiCamera(rpi_cam_proxy, gp_cam_proxy) elif cv_cam_proxy and gp_cam_proxy: LOGGER.info("Configuring hybrid camera (OpenCV + gPhoto2) ...") close_proxy(rpi_cam_proxy, None, None) return HybridCvCamera(cv_cam_proxy, gp_cam_proxy) elif gp_cam_proxy: LOGGER.info("Configuring gPhoto2 camera ...") close_proxy(rpi_cam_proxy, None, cv_cam_proxy) return GpCamera(gp_cam_proxy) elif rpi_cam_proxy: LOGGER.info("Configuring Picamera camera ...") close_proxy(None, gp_cam_proxy, cv_cam_proxy) return RpiCamera(rpi_cam_proxy) elif cv_cam_proxy: LOGGER.info("Configuring OpenCV camera ...") close_proxy(rpi_cam_proxy, gp_cam_proxy, None) return CvCamera(cv_cam_proxy) raise EnvironmentError("Neither Raspberry Pi nor GPhoto2 nor OpenCV camera detected")
def close_proxy(rpi_cam_proxy, gp_cam_proxy, cv_cam_proxy): """Close proxy drivers. """ if rpi_cam_proxy: RpiCamera(rpi_cam_proxy).quit() if gp_cam_proxy: GpCamera(gp_cam_proxy).quit() if cv_cam_proxy: CvCamera(cv_cam_proxy).quit()
class HybridCvCamera(CvCamera): """Camera management using the OpenCV camera for the preview (better video rendering) and a gPhoto2 compatible camera for the capture (higher resolution) """ IMAGE_EFFECTS = GpCamera.IMAGE_EFFECTS def __init__(self, *args, **kwargs): # Initialize the gPhoto2 camera first (drivers most restrictive) to avoid # connection concurence in case of DSLR compatible with OpenCV. self._gp_cam = GpCamera(*args, **kwargs) super(HybridCvCamera, self).__init__(*args, **kwargs) self._gp_cam._captures = self._captures # Same dict for both cameras def _post_process_capture(self, capture_data): """Rework capture data. :param capture_data: couple (GPhotoPath, effect) :type capture_data: tuple """ return self._gp_cam._post_process_capture(capture_data) def capture(self, effect=None): """Capture a picture in a file. """ self._gp_cam.capture(effect) self._hide_overlay() # If stop_preview() has not been called def quit(self): """Close the camera driver, it's definitive. """ super(HybridCvCamera, self).quit() self._gp_cam.quit()
def __init__(self, *args, **kwargs): kwargs['init'] = False GpCamera.__init__(self, *args, **kwargs) self.gphoto2_process = None self.omxplayer_process = None
def __init__(self, *args, **kwargs): # Initialize the gPhoto2 camera first (drivers most restrictive) to avoid # connection concurence in case of DSLR compatible with OpenCV. self._gp_cam = GpCamera(*args, **kwargs) super(HybridCvCamera, self).__init__(*args, **kwargs) self._gp_cam._captures = self._captures # Same dict for both cameras
def __init__(self, *args, **kwargs): super(HybridRpiCamera, self).__init__(*args, **kwargs) self._gp_cam = GpCamera(*args, **kwargs) self._gp_cam._captures = self._captures # Same dict for both cameras
def __init__(self, cv_camera_proxy, gp_camera_proxy): super(HybridCvCamera, self).__init__(cv_camera_proxy) self._gp_cam = GpCamera(gp_camera_proxy) self._gp_cam._captures = self._captures # Same dict for both cameras
def __init__(self, *args, **kwargs): RpiCamera.__init__(self, *args, **kwargs) self._gp_cam = GpCamera(*args, **kwargs) self._gp_cam._captures = self._captures # Same dict for both cameras