> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.stereolabs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.stereolabs.com/_mcp/server.

# Background Subtraction with UE5

In this tutorial, you will learn how to perform background subtraction with a ZED Camera and the NEURAL Depth Mode.

## What is Background Subtraction?

Background subtraction is a way of eliminating the background from an image. To achieve this we are using the Depth map generated by the SDK
to remove the background of an image. Everything further than a certain distance from the camera will be removed.

![image](/_fern-img/ae279dfe9dae887a18245e012fac35520b809cb718366c58e7e159b91e4318de.webp)

### General Settings

Now we've got to add a Blueprint from the ZED plugin. But by default, Content from plugins is hidden. To fix this, click on **View Options** at the bottom right of the Content Browser and enable **Show Plugin Content**.

![image](/_fern-img/345c4487ee4c77b179edc142e3d1976afc33827fa12e9d2355d62f5ba7e732a6.webp)

Now click on the folder icon beside Content and click on Stereolabs Content to switch to the plugin's content folder.

![image](/_fern-img/e64164c7db705ff454b646b31264f28c0a88d78026cc3699f3293702e0f72f3a.webp)

![image](/_fern-img/05eb74e79617f9d4cf96597301c6d537e163fba9efe70b9c2f2d6fd1f4c15f0f.webp)

In the Content Browser, go to **Plugins** -> **Stereolabs Content** -> **ZED** -> **Blueprints** and drag a **BP\_ZED\_Initializer** into the scene. This is the object that sets up your camera and handles communication with your app.

* Select the **BP\_ZED\_Initializer** blueprint, and in the **ZED** section, uncheck the **Show Zed Image** parameter.
  This parameter has to be disabled so we can see the 3D scene and not the ZED's image in fullscreen.

![image](/_fern-img/34b908b5de546ce691a4113b5db9cf46d6da5e8d78f4af3e54a76e29965610c5.webp)

* In the **Init Parameters** section, set Depth Mode to NEURAL. This mode is mandatory in order to have accurate background subtraction.

![image](/_fern-img/cec8bcf38589fb9b400397170ef7bcc70da18e2ea96536003b9b599cb129cc60.webp)

> **Note**
>
> The `NEURAL` depth mode is AI-based, therefore the AI model has to be downloaded and optimized when using this mode for the first time. If it has not been optimized yet, the plugin will start the optimization itself. It can take some time so we recommend [using the ZED Diagnostic tool](https://support.stereolabs.com/hc/en-us/articles/4852371065623-Why-is-my-application-frozen-when-using-the-NEURAL-depth-mode-) to optimize it beforehand.

### Remove the background

We are using the depth map to eliminate the background. Everything further than a certain distance from the camera will be removed.
That's why using a very accurate depth mode is important.

In UE5, there are 2 ways of doing that:

* Adding a virtual object closer to the camera than the background. That's what is done for the Weather forecast demo. A plane with a weather map placed on it is added in the scene, just behind the person.

* Using the **Depth clamp Threshold** parameter. This parameter will discard all the pixels of the image with a depth higher than the threshold. It is useful when the virtual background is a 3D scene placed farther away than the real background.

![image](/_fern-img/767fb296277af868eaa6119dcd46a42bf3bd1d5eac8d8e7416ecf7927f4d61af.webp)

This parameter can also be modified at runtime, on the **ZEDCamera** actor, generated at runtime under `ZEDPawn`, letting you adapt the threshold in real time.