import cv2
import time
import mediapipe as mp
import PoseEstimationModule
from PoseEstimationModule import PoseEstimation


cap = cv2.VideoCapture(0)
pTime = 0
cTime = 0
detector = PoseEstimation()
while True:
    _, frame = cap.read()
    frame = detector.findPose(frame)
    lmList = detector.findPosition(frame, draw=False)
    if len(lmList) != 0:
        print(lmList[4])

    cTime = time.time()
    fps = 1/(cTime-pTime)
    pTime = cTime

    cv2.putText(frame, str(int(fps)), (10,70), cv2.FONT_HERSHEY_PLAIN, 3, (255,0,0), 3)

    cv2.imshow("frame", frame)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break


cv2.destroyAllWindows()