eye detector wasn't initialized for ssd backend

This commit is contained in:
serengil 2020-12-08 09:49:36 +03:00
parent ad54c01b74
commit 08ce14e151
2 changed files with 18 additions and 10 deletions

View File

@ -40,19 +40,27 @@ def initialize_detector(detector_backend):
home = str(Path.home())
#eye detector is common for opencv and ssd
if detector_backend == 'opencv' or detector_backend == 'ssd':
opencv_path = get_opencv_path()
eye_detector_path = opencv_path+"haarcascade_eye.xml"
if os.path.isfile(eye_detector_path) != True:
raise ValueError("Confirm that opencv is installed on your environment! Expected path ",eye_detector_path," violated.")
global eye_detector
eye_detector = cv2.CascadeClassifier(eye_detector_path)
#------------------------------
#face detectors
if detector_backend == 'opencv':
opencv_path = get_opencv_path()
face_detector_path = opencv_path+"haarcascade_frontalface_default.xml"
eye_detector_path = opencv_path+"haarcascade_eye.xml"
if os.path.isfile(face_detector_path) != True:
raise ValueError("Confirm that opencv is installed on your environment! Expected path ",face_detector_path," violated.")
face_detector = cv2.CascadeClassifier(face_detector_path)
global eye_detector
eye_detector = cv2.CascadeClassifier(eye_detector_path)
elif detector_backend == 'ssd':

View File

@ -17,14 +17,14 @@ print("-----------------------------------------")
print("Face detectors test")
print("opencv detector")
res = DeepFace.verify(dataset, detector_backend = 'opencv')
print(res)
print("ssd detector")
res = DeepFace.verify(dataset, detector_backend = 'ssd')
print(res)
print("opencv detector")
res = DeepFace.verify(dataset, detector_backend = 'opencv')
print(res)
print("dlib detector")
res = DeepFace.verify(dataset, detector_backend = 'dlib')
print(res)