from cvzone.FaceDetectionModule import FaceDetector
import cv2

ESC = 27

cap = cv2.VideoCapture(0)
ratio = cap.get(cv2.CAP_PROP_FRAME_WIDTH) / cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
WIDTH = 400
HEIGHT = int(WIDTH / ratio)

detector = FaceDetector()

while cap.isOpened():
    success, img = cap.read()
    img = cv2.resize(img, (WIDTH, HEIGHT)) 

    img, bboxs = detector.findFaces(img)

    if bboxs:
        # bboxInfo - 'id', 'bbox', 'score', 'center'
        center = bboxs[0]['center']
        cv2.circle(img, center, 5, (255, 0, 255), cv2.FILLED)

    cv2.imshow('Image', img)
    if cv2.waitKey(1) == ESC:
        break
        
cap.release()
cv2.destroyAllWindows()