import cv2
from cvzone.PoseModule import PoseDetectorif __name__ == '__main__':# cap = cv2.VideoCapture('2.mp4')cap = cv2.VideoCapture(0)detector = PoseDetector()posList = []while True:success, img = cap.read()img = detector.findPose(img)# 获取33个点的每一帧放到lmList和bboxInfo数组中lmList, bboxInfo = detector.findPosition(img)# 将每一帧的33个点的xyz拼接好放到lmString中,最后放到posList数组中if bboxInfo:lmString = ''for lm in lmList:lmString += f'{lm[1]},{img.shape[0]-lm[2]},{lm[3]},'posList.append(lmString)# 打印有多少帧数print(len(posList))cv2.imshow("Image", img)# 按下S键就保存信息key = cv2.waitKey(1)if key == ord('s'):with open("AnimationFile.txt", 'w') as f:# 一帧对应一行f.writelines(["%s\n" % item for item in posList])