|
|
@@ -1,4 +1,7 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
# Match camera against existing faces, or record a new face. |
|
|
|
|
|
|
|
import cv2 |
|
|
|
import numpy as np |
|
|
|
import face_recognition |
|
|
@@ -28,7 +31,7 @@ def match(paths, cap, show): |
|
|
|
if cv2.mean(frame)[0] < 30: |
|
|
|
continue |
|
|
|
|
|
|
|
scale = 0.5 |
|
|
|
scale = 1 |
|
|
|
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB) |
|
|
|
small_rgb_frame = cv2.resize(rgb_frame, (0, 0), fx=scale, fy=scale) |
|
|
|
|
|
|
@@ -114,6 +117,9 @@ sub_match.add_argument( |
|
|
|
sub_match.add_argument( |
|
|
|
"-s", "--show", default=False, action="store_true", |
|
|
|
help="show what the camera sees") |
|
|
|
sub_match.add_argument( |
|
|
|
"-w", "--wait", default=False, action="store_true", |
|
|
|
help="wait for newline on stdin") |
|
|
|
sub_match.add_argument( |
|
|
|
"faces", type=str, nargs="+", |
|
|
|
help="the source image file(s)") |
|
|
@@ -129,6 +135,8 @@ sub_record.add_argument( |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
if args.command == "match": |
|
|
|
if args.wait: |
|
|
|
input("Waiting for newline...") |
|
|
|
match(args.faces, cv2.VideoCapture(args.device), args.show) |
|
|
|
elif args.command == "record": |
|
|
|
record(args.face, cv2.VideoCapture(args.device)) |