mediapipe
mediapipe copied to clipboard
Mediapipe Pose livestream segmentation causes Python to quit
I am trying to run Mediapipe Pose in livestream mode
options = PoseLandmarkerOptions(
base_options=BaseOptions(model_asset_path='pose_landmarker_full.task'),
running_mode=VisionRunningMode.LIVE_STREAM,
output_segmentation_masks=True,
result_callback=print_result)
with PoseLandmarker.create_from_options(options) as pose:
cap = cv2.VideoCapture(0)
i = 0
while (1):
succes, image = cap.read()
image = np.array(image)
imgRGB = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=imgRGB)
pose.detect_async(mp_image,i)
i += 1
however, if I try to output the segmentation mask, the Python interpreter quits without any error messages I have narrowed it down to this line
def print_result(result: PoseLandmarkerResult, output_image: mp.Image, timestamp_ms: int):
alpha= result.segmentation_masks[0].numpy_view()
if that code is alpha= result.segmentation_masks
, then Mediapipe will run and alpha
is of type mediapipe.python._framework_bindings.image.Image object
but if I wish to return the pixel data with .numpy_view() , it will cause Python to quit without any messages