# label_dict = classifier.get_label_dict(ROOT_DIR + '/models/labels.json') # ----------------------------------------------------------------- classifier = FaceClassifier() # classifier.set_model_path(ROOT_DIR + '/models/model_09_02.h5') classifier.set_model_path(ROOT_DIR + '/models/model_12_02.h5') # classifier.set_label_path(ROOT_DIR + '/models/labels.json') label_dict = classifier.get_label_dict(ROOT_DIR + '/models/labels.json') face_detected = False while (True): # Capture frame-by-frame ret, frame = cap.read() # Handles the mirroring of the current frame frame = cv2.flip(frame, 1) if p.extract_video_face(frame) != None: face_detected = True faces = p.extract_video_face(frame) for (x1, x2, y1, y2) in faces: # print(x1, x2, y1, y2) # x1, x2, y1, y2 = p.extract_video_face(frame) cv2.rectangle(frame, (x1 - 8, y1 - 8), (x2 + 8, y2 + 8), (0, 0, 255), 2) pixels = np.asarray(frame) face = pixels[y1:y2, x1:x2] # resize pixels to the models size output_image = np.array(face) face_pixel = np.asarray(output_image) face_pixel = cv2.resize(face_pixel, (160, 160))