I want to use MediaPipe for a project with keypoints detection but after writing a code that applies the model to a specific video, I get a RunTime error that I don't know how to correct.Here is the code
cap = cv2.VideoCapture("FitnessBasic/squat/data/000076.mp4")
## Setup mediapipe instance
with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose:
while cap.isOpened():
ret, frame = cap.read()
# Recolor image to RGB
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image.flags.writeable = False
# Make detection
results = pose.process(image)
# Recolor back to BGR
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
# Render detections
mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(245,117,66), thickness=2, circle_radius=2),
mp_drawing.DrawingSpec(color=(245,66,230), thickness=2, circle_radius=2))
cap.release()
And here is the error I encounter
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[8], line 3
1 cap = cv2.VideoCapture("FitnessBasic/squat/data/000076.mp4")
2 ## Setup mediapipe instance
----> 3 with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose:
4 while cap.isOpened():
5 ret, frame = cap.read()
File ~/anaconda3/lib/python3.11/site-packages/mediapipe/python/solutions/pose.py:146, in Pose.__init__(self, static_image_mode, model_complexity, smooth_landmarks, enable_segmentation, smooth_segmentation, min_detection_confidence, min_tracking_confidence)
122 """Initializes a MediaPipe Pose object.
123
124 Args:
(...)
143 https://solutions.mediapipe.dev/pose#min_tracking_confidence.
144 """
145 _download_oss_pose_landmark_model(model_complexity)
--> 146 super().__init__(
147 binary_graph_path=_BINARYPB_FILE_PATH,
148 side_inputs={
149 'model_complexity': model_complexity,
150 'smooth_landmarks': smooth_landmarks and not static_image_mode,
151 'enable_segmentation': enable_segmentation,
152 'smooth_segmentation':
153 smooth_segmentation and not static_image_mode,
...
ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options.
ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options.
SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
SplitNormalizedLandmarkListCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
SplitLandmarkListCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
I tried updating mediapipe
pip install --upgrade mediapipe
And I also tried simplifying the initialization
with mp_pose.Pose() as pose:
But none of those worked.