This is the Unity Project for using the body tracking module of the Stereolabs Zed Unity module for the animation of a SMPL-X model. It supports just body joint angles tracking since the Zed Body Tracking module generates just the skeleton. The accuracy of the depth of the model is higher than using SOTA RGB methods like HybriIK since the body tracking module leverage on the stereo vision of the Zed camera.
demo.mp4
- Create a new 3D project in Unity
- Download the SMPL-X Unity plugin from here (You need to sign up)
- Unzip the content and import the content of
SMPLX-Unityin theAssetsfolder of your project - Download the Zed Livelink Unity package from here
- Import the package in your project from
Assets -> Import Package -> Custom Package - If you have compilation errors related to the missing of the newtonsoft package do the following as explained here:
- Open the Package Manager (Window -> Package Manager)
- Click on the "+" button and select "Add package from name"
- Enter
com.unity.nuget.newtonsoft-jsonand click onAdd
- Go to
SMPLX-Unity/Assets/SMPLX/Modelsand click onsmplx-male.fbx. On the inspector window set the following options as described here:
- Meshes:
- Mesh Compression: Off
- Read/Write Enabled: On
- Rig:
- Optimize Mesh: Off
- Import Blendshapes: On
- Keep Quads: Off
- Weld Vertices: Off
- Animation Type: Humanoid
- Normals & Tangents:
- Normals: Calculate
- Smoothing Angle: recommended value=180 (higher numbers help with faster and smoother rendering)
- Tangents: None
- Materials:
- Material creation mode: None
And clickApply
- Material creation mode: None
- Go to
SMPLX-Unity/Assets/SMPLX/Prefabsand insmplx-male.prefab(orsmplx-female.prefab) underAnimationselectBodyTrackingAnimationControlleras the controller - Also add the component
ZED Skeleton Animatorscript for the prefab - Open the scene in
Assets/ZEDFusion/Scenes/Body Tracking Fusion.unity - Select
FusionManagerfrom the hierarchy and in the inspector expandAvatar Controlsand delete the already existing avatars. - Drag and drop the
smplx-male.prefab(orsmplx-female.prefab) prefab inSMPLX-Unity/Assets/SMPLX/Prefabsin theAvatarslist in theFusionManagerinspector
- Clone
zed-unity-livelinkrepo:
git clone https://github.com/stereolabs/zed-unity-livelink.git
- Build ZED Unity livelink Mono (If you would like to use multiple cameras you can try with zed-unity-livelink-fusion)
cd zed-unity-livelink/zed-unity-livelink-mono
mkdir build
cd build
cmake ..
make- Start the ZED Unity Livelink server
./ZED_LiveLink_Mono- You will see the ip address and port used for multicast communication. Annotate them and set them in the
FusionManagerinspector in Unity in theZED Streaming Clientsection
Inside the utils folder you can find the C# program called SendParams.cs that I use in Unity to send the parameters of the SMPL-X model to the smplx_tracking.py script.
I used ROS2 and Unity TCP Endpoint but you can rewrite it using a simple TCP client-server architecture.
smplx_unity_demo-2024-07-17_12.47.58.mp4
- smplx
- open3d
You can install them using pip:
pip install smplx open3dThe C# program works if change the visibility of the following variables in the SMPLX.cs script under Assets/SMPLX-Unity/Assets/SMPLX/Scripts from private to public:
_bodyJointNames
_transformFromName
Also you need to define a constant name for the prefab instantiated by the ZED Unity plugin.
You need to add the following line in the SkeletonHandler.cs script under Assets/ZEDFusion/Scripts:
humanoid.name = "Humanoid";In this way the SendParams.cs program can retrieve the gameobject correctly at run-time.
I avoided creating a ROS2 package since it is a simple script. You can run it using the following command:
python3 smplx_tracking smplx_tracking.pyThen press play in Unity and finally run the ROS TCP Endpoint to create the connection.
I created a ROS2 service in the smplx_tracking.py script that dumps the SMPL-X parameters in a file.
ros2 service call /dump_smplx_parameters std_srvs/srv/Empty "{}"