# Mask is inconsistent

**URL:** <https://community.stereolabs.com/t/mask-is-inconsistent/3454>\
**Category:** Python\
**Created:** [September 8, 2023, 6:39am UTC](https://community.stereolabs.com/t/mask-is-inconsistent/3454 "2023-09-08T06:39:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gopi-htic](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gopi-htic/32/1719_2.png) [@Gopi-htic](https://community.stereolabs.com/u/Gopi-htic)\
**Post date:** [September 8, 2023, 6:39am UTC](https://community.stereolabs.com/t/mask-is-inconsistent/3454/1 "2023-09-08T06:39:38Z")

</div>

I’m trying to get the mask of humans, but it is inconsistent.

```auto

import cv2
import sys
import time
import pyzed.sl as sl
import numpy as np
import argparse
import math
import numpy as np
from matplotlib import pyplot as plt
from skimage.measure import label, regionprops, regionprops_table
import pygame
from pygame.locals import *

from OpenGL.GL import *
from OpenGL.GLU import *

def main():

   
    print("Running Body Tracking sample ... Press 'q' to quit, or 'm' to pause or restart")

    # Create a Camera object
    zed = sl.Camera()

    # Create a InitParameters object and set configuration parameters
    init_params = sl.InitParameters()
    #init_params.camera_fps = 30 # Set fps at 30

    init_params.camera_resolution = sl.RESOLUTION.HD1080 # Use HD1080 video mode
    init_params.coordinate_units = sl.UNIT.CENTIMETER # Set coordinate units
    init_params.depth_mode = sl.DEPTH_MODE.QUALITY
    init_params.coordinate_system = sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP
    
    # Open the camera
    err = zed.open(init_params)
    if err != sl.ERROR_CODE.SUCCESS:
        exit(1)

    # Enable Positional tracking (mandatory for object detection)
    positional_tracking_parameters = sl.PositionalTrackingParameters()
    # If the camera is static, uncomment the following line to have better performances
    # positional_tracking_parameters.set_as_static = True
    zed.enable_positional_tracking(positional_tracking_parameters)
    
    body_param = sl.BodyTrackingParameters()
    body_param.enable_segmentation = True
    body_param.enable_tracking = True # Track people across images flow
    body_param.enable_body_fitting = False # Smooth skeleton move
    body_param.detection_model = sl.BODY_TRACKING_MODEL.HUMAN_BODY_FAST
    body_param.body_format = sl.BODY_FORMAT.BODY_18 # Choose the BODY_FORMAT you wish to use

    # Enable Object Detection module
    zed.enable_body_tracking(body_param)

    body_runtime_param = sl.BodyTrackingRuntimeParameters()
    body_runtime_param.detection_confidence_threshold = 40

    # Get ZED camera information
    camera_info = zed.get_camera_information()
    # 2D viewer utilities
    
    
    bodies = sl.Bodies()
    image = sl.Mat()
    depth = sl.Mat()
    display_resolution = sl.Resolution(min(camera_info.camera_configuration.resolution.width, 1280), min(camera_info.camera_configuration.resolution.height, 720))
    key_wait = 10 

   
    while True:
        # Grab an image
        time_temp=time.time()

        if zed.grab() == sl.ERROR_CODE.SUCCESS:
            print("TIME",time.time()-time_temp)
            # Retrieve left image
            zed.retrieve_image(image, sl.VIEW.LEFT, sl.MEM.CPU)
            # Retrieve bodies
            zed.retrieve_measure(depth, sl.MEASURE.DEPTH)
            zed.retrieve_bodies(bodies, body_runtime_param)
            bodies_list=bodies.body_list 
            image_left_ocv = image.get_data()
            key = cv2.waitKey(key_wait)
            cv2.imshow("ZED | 2D View", image_left_ocv)
            cv2.waitKey(1)
            print("FPS : ",zed.get_current_fps())
            if key == 113: # for 'm' key
                for body in bodies_list:
                    print("body ID ",body.id, " Position ",body.keypoint_2d[2])
                    mask=body.mask
                    temp=mask.get_data()
                    if body.mask.is_init():
                        print(temp)
                        plt.imshow(temp)
                        plt.show()
                        print(temp.shape)

                break
    
    image.free(sl.MEM.CPU)
    zed.disable_body_tracking()
    zed.disable_positional_tracking()
    zed.close()
    cv2.destroyAllWindows()
    
if __name__ == ' __main__':
    
    main() 

```

Sometime the mask is completely captured.

 ![image](https://community.stereolabs.com/uploads/default/original/2X/4/4ced23f435789812f25d0e2b49fe1634020755cb.jpeg)  
But mostly, the mask is not fully captured.  
 ![image](https://community.stereolabs.com/uploads/default/original/2X/d/d0a0e12791939dada7975136e71426bf8a5a3fa7.jpeg)

---

<div class="post-metadata">

**Author:** ![JPlou](https://community.stereolabs.com/user_avatar/community.stereolabs.com/jplou/32/1012_2.png) [@JPlou](https://community.stereolabs.com/u/JPlou)\
**Post date:** [September 12, 2023, 4:02pm UTC](https://community.stereolabs.com/t/mask-is-inconsistent/3454/2 "2023-09-12T16:02:57Z")

</div>

@Gopi-htic,  
Thanks for reporting this, we’ll investigate it and get back to you.  
Do you have the issue with all depth modes / body models?

---

<div class="post-metadata">

**Author:** ![alassagne](https://community.stereolabs.com/user_avatar/community.stereolabs.com/alassagne/32/2428_2.png) [@alassagne](https://community.stereolabs.com/u/alassagne)\
**Post date:** [November 18, 2023, 7:26am UTC](https://community.stereolabs.com/t/mask-is-inconsistent/3454/3 "2023-11-18T07:26:23Z")

</div>

Hi @Gopi-htic

We’ve reproduced and fixed this issue thanks to another user that sent us a SVO. It will be part of the next release. If you are interested in a early version, you can ask me.
