-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoseEstimation.py
23 lines (19 loc) · 1016 Bytes
/
PoseEstimation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2
from exercices_types import TypeOfExercise
from Body_part_angle import BodyPartAngle
import numpy as np
from utils import *
import mediapipe as mp
class poseDetector():
def __init__(self, detection_confidence = 0.5, track_confidence= 0.5):
self.detection_confidence = detection_confidence
self.track_confidence = track_confidence
self.mp_draw = mp.solutions.drawing_utils
self.mp_pose = mp.solutions.pose
self.Pose = self.mp_pose.Pose(min_detection_confidence=self.detection_confidence, min_tracking_confidence =self.track_confidence)
def findPose(self, frame, draw=True):
results = self.Pose.process(frame)
if results.pose_landmarks:
if draw:
self.mp_draw.draw_landmarks(frame, results.pose_landmarks, self.mp_pose.POSE_CONNECTIONS, self.mp_draw.DrawingSpec(color=(255,0,0), thickness=2, circle_radius=2), self.mp_draw.DrawingSpec(color=(174, 139, 45), thickness=2, circle_radius=2))
return results