-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (25 loc) · 1.17 KB
/
Copy pathmain.py
File metadata and controls
34 lines (25 loc) · 1.17 KB
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
from FaceDetector import FaceDetector
from Utils import load_images
from Utils import convert_images_to_greyscale
from Utils import draw_face_area
from PIL import Image
def main():
pos_training_path = 'training_data/faces'
neg_training_path = 'training_data/nonfaces'
pos_testing_path = 'training_data/faces/test'
neg_testing_path = 'training_data/nonfaces/test'
pos_result_testing_path = 'training_data/faces/test/results/'
neg_result_testing_path = 'training_data/nonfaces/test/results/'
images = load_images(pos_testing_path)
greyscale_images = convert_images_to_greyscale(images)
face_detector = FaceDetector("classifiers/lbpcascade_frontalface.xml")
for image_index in range(0, len(greyscale_images)):
print(f"Image: {image_index}")
faces = face_detector.detect(greyscale_images[image_index], 1.0, 1.1, 0.1, 3)
image = Image.fromarray(images[image_index])
for face in faces:
print(f"Detect - x: {face.x}, y: {face.y}, size: {face.size}")
draw_face_area(image, face)
image.save(pos_result_testing_path + "test" + str(image_index) + ".png")
if __name__ == '__main__':
main()