openflexure-microscope-server/openflexure_microscope/camera/config.py
2018-11-06 15:57:33 +00:00

34 lines
796 B
Python

import yaml
TYPES = {
'stream_resolution': tuple,
'video_resolution': tuple,
'image_resolution': tuple,
'numpy_resolution': tuple,
'jpeg_quality': int,
'framerate': int,
'awb_mode': str,
'red_gain': float,
'blue_gain': float,
'shutter_speed': int,
'saturation': int,
'analog_gain': float,
'digital_gain': float,
}
def convert_config(config):
"""Convert datatype of config based on type dictionary."""
global TYPES
for key in config:
if key in TYPES:
config[key] = TYPES[key](config[key])
return config
def load_config(yaml_path):
"""Load YAML file, pass through dictionary conversion, and return."""
with open(yaml_path) as config_file:
return convert_config(yaml.load(config_file))