Using ZED and OpenCV in a Docker Container
This tutorial shows how to use ZED SDK applications along with the OpenCV library in a Docker container. This section gives you an overview of using ZED cameras and OpenCV in a Docker Container, it demonstrates how to build and run an OpenCV application.
In the next section, you will learn how to create a Docker image with ZED SDK and OpenCV. However, the present tutorial presumes that you are running a Docker container with all the necessary libraries to present an overview of using OpenCV in Docker.
Download and run the Docker Image
To build an application using OpenCV you need to pull and run a Docker image with ZED SDK and OpenCV capabilities. If you wish to run applications that use display windows make sure your container also supports OpenGL.
--gpus allcommand adds all the available GPUs--privilegedgrants permission to the container to access the camera connected to USB--runtime nvidiawill use the NVIDIA® container runtime.-v /tmp/.X11-unix:/tmp/.X11-unixis required for the container to access the display.-e DISPLAYmakes yourDISPLAYenvironment variable available in the container.
To know more about docker run usage and command options, read docker run description here.
Run a sample OpenCV application
Once there is a container running you are good to get started. Download a sample OpenCV example, zed-opencv sample is the perfect place to get started.
The sample implements the following tasks:
- Adjust several parameters: depth sensing mode, image resolution, and units.
- Capture image, depth and point cloud from the ZED.
- Convert image and depth map to compatible 32-bits float OpenCV matrix.
- Display video and depth with OpenCV.
- Save side-by-side images, depth images and point clouds in various formats.
For further explanation of the code refer to the ZED OpenCV documentation.
Install the zed-opencv sample code from GitHub (https://github.com/stereolabs/zed-opencv).
Compile the code and run the application
Build the C++ code and run the application
Congratulations! You have built your first ZED OpenCV application using Docker.
You can now go ahead and build other examples that use openCV in a similar way explained above. Program-specific explanations and build instructions can be found in their respective GitHub repository.

