C++ Objects to Unity

My problem is that I generate a JSON file with all the sl::Objects for body tracking using 4 different cameras. Then I need to read the file in Unity and somehow move the avatar accordingly.

Any idea how to do the Unity part, because I don’t see at what point the joints are passed to the avatar.ecause I don’t see in wich spot the joints are passed to the avatar.


I think the easiest way is to create sl.Objects in Unity with the data read from the json.
That way you can reuse most of the code, you only have to change from where you get the sl.Objects data.
You should take a look at the script called : ZEDSkeletonTrackingViewer.cs(https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/SkeletonTracking/ZEDSkeletonTrackingViewer.cs#L124).

Best regards,
Benjamin Vallon

Thanks for your response!!
I find out the function private void UpdateAvatarControl(SkeletonHandler handler, sl.ObjectDataSDK data, bool useAvatar) in the script ZEDSkeletonTrakingViewer.cs will do de job.

But now, the thing is that the joints I do obtain in the C++ SDK are not the same that the ones extracted in UNITY (the sl.ObjectDataSDK object), even if I define the coordinate_system in the C++ SDK to COORDINATE_SYSTEM::LEFT_HANDED_Y_UP.
For example, the first join on the first frame of the same svo file extracted in UNITY is (0.5,-0.4,1.0), but in the C++ SDK is (0.0, -0.2, 0.0).

Any idea why this happens? Thanks again!

I find out that that i was using data.skeletonJointPosition and not data.localPositionPerJoint, finally the localPositionPerJoint are both the same in Unity and C++ SDK, but how do I get the values of skeletonJointPosition using the localPositionPerJoint ?


In Unity, data.skeletonJointPosition is the equivalent of data.keypoint in the SDK.
The naming has not been updated in Unity to match the c++ sdk which is not very convenient. The update is planned for a near future.

keypoint contains the skeleton data in global frame whereas local_position_per_joint are store in local frame (relative to its parent). You can find the skeleton hierarchy in the documentation.

That whas it!!
Thank you so much!

1 Like