reorder lines for readability
This commit is contained in:
parent
01c6364e65
commit
5fcb7383ca
1 changed files with 21 additions and 12 deletions
|
|
@ -19,8 +19,6 @@ import cv2
|
||||||
import dlib
|
import dlib
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
# Get the absolute path to the current directory
|
|
||||||
PATH = os.path.abspath(__file__ + '/..')
|
|
||||||
|
|
||||||
# Read config from disk
|
# Read config from disk
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
@ -36,6 +34,9 @@ def stop(status):
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Get the absolute path to the current directory
|
||||||
|
PATH = os.path.abspath(__file__ + '/..')
|
||||||
|
|
||||||
# The username of the user being authenticated
|
# The username of the user being authenticated
|
||||||
user = sys.argv[1]
|
user = sys.argv[1]
|
||||||
# The model file contents
|
# The model file contents
|
||||||
|
|
@ -44,6 +45,12 @@ models = []
|
||||||
encodings = []
|
encodings = []
|
||||||
# Amount of ingnored dark frames
|
# Amount of ingnored dark frames
|
||||||
dark_tries = 0
|
dark_tries = 0
|
||||||
|
# Total amount of frames captured
|
||||||
|
frames = 0
|
||||||
|
# face recognition/detection instances
|
||||||
|
face_detector = None
|
||||||
|
pose_predictor = None
|
||||||
|
face_encoder = None
|
||||||
|
|
||||||
# Try to load the face model from the models folder
|
# Try to load the face model from the models folder
|
||||||
try:
|
try:
|
||||||
|
|
@ -59,6 +66,17 @@ except FileNotFoundError:
|
||||||
if not encodings:
|
if not encodings:
|
||||||
sys.exit(10)
|
sys.exit(10)
|
||||||
|
|
||||||
|
# Read config from disk
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(PATH + "/config.ini")
|
||||||
|
|
||||||
|
# CNN usage flag
|
||||||
|
use_cnn = config.getboolean('core', 'use_cnn', fallback=False)
|
||||||
|
timeout = config.getint("video", "timout", fallback=5)
|
||||||
|
dark_threshold = config.getfloat("video", "dark_threshold", fallback=50.0)
|
||||||
|
video_certainty = config.getfloat("video", "certainty", fallback=3.5) / 10
|
||||||
|
end_report = config.getboolean("debug", "end_report", fallback=False)
|
||||||
|
|
||||||
# Save the time needed to start the script
|
# Save the time needed to start the script
|
||||||
timings['st'] = time.time() - timings['st']
|
timings['st'] = time.time() - timings['st']
|
||||||
|
|
||||||
|
|
@ -90,11 +108,6 @@ timings['ic'] = time.time() - timings['ic']
|
||||||
|
|
||||||
timings['ll'] = time.time()
|
timings['ll'] = time.time()
|
||||||
|
|
||||||
face_detector = None
|
|
||||||
pose_predictor = None
|
|
||||||
face_encoder = None
|
|
||||||
use_cnn = config.getboolean('core', 'use_cnn', fallback=False)
|
|
||||||
|
|
||||||
def init_detector():
|
def init_detector():
|
||||||
global face_detector
|
global face_detector
|
||||||
if use_cnn:
|
if use_cnn:
|
||||||
|
|
@ -128,6 +141,7 @@ init_thread3.join()
|
||||||
init_thread2.join()
|
init_thread2.join()
|
||||||
init_thread1.join()
|
init_thread1.join()
|
||||||
del init_thread1, init_thread2, init_thread3
|
del init_thread1, init_thread2, init_thread3
|
||||||
|
# Note the time it took to initalize detectors
|
||||||
timings['ll'] = time.time() - timings['ll']
|
timings['ll'] = time.time() - timings['ll']
|
||||||
|
|
||||||
# Fetch the max frame height
|
# Fetch the max frame height
|
||||||
|
|
@ -140,11 +154,6 @@ scaling_factor = (max_height / height) or 1
|
||||||
|
|
||||||
# Start the read loop
|
# Start the read loop
|
||||||
timings['fr'] = time.time()
|
timings['fr'] = time.time()
|
||||||
frames = 0
|
|
||||||
timeout = config.getint("video", "timout")
|
|
||||||
dark_threshold = config.getfloat("video", "dark_threshold")
|
|
||||||
end_report = config.getboolean("debug", "end_report")
|
|
||||||
video_certainty = config.getfloat("video", "certainty") / 10
|
|
||||||
while True:
|
while True:
|
||||||
# Increment the frame count every loop
|
# Increment the frame count every loop
|
||||||
frames += 1
|
frames += 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue