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
Hi,
You should use the mask
property of the BodyData
object :
https://www.stereolabs.com/docs/api/classsl_1_1BodyData.html#a4c475a9ddaa98bf7cfcc8a5bdea7b0e2
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