Exemplo n.º 1
0
 def test_add_nose(self):
     img = cv2.imread(img_path)
     nosed_img_path = os.path.join(dir_path, 'tests/n-xinwen.jpg')
     paste_face(img, ['recipe_nose'])
     expected_nosed_img = cv2.imread(nosed_img_path)
     diff = im_diff(img, expected_nosed_img)
     print('diff = ', diff)
     self.assertLess(diff, 1)
Exemplo n.º 2
0
    def test_add_sun_glasses_and_moustache(self):
        img = cv2.imread(img_path)
        pasted_path = os.path.join(dir_path, 'tests/em-xinwen.jpg')
        paste_face(img, ['recipe_sun_glasses', 'recipe_moustache'])
        expected = cv2.imread(pasted_path)

        diff = im_diff(img, expected)
        print('diff === ', diff)
        self.assertLess(diff, 1)
Exemplo n.º 3
0
    def test_sub_image(self):
        image_path = os.path.join(dir_path, './tests/xinwen.jpg')
        sub_image_path = os.path.join(dir_path, './tests/sub-xinwen.jpg')
        img = cv2.imread(image_path)
        cv2.imshow('Test', img)

        sub_img = sub_image(img, 0, 0, 100, 100)
        expected_sub_img = cv2.imread(sub_image_path)
        cv2.imshow('Test1', sub_img)

        diff = im_diff(sub_img, expected_sub_img)
        print('diff = ', diff)
        self.assertLess(diff, 1)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
Exemplo n.º 4
0
    def test_add_sun_glasses(self):
        img = cv2.imread(img_path)
        sun_glasses_img_path = os.path.join(dir_path, 'tests/e-xinwen.jpg')
        paste_face(img, ['recipe_sun_glasses'])
        expected = cv2.imread(sun_glasses_img_path)

        diff = im_diff(img, expected)
        print('diff == ', diff)

        if diff > 1:
            cv2.imshow('actual', img)
            cv2.imshow('expected', expected)
            cv2.waitKey(0)
            cv2.destroyAllWindows()

        self.assertLess(diff, 1)
Exemplo n.º 5
0
    def test_paster_effect(self):
        image_path = os.path.join(dir_path, './tests/xinwen.jpg')
        paster_path = os.path.join(dir_path, './pasters/moustache.png')
        pasted_path = os.path.join(dir_path, './tests/paster-xinwen.jpg')
        img = cv2.imread(image_path)
        paster = cv2.imread(paster_path)

        add_paster(img, paster, 100, 100, 100, None)
        cv2.imshow('Test', img)

        print('img dimension = ', img.shape)

        pasted = cv2.imread(pasted_path)

        print('pasted dimension = ', pasted.shape)
        cv2.imshow('Test1', pasted)
        cv2.waitKey(0)

        diff = im_diff(pasted, img)
        print('diff 2 = ', diff)

        self.assertLess(diff, 1)
        cv2.waitKey(0)
        cv2.destroyAllWindows()