use default values when reading from config

This commit is contained in:
dmig 2018-12-09 12:28:45 +07:00
parent 0c384baef2
commit 31dab29aa7
No known key found for this signature in database
GPG key ID: A4A245B3AD37C4FC
2 changed files with 8 additions and 8 deletions

View file

@ -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'

View file

@ -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