Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mediapipe Pose livestream segmentation causes Python to quit #161

Open
ccarmatic opened this issue Jun 8, 2023 · 1 comment
Open

Mediapipe Pose livestream segmentation causes Python to quit #161

ccarmatic opened this issue Jun 8, 2023 · 1 comment

Comments

@ccarmatic
Copy link

ccarmatic commented Jun 8, 2023

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

@ccarmatic ccarmatic changed the title Mediapipe Pose livestream mode segmentation? Mediapipe Pose livestream segmentation causes Python to quit Jun 8, 2023
@PaulTR
Copy link
Collaborator

PaulTR commented Aug 24, 2023

Hey @ccarmatic. I'm waiting for a response internally, but I think this has to do with a lack of flow control in MediaPipe for the segmentation task portion. I was able to replicate it with one of my own projects. It's being looked into. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants