From 31dab29aa7ce6dec24aaee374ede04be35095f83 Mon Sep 17 00:00:00 2001 From: dmig Date: Sun, 9 Dec 2018 12:28:45 +0700 Subject: [PATCH] use default values when reading from config --- src/cli/test.py | 8 ++++---- src/compare.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cli/test.py b/src/cli/test.py index 8c8e034..c65c92b 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -19,13 +19,13 @@ config.read(path + "/../config.ini") video_capture = cv2.VideoCapture(config.get("video", "device_path")) # Force MJPEG decoding if true -if config.getboolean("video", "force_mjpeg"): +if config.getboolean("video", "force_mjpeg", fallback=False): # Set a magic number, will enable MJPEG but is badly documented video_capture.set(cv2.CAP_PROP_FOURCC, 1196444237) # Set the frame width and height if requested -fw = config.getint("video", "frame_width") -fh = config.getint("video", "frame_height") +fw = config.getint("video", "frame_width", fallback=-1) +fh = config.getint("video", "frame_height", fallback=-1) if fw != -1: video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, fw) @@ -52,7 +52,7 @@ def print_text(line_number, text): """Print the status text by line number""" cv2.putText(overlay, text, (10, height - 10 - (10 * line_number)), cv2.FONT_HERSHEY_SIMPLEX, .3, (0, 255, 0), 0, cv2.LINE_AA) -use_cnn = config.getboolean('core', 'use_cnn') +use_cnn = config.getboolean('core', 'use_cnn', fallback=False) if use_cnn: face_detector = dlib.cnn_face_detection_model_v1( path + '/../dlib-data/mmod_human_face_detector.dat' diff --git a/src/compare.py b/src/compare.py index 24c4a15..dbfd5fb 100644 --- a/src/compare.py +++ b/src/compare.py @@ -59,13 +59,13 @@ timings.append(time.time()) video_capture = cv2.VideoCapture(config.get("video", "device_path")) # Force MJPEG decoding if true -if config.getboolean("video", "force_mjpeg"): +if config.getboolean("video", "force_mjpeg", fallback=False): # Set a magic number, will enable MJPEG but is badly documentated video_capture.set(cv2.CAP_PROP_FOURCC, 1196444237) # Set the frame width and height if requested -fw = config.getint("video", "frame_width") -fh = config.getint("video", "frame_height") +fw = config.getint("video", "frame_width", fallback=-1) +fh = config.getint("video", "frame_height", fallback=-1) if fw != -1: video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, fw) @@ -84,7 +84,7 @@ import face_recognition timings.append(time.time()) # Fetch the max frame height -max_height = int(config.get("video", "max_height")) +max_height = config.getfloat("video", "max_height", fallback=0.0) # Start the read loop frames = 0