In Spark AR Studio, use 2D body tracking to create effects that move with one or multiple user's bodies. There are two ways to implement this depending on which key points of the body you want to track. You can use either:
When creating a body tracking effect, it’s a good idea to change the Simulator video to one that shows an entire person. You can also select your computer’s built-in camera to see the effect on yourself.
Add and connect the body tracking patches
The first two patches you need to create a body tracking effect are available in the Patch Menu. They are:
Once you’ve connected these patches as in the example above, you need to connect the Body output of Body Select to the input of either a Body Bounding Box patch or one of the six Body Landmarks patches (Head 2D, Neck 2D, Right Arm 2D, Left Arm 2D, Right Leg 2D, Left Leg 2D).
The example graph below shows all seven patches connected to the output of the Body Select patch. This means all possible body key points are being tracked.
Take a look at the examples below to learn how to create effects that respond to these tracked points.
In this example, we’ve created the effect of red tracking points following specific parts of the body. We did this by attaching 2D rectangles to the 20 key points of the body.
You can customize this effect by adding your own materials and 2D textures to the rectangles. You could also make 2D text follow the body instead.
Add the canvas and rectangles
To build this effect we first added a canvas. We then added 20 resized rectangles, each with a red material applied. We grouped the rectangles under the canvas and renamed them to reflect where they’ll be positioned on the body.
Add the body tracking patches
Next, we added the Body Finder, Body Select and the six Body Landmarks patches. We connected:
Finally, we connected each Body Landmark patch output to the yellow patches representing the corresponding positions of the rectangles. Here’s how the final patch graph looks:
You might want to create an effect where 3D objects, like a particle system or a rigged 3D model follows the user's body. You can do this by attaching 3D planes to the Body Landmark patches instead of 2D rectangles. This implementation is more complex because you need to add additional patches to your graph to convert the 2D data output from the body landmarks patches to 3D data
We’ve set these patches up for you already in the Body Movement Template available in the Spark AR Studio welcome window. It’s a good idea to customize this template to easily set up complex body tracking effects.
In this example we’ve used the body bounding box patch to create a rectangle around the body that moves and resizes as the person moves.
Add the canvas and rectangle
Edit the rectangle
Add the body tracking patches
Next we added the Body Finder, Body Select and Body Bounding Box patches. We connected:
Make the rectangle move with the user
To make the rectangle move with the user, the rectangle’s position must be defined by the bounding box coordinates. To do this, we:
Make the rectangle resize with the user
To make the rectangle resize based on the user, the height and width of the rectangle must align with these same properties of the bounding box. To do this, we:
Here’s how the final graph looks:
There are some limitations to consider with body tracking effets. Keep in mind that:
Tracking is weaker or lost when the person: