Unity: Filter for other detected objects in the BodyTracking module

Hi, I am using the bodyTracking module, but would like to access detected objects other than bodies. I tried registering to the zedManager.OnObjectDetection event, but this did not work. So my question is, how is it possible to retrieve the other objects from the zedManager used in the body tracking module?

I also have a second unrelated question. Pressing the “r” key on my keyboard always changes the offset to the ground for the avatars. Basically, it looks like they jump when pressed. I set all keyboard mappings to None, but this did not solve my problem.

Hi,

The body tracking and the Object detection features are two different modules that can be used simultaneously.
Registering to the OnObjectDetection event is necessary but not sufficient, you also need to start the module by either pressing the “Start Object detection” button in the ZEDManager or calling the “startObjectDetection” method.

It’s strange because I don’t see any code related to the R key in the plugin, and pressing mine does nothing.

Stereolabs Support

When I call the startObjectDetection function I get the following error message:

It seems to work with the button in the ZEDManager, but I would like to do it in the code.

private ZEDManager zedManager;

// Start is called before the first frame update
void Start()
{
    zedManager = ZEDManager.GetInstance(ZED_CAMERA_ID.CAMERA_ID_01);
    zedManager.StartObjectDetection();
    zedManager.OnObjectDetection += OnObjectDetection;
}

The R key problem only occurs when automatic offset is enabled, could you please try reproducing the problem with this setting? Thanks for your help.

You can’t call it on Start, the camera is not ready yet.

For that, use the zedManager.OnZEDReady event.

Something like :

zedManager.OnZEDReady += StartObjectDetection;

And in the StartObjectDetection function, call zedManager.StartObjectDetection();

Stereolabs Support

Thank you, that worked. Could you reproduce my second problem with the R key? As I wrote above, the error only occurs for me when automatic offset is enabled. It’s a bit confusing as I couldn’t find anything in the code that could cause it

I did not manage to reproduce the issue, and as you said, I did not find any code that is triggered by the R key in the plugin.

I finally found the problem. For anyone else who may encounter the same problem with the R key in the future: In the Avatar Prefabs that come with the Bodytracking sample, there is a “Reset Automatic Offset” field that is set to R by default.
image

1 Like