Timeouts are now by seconds and added max_height
This commit is contained in:
parent
3910755c1a
commit
d7f8510226
3 changed files with 26 additions and 6 deletions
22
compare.py
22
compare.py
|
|
@ -61,6 +61,9 @@ timings.append(time.time())
|
||||||
video_capture = cv2.VideoCapture(int(config.get("video", "device_id")))
|
video_capture = cv2.VideoCapture(int(config.get("video", "device_id")))
|
||||||
timings.append(time.time())
|
timings.append(time.time())
|
||||||
|
|
||||||
|
# Fetch the max frame height
|
||||||
|
max_height = int(config.get("video", "max_height"))
|
||||||
|
|
||||||
# Start the read loop
|
# Start the read loop
|
||||||
frames = 0
|
frames = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -70,6 +73,17 @@ while True:
|
||||||
# Don't remove ret, it doesn't work without it
|
# Don't remove ret, it doesn't work without it
|
||||||
ret, frame = video_capture.read()
|
ret, frame = video_capture.read()
|
||||||
|
|
||||||
|
height, width = frame.shape[:2]
|
||||||
|
|
||||||
|
if max_height < height:
|
||||||
|
scaling_factor = max_height / float(height)
|
||||||
|
frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)
|
||||||
|
|
||||||
|
scale_height, scale_width = frame.shape[:2]
|
||||||
|
|
||||||
|
# Convert from BGR to RGB
|
||||||
|
frame = frame[:, :, ::-1]
|
||||||
|
|
||||||
# Get all faces from that frame as encodings
|
# Get all faces from that frame as encodings
|
||||||
face_encodings = face_recognition.face_encodings(frame)
|
face_encodings = face_recognition.face_encodings(frame)
|
||||||
|
|
||||||
|
|
@ -89,8 +103,6 @@ while True:
|
||||||
|
|
||||||
# If set to true in the config, print debug text
|
# If set to true in the config, print debug text
|
||||||
if config.get("debug", "end_report") == "true":
|
if config.get("debug", "end_report") == "true":
|
||||||
print("DEBUG END REPORT\n")
|
|
||||||
|
|
||||||
def print_timing(label, offset):
|
def print_timing(label, offset):
|
||||||
"""Helper function to print a timing from the list"""
|
"""Helper function to print a timing from the list"""
|
||||||
print(" " + label + ": " + str(round((timings[1 + offset] - timings[offset]) * 1000)) + "ms")
|
print(" " + label + ": " + str(round((timings[1 + offset] - timings[offset]) * 1000)) + "ms")
|
||||||
|
|
@ -101,6 +113,10 @@ while True:
|
||||||
print_timing("Opening the camera", 2)
|
print_timing("Opening the camera", 2)
|
||||||
print_timing("Searching for known face", 3)
|
print_timing("Searching for known face", 3)
|
||||||
|
|
||||||
|
print("\nResolution")
|
||||||
|
print(" Native: " + str(height) + "x" + str(width))
|
||||||
|
print(" Used: " + str(scale_height) + "x" + str(scale_width))
|
||||||
|
|
||||||
print("\nFrames searched: " + str(frames) + " (" + str(round(float(frames) / (timings[4] - timings[2]), 2)) + " fps)")
|
print("\nFrames searched: " + str(frames) + " (" + str(round(float(frames) / (timings[4] - timings[2]), 2)) + " fps)")
|
||||||
print("Certainty of winning frame: " + str(round(match * 10, 3)))
|
print("Certainty of winning frame: " + str(round(match * 10, 3)))
|
||||||
|
|
||||||
|
|
@ -113,7 +129,7 @@ while True:
|
||||||
stop(0)
|
stop(0)
|
||||||
|
|
||||||
# Stop if we've exceded the maximum retry count
|
# Stop if we've exceded the maximum retry count
|
||||||
if tries > int(config.get("video", "frame_count")):
|
if time.time() - timings[3] > int(config.get("video", "timout")):
|
||||||
stop(11)
|
stop(11)
|
||||||
|
|
||||||
tries += 1
|
tries += 1
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,17 @@ suppress_unknown = false
|
||||||
# On a scale from 1 to 10, values above 5 are not recommended
|
# On a scale from 1 to 10, values above 5 are not recommended
|
||||||
certainty = 3.5
|
certainty = 3.5
|
||||||
|
|
||||||
# The number of frames to capture and to process before timing out
|
# The number of seconds to search before timing out
|
||||||
frame_count = 30
|
timout = 4
|
||||||
|
|
||||||
# The /dev/videoX id to capture frames from
|
# The /dev/videoX id to capture frames from
|
||||||
# Should be set automatically by the installer
|
# Should be set automatically by the installer
|
||||||
device_id = 1
|
device_id = 1
|
||||||
|
|
||||||
|
# Scale down the video feed to this maximum height
|
||||||
|
# Speeds up face recognition but can make it less precise
|
||||||
|
max_height = 320
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
# Show a short but detailed diagnostic report in console
|
# Show a short but detailed diagnostic report in console
|
||||||
end_report = false
|
end_report = false
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ handleStatus(subprocess.call(["rm", "-rf", "/tmp/dlib_clone"]))
|
||||||
|
|
||||||
log("Installing face_recognition")
|
log("Installing face_recognition")
|
||||||
|
|
||||||
handleStatus(subprocess.call(["pip3", "install", "face_recognition"]))
|
handleStatus(subprocess.call(["pip3", "install", "face_recognition", "sty"]))
|
||||||
|
|
||||||
log("Cloning howdy")
|
log("Cloning howdy")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue