コード例 #1
0
ファイル: Utils.py プロジェクト: 10a-/pyinyourface
def visualize(fname,points,index=None,face_rect=None):
	pvimg = pvImage(fname)
	for p in points: pvimg.annotatePoint(p)
	if index: pvimg.annotateLabel((0,0),str(index))
	if face_rect: pvimg.annotateRect(face_rect)
	name,ext = splitext(basename(fname))
	pvimg.asAnnotated().save("%s_viz%s%s"%(name,'_%02d'%index if index else '',ext))
コード例 #2
0
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
    ]
コード例 #3
0
ファイル: Utils.py プロジェクト: nagyistge/LipReading-1
def visualize(fname, points, index=None, face_rect=None):
    pvimg = pvImage(fname)
    for p in points:
        pvimg.annotatePoint(p)
    if index: pvimg.annotateLabel((0, 0), str(index))
    if face_rect: pvimg.annotateRect(face_rect)
    name, ext = splitext(basename(fname))
    pvimg.asAnnotated().save("%s_viz%s%s" %
                             (name, '_%02d' % index if index else '', ext))
コード例 #4
0
ファイル: train.py プロジェクト: PREETHUP/LipReading
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')
コード例 #5
0
ファイル: align.py プロジェクト: rosnikv/LipReading
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]