Binary mask body tracking

Hi, I wanted to ask how to retrieve the binary mask images of detectted bodies in the Body Tracking module.
Even with the “enable_segmentation = True” in the BodyTrackingParameters I’m not able to obtain the mask coordinates as json result, neither to have them as images that I can visualize in video as it’s possible to do with the keypoints.
Can anyone provide help? Thanks


You should use the mask property of the BodyData object :

It’s a matrix of point representing what you ask.

Hi alassagne, thanks for your reply.
Yes in the end I solved retrieving the mask with:

body_array = bodies.body_list
        if len(body_array) > 0:
            first_body = body_array[0]
            if first_body.mask.is_init():
                mask = first_body.mask
                mask_cv2 = mask.get_data()
                cv2.imshow("binary mask", mask_cv2)

I’m posting the code in case it would be useful for any other user.

1 Like