-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
59 lines (43 loc) · 1.81 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import unittest # For unit testing
import cv2 # For video rendering
import os # For file operations
# NON_FUNCTIONAL
# WIP
from perfect_photo import PerfectPhoto
"""Test PerfectPhoto on images within a given directory"""
class TestImages(unittest.TestCase):
def __init__(self, true_dir, false_dir):
self.true_dir = os.getcwd()
self.false_dir = os.getcwd()
self.test = PerfectPhoto()
def test_single_face(self):
# TODO: Read all images from storage directory, analyze them with perfect_photo
for img in os.listdir(self.img_dir):
image = cv2.imread(img)
analyzed, features, expressions = self.test.analyze_img(image)
# TODO: Render results on image and display, verify test results
self.assertEqual(len(features), 1)
self.assertListEqual(expressions, [{"eyes_open": True, "smiling": True}])
# Show test images
cv2.imshow("Test Image " + f"'{self.img_dir}'", analyzed) # Display the processed image
cv2.waitKey(0)
cv2.destroyAllWindows() # Destroy windows
def test_multi_face(self):
test = PerfectPhoto(self.img_dir)
cv2.imshow("Tested Image " + f"'{self.img_dir}'", test) # Display the processed frames
"""Test PerfectPhoto on videos within a given directory"""
class TestVideo(unittest.TestCase):
def __init__(self, dir):
self.img_dir = dir
def test_single_face(self):
test = PerfectPhoto()
def test_multi_face(self):
test = PerfectPhoto()
"""Test PerfectPhoto on a live feed from a given webcam"""
class TestWebcam(unittest.TestCase):
def __init__(self, dir):
self.img_dir = dir
def test_single_face(self):
test = PerfectPhoto()
def test_multi_face(self):
test = PerfectPhoto()