in projects/vision-ai-edge-platform/camera-client/camera_client.py [0:0]
def write_config(printout, logger, cam, cfg_file):
"""Write desired configurations to the camera.
For camera types that support configuration management, uses the cam
class set_properties() method, to write or update the camera's
runtime configs. Read config parameter/value pairs from input text file.
Args:
printout: printing messages to stdout.
logger: main logger client.
cam: camera object.
cfg_file: target configurations input file.
"""
if printout:
logger.info("Reading config file: {}".format(cfg_file))
try:
f = open(cfg_file, "r", encoding="utf-8")
except IOError:
if printout:
logger.error("Error reading file")
exit(1)
configs = {}
for row in f:
key, value = row.split(" = ")
value = value.rstrip()
if value == "True":
configs[key] = True
elif value == "False":
configs[key] = False
elif '"' in value:
configs[key] = str(value).replace('"', "")
elif "." in value or "e" in value:
configs[key] = float(value)
else:
configs[key] = int(value)
f.close()
logger.debug("Writing configs to camera: {}".format(configs))
cam.set_properties(configs)
return