some work around using and handling capture errors

This commit is contained in:
langolierz
2018-10-10 00:52:48 +00:00
parent a133bb551e
commit cbd5ee9d61
4 changed files with 83 additions and 26 deletions

View File

@@ -24,7 +24,10 @@ class Capture(object):
def create_capture_device(self):
if self.use_capture:
if self.piCapture_with_no_source():
return
self.update_capture_settings()
try:
self.device = picamera.PiCamera(resolution=self.resolution, framerate=self.framerate, sensor_mode = self.sensor_mode)
except picamera.exc.PiCameraError as e:
@@ -33,6 +36,16 @@ class Capture(object):
print('camera exception is {}'.format(e))
self.message_handler.set_message('INFO', 'no capture device attached')
def piCapture_with_no_source(self):
is_piCapture = subprocess.check_output(['pivideo', '--query', 'ready'])
if 'Video Processor was not found' not in str(is_piCapture):
self.data.settings['capture']['TYPE']['value'] = "piCaptureSd1"
is_source = subprocess.check_output(['pivideo', '--query', 'lock'])
if 'No active video detected' in str(is_source):
self.message_handler.set_message('INFO', 'piCapture detected w no input source')
return True
return False
def update_capture_settings(self):
##setting class variables
self.use_capture = self.data.settings['capture']['DEVICE']['value'] == 'enabled'
@@ -227,5 +240,8 @@ class Capture(object):
else:
return int(fractions.Fraction(setting_value) * 1000000)
def receive_state(self, unused_addr, args):
pass