def test_frontal_face_detector(): takeo_copy = takeo.copy() dlib_detector = load_dlib_frontal_face_detector() pcs = dlib_detector(takeo_copy) assert len(pcs) == 1 assert takeo_copy.n_channels == 3 assert takeo_copy.landmarks['dlib_0'][None].n_points == 4
def test_frontal_face_detector_rgb(): takeo_copy = takeo.copy() assert takeo_copy.n_channels == 3 dlib_detector = load_dlib_frontal_face_detector() pcs = dlib_detector(takeo_copy, greyscale=False) assert len(pcs) == 1 assert takeo_copy.n_channels == 3 assert takeo_copy.landmarks['dlib_0'].n_points == 4
if args.input_dir: options['input_dir'] = args.input_dir if args.output_dir: options['output_dir'] = args.output_dir if args.model: options['model'] = args.model if args.file: options['file'] = args.file if args.output: options['output'] = args.output return options if __name__ == '__main__': options = parse_options() fit_image.detect = load_dlib_frontal_face_detector() fit_image.fitter = DlibWrapper(options['model']) if 'file' in options: video_file = options['file'] video_file_basename = os.path.basename(video_file) print('Generating Landmarks from {}'.format(video_file)) output = options['output'] if 'output' in options else os.path.splitext(video_file_basename)[0] + '.csv' process_video(video_file, output) exit() print('Generating Landmarks from {}'.format(options['input_dir'])) videofiles = find_all_videos(options['input_dir'], relpath=False) videofiles.sort() print('Found {} video(s)...'.format(len(videofiles))) input_dir = os.path.abspath(options['input_dir'])
def __init__(self, model): self.detector = load_dlib_frontal_face_detector() self.fitter = DlibWrapper(model)
import os import shutil from menpofit.aam import load_balanced_frontal_face_fitter from menpo.shape import TexturedTriMesh from menpo3d.morphablemodel import ColouredMorphableModel from menpodetect.dlib import load_dlib_frontal_face_detector from menpofit.dlib import DlibWrapper from menpo3d.morphablemodel.fitter import LucasKanadeMMFitter from menpo.transform import image_coords_to_tcoords from PIL import Image from pathlib import Path detect = load_dlib_frontal_face_detector() aam_fitter = load_balanced_frontal_face_fitter() shape_model, landmarks = mio.import_pickle( "Child Customisation/pkls/children_under7.pkl") texture_model = mio.import_pickle('Child Customisation/pkls/fast_dsift.pkl') tcoords, bcoords_img, tri_index_img = mio.import_pickle( 'Child Customisation/pkls/unwrapped_template_barycentrics.pkl') def extract_texture(mesh_in_image, background): TI = tri_index_img.as_vector() BC = bcoords_img.as_vector(keep_channels=True).T sample_points_3d = mesh_in_image.project_barycentric_coordinates(BC, TI)