def demo(det_models, face_id_model, reference, crop_size, id_npy, max_size, font):
    cap = cv2.VideoCapture(0)
    name_to_last_time_seen = {}
    try:
        while cap.isOpened():
            start_time = time.time()
            (ret, image_np) = cap.read()
            if (ret and cap.isOpened()):
                pil_img = Image.fromarray(image_np[..., ::(- 1)])
                pil_img.thumbnail((max_size, max_size))
                (viz_img, names) = process_and_viz_img(pil_img=pil_img, det_models=det_models, face_id_model=face_id_model, reference=reference, crop_size=crop_size, id_npy=id_npy, font=font)
                cur_time = time.time()
                play_sound_if_needed(names=names, name_to_last_time_seen=name_to_last_time_seen, cur_time=cur_time)
                fps = (1.0 / (cur_time - start_time))
                draw_fps(img=viz_img, font=font, fps=fps)
                viz_img_bgr = np.array(viz_img)[..., ::(- 1)]
                cv2.imshow('Face Detection Demo', viz_img_bgr)
            if ((cv2.waitKey(1) & 255) == ord('q')):
                break
    finally:
        cap.release()
        cv2.destroyAllWindows()
def demo(det_models, face_id_model, reference, crop_size, id_npy, max_size, font):
    cap = cv2.VideoCapture(0)
    name_to_last_time_seen = {}
    try:
        while cap.isOpened():
            start_time = time.time()
            (ret, image_np) = cap.read()
            if (ret and cap.isOpened()):
                pil_img = Image.fromarray(image_np[..., ::(- 1)])
                pil_img.thumbnail((max_size, max_size))
                (viz_img, names) = process_and_viz_img(pil_img=pil_img, det_models=det_models, face_id_model=face_id_model, reference=reference, crop_size=crop_size, id_npy=id_npy, font=font)
                cur_time = time.time()
                play_sound_if_needed(names=names, name_to_last_time_seen=name_to_last_time_seen, cur_time=cur_time)
                fps = (1.0 / (cur_time - start_time))
                draw_fps(img=viz_img, font=font, fps=fps)
                viz_img_bgr = np.array(viz_img)[..., ::(- 1)]
                cv2.imshow('Face Detection Demo', viz_img_bgr)
            if ((cv2.waitKey(1) & 255) == ord('q')):
                break
    finally:
        cap.release()
        cv2.destroyAllWindows()