|
|
|
|
|
""" |
|
Created on Sun Aug 4 14:49:57 2024 |
|
|
|
@author: ysnrfd |
|
""" |
|
|
|
import cv2 |
|
import mediapipe as mp |
|
|
|
|
|
mp_pose = mp.solutions.pose |
|
pose = mp_pose.Pose() |
|
|
|
|
|
mp_drawing = mp.solutions.drawing_utils |
|
|
|
|
|
cap = cv2.VideoCapture(0) |
|
|
|
while True: |
|
|
|
ret, frame = cap.read() |
|
if not ret: |
|
break |
|
|
|
|
|
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) |
|
|
|
|
|
results = pose.process(frame_rgb) |
|
|
|
|
|
if results.pose_landmarks: |
|
mp_drawing.draw_landmarks(frame, results.pose_landmarks, mp_pose.POSE_CONNECTIONS) |
|
|
|
|
|
cv2.imshow("Pose Detection", frame) |
|
|
|
|
|
if cv2.waitKey(1) & 0xFF == ord('q'): |
|
break |
|
|
|
|
|
cap.release() |
|
cv2.destroyAllWindows() |
|
|