深度CV项目就业小班第9期
CV项目肢体动作识别
代码:
import CV2import(已报名深度之👀 获课底部) mediapipe as mpimport time
mpDraw = mp.solutions.drawing_utils
mpPose = mp.solutions.pose
pose = mpPose.Pose()cap = CV2.VideoCapture('PoseVideos/3.mp4')pTime = 0while True:
success, img = cap.read()
imgRGB = CV2.cvtColor(img, CV2.COLOR_BGR2RGB)
results = pose.process(imgRGB)
# print(results.pose_landmarks)
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
print(id, lm)
cx, cy = int(lm.x * w), int(lm.y * h)
CV2.circle(img, (cx, cy), 5, (255, 0, 0), CV2.FILLED)
cTime = time.time()
fps = 1 / (cTime - pTime)
pTime = cTime
CV2.putText(img, str(int(fps)), (70, 50), CV2.FONT_HERSHEY_PLAIN, 3,
(255, 0, 0), 3)
CV2.imshow("Image", img)
CV2.waitKey(1)