This commit is contained in:
Mateusz Tylka 2023-01-29 21:14:30 +01:00
parent d28b8dbec4
commit 56eede6777

View File

@ -8,6 +8,7 @@ import numpy as np
from source.cartoonize import Cartoonizer from source.cartoonize import Cartoonizer
def load_source(filename: str) -> np.ndarray: def load_source(filename: str) -> np.ndarray:
return cv2.imread(filename)[...,::-1] return cv2.imread(filename)[...,::-1]
@ -17,7 +18,7 @@ def find_and_crop_face(data: np.ndarray) -> np.ndarray:
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml') face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml')
face = face_cascade.detectMultiScale(data_gray, 1.3, 4) face = face_cascade.detectMultiScale(data_gray, 1.3, 4)
face = max(face, key=len) face = max(face, key=len)
(x, y, w, h) = face x, y, w, h = face
face = data[y:y + h, x:x + w] face = data[y:y + h, x:x + w]
return face return face