Live visualisation of various facial recognition algorithms.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.9 KiB

import argparse
import face_recognition.comparison
import cv2
from multiprocessing import freeze_support
import os
if __name__ == '__main__':
freeze_support() # support pyinstaller on Windows
parser = argparse.ArgumentParser(description='Visualise face recognition algorithms.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--camera', '-c', type=int, default=0,
help='Numeric id of the camera')
parser.add_argument('--windowed', '-w', action='store_true',
help='Display output windowed instead of fullscreen')
parser.add_argument('--clockwise', action='store_true',
help='Rotate clockwise')
parser.add_argument('--counter-clockwise', action='store_true',
help='Rotate counter clockwise')
parser.add_argument('--cascade', default=os.path.join(os.path.dirname(os.path.realpath(__file__)),'haarcascade_frontalface_alt2.xml'),
help='Cascade XML file to use (opencv format)')
parser.add_argument('--output', metavar="DIRECTORY", default=os.path.expanduser("~/Desktop/faces"),
help='Directory to store images (after pressing spacebar)')
parser.add_argument('--visualhaar-lib', metavar="LIBRARY", default=None,
help='path/filename for visualhaar library (.so on linux, .dll on windows)\nSee: https://git.rubenvandeven.com/r/visualhaar/releases')
args = parser.parse_args()
rotate = None
if args.clockwise:
rotate = cv2.ROTATE_90_CLOCKWISE
if args.counter_clockwise:
rotate = cv2.ROTATE_90_COUNTERCLOCKWISE
if not os.path.exists(args.output):
print("Making directory:", args.output)
os.mkdir(args.output)
face_recognition.comparison.main(args.camera, rotate, not args.windowed, args.cascade, args.output, args.visualhaar_lib)