Added functionality to switch automatically to JPEG Fine and restore the original setting on teardown. This closes #10
This commit is contained in:
@@ -92,6 +92,7 @@ class Photobooth:
|
|||||||
logging.info('Teardown of camera')
|
logging.info('Teardown of camera')
|
||||||
self.triggerOff()
|
self.triggerOff()
|
||||||
self.setCameraIdle()
|
self.setCameraIdle()
|
||||||
|
self._cap.cleanup()
|
||||||
|
|
||||||
def recvEvent(self, expected):
|
def recvEvent(self, expected):
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,16 @@ class CameraGphoto2(Camera):
|
|||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|
||||||
self._cap.set_config(self._oldconfig)
|
config = self._cap.get_config()
|
||||||
|
config.get_child_by_name('imageformat').set_value(self._imageformat)
|
||||||
|
config.get_child_by_name('imageformatsd').set_value(self._imageformat)
|
||||||
|
# config.get_child_by_name('autopoweroff').set_value(self._autopoweroff)
|
||||||
|
self._cap.set_config(config)
|
||||||
self._cap.exit(self._ctxt)
|
self._cap.exit(self._ctxt)
|
||||||
|
|
||||||
def _setupLogging(self):
|
def _setupLogging(self):
|
||||||
|
|
||||||
gp.error_severity[gp.GP_ERROR] = logging.WARNING
|
gp.error_severity[gp.GP_ERROR] = logging.ERROR
|
||||||
gp.check_result(gp.use_python_logging())
|
gp.check_result(gp.use_python_logging())
|
||||||
|
|
||||||
def _setupCamera(self):
|
def _setupCamera(self):
|
||||||
@@ -61,16 +65,29 @@ class CameraGphoto2(Camera):
|
|||||||
str(self._cap.get_summary(self._ctxt)))
|
str(self._cap.get_summary(self._ctxt)))
|
||||||
|
|
||||||
# get configuration tree
|
# get configuration tree
|
||||||
# self._config = self._cap.get_config()
|
|
||||||
# self._oldconfig = self._config
|
|
||||||
config = self._cap.get_config()
|
config = self._cap.get_config()
|
||||||
|
|
||||||
# make sure camera format is not set to raw
|
# make sure camera format is not set to raw
|
||||||
imageformat = config.get_child_by_name('imageformat').get_value()
|
imageformat = config.get_child_by_name('imageformat')
|
||||||
if 'raw' in imageformat.lower():
|
self._imageformat = imageformat.get_value()
|
||||||
raise RuntimeError('Camera file format is set to RAW')
|
if 'raw' in self._imageformat.lower():
|
||||||
|
imageformat.set_value('Large Fine JPEG')
|
||||||
|
imageformatsd = config.get_child_by_name('imageformatsd')
|
||||||
|
self._imageformatsd = imageformatsd.get_value()
|
||||||
|
if 'raw' in self._imageformatsd.lower():
|
||||||
|
imageformatsd.set_value('Large Fine JPEG')
|
||||||
|
|
||||||
self._printConfig(config)
|
# make sure autopoweroff is disabled
|
||||||
|
# this doesn't seem to work
|
||||||
|
# autopoweroff = config.get_child_by_name('autopoweroff')
|
||||||
|
# self._autopoweroff = autopoweroff.get_value()
|
||||||
|
# logging.info('autopoweroff: {}'.format(self._autopoweroff))
|
||||||
|
# if int(self._autopoweroff) > 0:
|
||||||
|
# autopoweroff.set_value('0')
|
||||||
|
|
||||||
|
# apply configuration and print current config
|
||||||
|
self._cap.set_config(config)
|
||||||
|
self._printConfig(self._cap.get_config())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _configTreeToText(tree, indent=0):
|
def _configTreeToText(tree, indent=0):
|
||||||
|
|||||||
@@ -40,16 +40,33 @@ class CameraGphoto2Cffi(Camera):
|
|||||||
|
|
||||||
self._setupCamera()
|
self._setupCamera()
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
|
||||||
|
self._cap.config['imgsettings']['imageformat'].set(self._imageformat)
|
||||||
|
self._cap.config['imgsettings']['imageformatsd'].set(self._imageformatsd)
|
||||||
|
# self._cap.config['settings']['autopoweroff'].set(self._autopoweroff)
|
||||||
|
|
||||||
def _setupCamera(self):
|
def _setupCamera(self):
|
||||||
|
|
||||||
self._cap = gp.Camera()
|
self._cap = gp.Camera()
|
||||||
logging.info('Supported operations: %s',
|
logging.info('Supported operations: %s',
|
||||||
self._cap.supported_operations)
|
self._cap.supported_operations)
|
||||||
|
|
||||||
imageformat = self._cap.config['imgsettings']['imageformat'].value
|
# make sure camera format is not set to raw
|
||||||
if 'raw' in imageformat.lower():
|
self._imageformat = self._cap.config['imgsettings']['imageformat'].value
|
||||||
raise RuntimeError('Camera file format is set to RAW')
|
if 'raw' in self._imageformat.lower():
|
||||||
|
self._cap.config['imgsettings']['imageformat'].set('Large Fine JPEG')
|
||||||
|
self._imageformatsd = self._cap.config['imgsettings']['imageformatsd'].value
|
||||||
|
if 'raw' in self._imageformatsd.lower():
|
||||||
|
self._cap.config['imgsettings']['imageformatsd'].set('Large Fine JPEG')
|
||||||
|
|
||||||
|
# make sure autopoweroff is disabled
|
||||||
|
# this doesn't seem to work
|
||||||
|
# self._autopoweroff = int(self._cap.config['settings']['autopoweroff'].value)
|
||||||
|
# if self._autopoweroff > 0:
|
||||||
|
# self._cap.config['settings']['autopoweroff'].set("0")
|
||||||
|
|
||||||
|
# print current config
|
||||||
self._printConfig(self._cap.config)
|
self._printConfig(self._cap.config)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user