Exemplo n.º 1
0
    def test_apply_transformation_to_image(self):

        counter = 0
        self.image_transformer.modified_image = self.image_transformer.create_new_image(
        )

        for original_face_idx, original_face in self.image_transformer.original_face_to_vts.items(
        ):
            original_image_points, modified_image_points = self.image_transformer.get_all_image_points(
                original_face_idx)
            matrix_computer = MatrixComputer(original_image_points,
                                             modified_image_points)
            sections = matrix_computer.get_transforming_triangles()
            matrices = matrix_computer.get_transformations(sections)

            for triangles, matrix in zip(sections, matrices):
                source_triangle, destination_triangle = triangles
                self.image_transformer.apply_transformation_to_image(
                    source_triangle, destination_triangle, matrix)
                filename = self.get_apply_transformation_filename(counter)
                self.image_transformer.modified_image.save(filename)
                counter += 1

        for step_number in self.transformations:
            expected = self.get_expected_applied_filename(step_number)
            actual = self.get_apply_transformation_filename(step_number)
            self.assertTrue(
                self.image_equal(expected, actual),
                "transformation_" + str(step_number) + ".pngs are not equal ")

        self.teardown_apply_transformation_to_image()
Exemplo n.º 2
0
    def setUp(self):
        #the points are picked because they're a simple translation
        source_pts = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]
        destination_pts = [(1.0, 0.0), (2.0, 0.0), (2.0, 1.0), (1.0, 1.0)]

        self.computer = MatrixComputer(source_pts, destination_pts)