1#!/usr/bin/python 2# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt 3# 4# This utility generates the test data required for the tests contained in test_numpy_returns.py 5# 6# Also note that this utility requires Numpy which can be installed 7# via the command: 8# pip install numpy 9import sys 10import dlib 11import numpy as np 12import utils 13 14if len(sys.argv) != 2: 15 print( 16 "Call this program like this:\n" 17 " ./generate_numpy_returns_test_data.py shape_predictor_5_face_landmarks.dat\n" 18 "You can download a trained facial shape predictor from:\n" 19 " http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2\n") 20 exit() 21 22 23detector = dlib.get_frontal_face_detector() 24predictor = dlib.shape_predictor(sys.argv[1]) 25 26img = dlib.load_rgb_image("../../../examples/faces/Tom_Cruise_avp_2014_4.jpg") 27dets = detector(img) 28shape = predictor(img, dets[0]) 29 30utils.save_pickled_compatible(shape, "shape.pkl") 31 32face_chip = dlib.get_face_chip(img, shape) 33np.save("test_face_chip", face_chip)