Last active
November 4, 2022 17:41
-
-
Save SULAIMAN-5-AHMED/783efa8f4c0137286a2ad0ab5ea8ebe8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import mediapipe as mp | |
cap = cv2.VideoCapture(0) | |
mpDraw = mp.solutions.drawing_utils | |
mpPose = mp.solutions.pose | |
pose = mpPose.Pose() | |
while True: | |
success, img = cap.read() | |
imgRgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
results = pose.process(imgRgb) | |
if results.pose_landmarks: | |
mpDraw.draw_landmarks(img, results.pose_landmarks, mpPose.POSE_CONNECTIONS) | |
for id, lm in enumerate(results.pose_landmarks.landmark): | |
h, w, c = img.shape | |
cx, cy = int(lm.x * w), int(lm.y * h) | |
cv2.circle(img, (cx, cy), 9, (0, 0, 255), cv2.FILLED) | |
cv2.imshow('VID', img) | |
cv2.waitKey(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment