def test_align_shapes(self): s1 = Shape([(1, 2), (1, 3), (1, 4), (2, 4), (3, 4), (3, 3), (3, 2), (2, 2)]) s2 = Shape([(5, 2), (6, 3), (7, 4), (8, 3), (9, 2), (8, 1), (7, 0), (6, 1)]) Shape.translate_all_to_origin([s1, s2]) s2.align(s1) npt.assert_almost_equal(s1.points, s2.points, decimal=1)
def main(): train_directory = '/home/mihai/Proiecte/AAM/Dataset/' shape_train_files = [] texture_train_files = [] for file_name in os.listdir(train_directory): if file_name.endswith(".pts"): file_name = os.path.splitext(file_name)[0] file_path = os.path.join(train_directory, file_name) shape_train_files.append(file_path + '.pts') texture_train_files.append(file_path + '.pgm') train_shapes = Shape() train_shapes.load(shape_train_files) aligned_shapes = train_shapes.align() mean_shape = Shape.mean(aligned_shapes) pca = train_shapes.pca(train_shapes.shapes) train_textures = Texture() train_textures.load(texture_train_files, train_shapes.shapes, mean_shape)