From db53bd2d65c2a8a56f146577d56e2316a9bb1c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20In=C3=A1cio?= Date: Wed, 12 Feb 2020 15:13:20 -0300 Subject: [PATCH] Update module camera settings Include reset settings function --- camera_settings.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/camera_settings.py b/camera_settings.py index 06c2641..2ea3448 100644 --- a/camera_settings.py +++ b/camera_settings.py @@ -31,3 +31,20 @@ def check_settings(): print(f'{attrib} = {VIDEO_CHECK.get(index)}') VIDEO_CHECK.release() + +def reset_settings(): + if not os.path.exists('camera_settings.log'): + print('"camera_settings.log" does not exist!') + print('Verify your camera settings!') + return False + else: + VIDEO_CHECK = cv2.VideoCapture(0) + f = open('camera_settings.log', 'r') + lines = f.read().split('\n') + for line in lines: + attrib = line.split(' = ') + if attrib[0] in attrib_list.keys(): + VIDEO_CHECK.set(attrib_list[attrib[0]], eval(attrib[1])) + f.close() + VIDEO_CHECK.release() + return True