def detect_face_video(pose_model):
    face_cascade = cv2.CascadeClassifier((cv2.data.haarcascades + 'haarcascade_frontalface_default.xml'))
    cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    while True:
        (_, img) = cap.read()
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        faces = face_cascade.detectMultiScale(gray, 1.1, 4)
        (yaw, pitch, roll) = pose_d.run_pose_detection(pose_model, pose_d.load_img(img))
        for (x, y, w, h) in faces:
            cv2.rectangle(img, (x, y), ((x + w), (y + h)), (255, 0, 0), 2)
        img = pose_d.draw_labels(yaw, pitch, roll, img)
        cv2.imshow('img', img)
        k = (cv2.waitKey(30) & 255)
        if (k == 27):
            break
    cap.release()
    cv2.destroyAllWindows()
def detect_face_video(pose_model):
    face_cascade = cv2.CascadeClassifier((cv2.data.haarcascades + 'haarcascade_frontalface_default.xml'))
    cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    while True:
        (_, img) = cap.read()
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        faces = face_cascade.detectMultiScale(gray, 1.1, 4)
        (yaw, pitch, roll) = pose_d.run_pose_detection(pose_model, pose_d.load_img(img))
        for (x, y, w, h) in faces:
            cv2.rectangle(img, (x, y), ((x + w), (y + h)), (255, 0, 0), 2)
        img = pose_d.draw_labels(yaw, pitch, roll, img)
        cv2.imshow('img', img)
        k = (cv2.waitKey(30) & 255)
        if (k == 27):
            break
    cap.release()
    cv2.destroyAllWindows()