> 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.

# Tutorial - Split Process

This tutorial shows how to decouple image and depth acquisition using the `read()` and `grab()` functions, so images can be retrieved at full frame rate while depth and point cloud measurements are only computed every few frames. The program captures 150 frames, computing depth every 6th frame, and prints the resulting image and depth throughput (FPS). We assume that you have followed the [Depth Sensing](/docs/tutorials/depth-sensing/) tutorial before.

## Getting Started

* First, download the latest version of the [ZED SDK](https://www.stereolabs.com/developers/).
* Download the [Split Process](https://github.com/stereolabs/zed-sdk/tree/master/tutorials/tutorial%2010%20-%20split%20process) sample code in C++.

## Code Overview

### Open the camera

As in previous tutorials, we create, configure and open the ZED, enabling `NEURAL` depth mode.

**`C++`**

```cpp C++
// Create a ZED camera object
Camera zed;

// Set configuration parameters
InitParameters init_parameters;
init_parameters.depth_mode = DEPTH_MODE::NEURAL;     // Use NEURAL depth mode
init_parameters.coordinate_units = UNIT::MILLIMETER; // Use millimeter units (for depth measurements)

// Open the camera
auto returned_state = zed.open(init_parameters);
if (returned_state > ERROR_CODE::SUCCESS) {
    cout << "Error " << returned_state << ", exit program." << endl;
    return EXIT_FAILURE;
}
```

### Capture images with `read()`, depth with `grab()`

In previous tutorials, `grab()` was called on every iteration to get both the image and the depth. Here, we call `zed.read()` on every loop to retrieve the left image as fast as possible, and only call `zed.grab()` (which recomputes depth) every 6 frames, reducing the computational cost when full-rate depth isn't needed.

**`C++`**

```cpp C++
// Capture 150 images then stop
int frame_count = 0;
int depth_count = 0;
sl::Mat image, depth, point_cloud;

const sl::Timestamp start_ts = sl::getCurrentTimeStamp();
const int depth_every_n_frames = 6;

while (frame_count < 150) {
    // A new image is available if read() returns ERROR_CODE::SUCCESS
    if (zed.read() <= ERROR_CODE::SUCCESS) {
        // Retrieve left image
        zed.retrieveImage(image, VIEW::LEFT);
        frame_count++;
    }

    // Measurements are available if grab() returns ERROR_CODE::SUCCESS or a WARNING (an error_code lower than ERROR_CODE::SUCCESS)
    if (((frame_count % depth_every_n_frames) == 0) && (zed.grab() <= ERROR_CODE::SUCCESS)) {
        // Retrieve depth map. Depth is aligned on the left image
        zed.retrieveMeasure(depth, MEASURE::DEPTH);
        // Retrieve colored point cloud. Point cloud is aligned on the left image.
        zed.retrieveMeasure(point_cloud, MEASURE::XYZRGBA);

        // Get and print distance value in mm at the center of the image
        // We measure the distance camera - object using Euclidean distance
        const int x = point_cloud.getWidth() / 2;
        const int y = point_cloud.getHeight() / 2;
        sl::float4 point_cloud_value;
        point_cloud.getValue(x, y, &point_cloud_value);

        if (std::isfinite(point_cloud_value.z)) // convert to float3 to use norm(), the 4th component is used to store the color
            cout << "Distance to Camera at {" << x << ";" << y << "}: " << sl::float3(point_cloud_value).norm() << "mm" << endl;
        else
            cout << "The Distance can not be computed at {" << x << ";" << y << "}" << endl;
        depth_count++;
    }
}
```

> **Note**
>
> `read()` grabs a new image without recomputing depth, which is significantly cheaper on GPU than `grab()`. Use this pattern when your application needs images at the sensor's full frame rate but can tolerate a lower depth-update rate.

For more information on `read()` and `grab()`, see [Using the Video API](/docs/development/zed-sdk/modules/camera/camera-controls/).

### Report throughput and close the camera

Once 150 frames have been captured, we compute and print the resulting image and depth FPS, then close the camera.

**`C++`**

```cpp C++
auto diff = (sl::getCurrentTimeStamp() - start_ts).getSeconds();
// Print the FPS
if (diff > 0)
    std::cout << "Image: " << (frame_count / diff) << "FPS / Depth: " << (depth_count / diff) << "FPS" << std::endl;

// Close the camera
zed.close();
```