def main(aligner_fname, cascade_fname, image_fnames): aligner = Aligner(aligner_fname) cascade = load_cascade(cascade_fname) images = (pvImage(fname) for fname in image_fnames) return [ aligner.align_face(detect_faces(img, cascade)[0], img) for img in images ]
def main(img_dir,pts_dir,haar_file,num_trains): t = Trainer() cascade = load_cascade(haar_file) sglob = lambda dir: sorted(glob(dir+"/*")) paths = izip(sglob(img_dir),sglob(pts_dir)) # split into training and testing for im,pf in islice(paths,num_trains): img = pvImage(im) pts = read_pointsfile(pf) faces = detect_faces(img,cascade) if faces: t.add_training_image(img,pts,faces[0]) else: print "No face found for %s"%im t.train() t.export_aligner('aligner.yaml')
def main(aligner_fname, cascade_fname, image_fnames): aligner = Aligner(aligner_fname) cascade = load_cascade(cascade_fname) images = (pvImage(fname) for fname in image_fnames) return [aligner.align_face(detect_faces(img, cascade)[0], img) for img in images]