def pwa_demo(datadir='data/CK'): images, shapes, mean_shape = get_random_faces(datadir) transformed = [ pwa.warp(im, shape, mean_shape) for im, shape in zip(images, shapes) ] # implot(zip(images, transformed)) # interlieve, not zip! implot(images + transformed)
def test_facedet(self): im_file_path = glob(join(self.data_dir, 'images/*'))[0] im = imread(im_file_path) rects = facedet(im) for i, j, h, w in rects: cv2.rectangle(im, (j, i), (j + w, i + h), color=(0, 255, 0), thickness=3) implot(im)
def test_basic_pwa(self): data_tuples = read_images_and_landmarks(self.data_dir) im0, lms0 = data_tuples[0] tri0 = delaunay(lms0) im0 = draw_tri(im0, lms0, tri0) im1, lms1 = data_tuples[1] tri1 = delaunay(lms1) im1 = draw_tri(im1, lms1, tri1) im1to0 = pwa.warpTriangle(im1, lms1[:, [1, 0]], lms0[:, [1, 0]], tri1, im0.shape) implot([im0, im1, im1to0])
def test_delaunay(self): im, lms = read_images_and_landmarks(self.data_dir)[0] tri = delaunay(lms) implot(draw_tri(im, lms, tri))
def test_draw_landmarks(self): images_and_landmarks = read_images_and_landmarks(self.data_dir)[:4] marked_images = [ draw_landmarks(im, lm) for im, lm in images_and_landmarks ] implot(marked_images)
def pwa_demo(datadir='data/CK'): images, shapes, mean_shape = get_random_faces(datadir) transformed = [pwa.warp(im, shape, mean_shape) for im, shape in zip(images, shapes)] # implot(zip(images, transformed)) # interlieve, not zip! implot(images + transformed)