So I am new to working with mediapipe and extremely confused in how to use mediapipe pose detector. I have a video, and I am using openCV to access the frames of that video and the using pose() to get all the keypoints of the video. sounds good? but the optput is not a list or anything its something else 'NormalizedLandmark' and i just cannot iterate it.
what I want to do is:
- access the video one frame at a time
- while accessing the first frame use pose() function to get all four (x,t,z,V) coordinates of the 33 keypoints
- put these 33*4 elements seperated by commas in one list
- access the second frame and repeat the process untill all frames are over
- put all these lists in another list.
let no. of frames are 204 then, output shape will be (204,132) 132 because 4 coordinates and 33 poses, 33*4=132
How I am trying to do this is:
lm_list = []
cap = cv2.VideoCapture('/content/drive/MyDrive/Sample poses/standing p1.mp4')
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
# Convert the frame to RGB
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
result = pose.process(frame_rgb)
if result.pose_landmarks:
for idx, landmark in enumerate(result.pose_landmarks.landmark):
lm_list.append([landmark.x, landmark.y, landmark.z, landmark.visibility])
Would be a great help!