How to remove untracked bodies from list?

Hello,

I am trying to use the body_tracking to get a list of people in a frame and display the coordinate of their chest spine key point. This functionality is working right now.

When a person goes out of camera view/moves behind a person, they are assigned a new body id. This is an issue because I would like to only display the coordinates of people who are in frame. I would like to remove these old bodies from the list when someone is not being tracked anymore.

Could anyone point me in the right direction? I cannot directly point to the index in bodies.body_list because I get an out of bounds error.

Thanks for the assistance!

Hi,

You can filter out the bodies using their OBJECT_TRACKING_STATE (https://www.stereolabs.com/docs/api/python/classpyzed_1_1sl_1_1OBJECT__TRACKING__STATE.html).
In your case, you only want the bodies that are OK, ignore the rest.

Best,
Benjamin V.

Stereolabs Support