This package lets you use the ZED stereo camera in C#. The C# API is a wrapper around the ZED SDK which is written in C++ optimized code. We make the ZED SDK accessible from external C# code.
- First, download the latest version of the ZED SDK on stereolabs.com
- For more information, read the ZED API documentation or our Community page
- Windows 10 64bits or later
- Visual Studio 2017 with C# extensions
- Cmake 3.23 at least
- C wrapper of the ZED SDK
- ZED SDK 4.2.0 and its dependency (CUDA)
The C# API is available as a Nuget Package on Nuget.org.
Package | Description | Link |
---|---|---|
Stereolabs.zed | .NET Wrapper that imports the functions from the interface |
To add a NuGet pacakge to your project, please follow this documentation.
It is also possible to build the wrapper from the sources. The C# wrapper made of two libraries :
- The C# wrapper called Stereolabs.zed.dll. It defines all the functions of the ZED SDK in C#.
- The C wrapper called zed-c-api. This native dll binds all the C# functions to the ZED SDK (written in C++). This wrapper is available here : https://github.com/stereolabs/zed-c-api
-
Open cmake-gui.
-
In “Where is the source code“, enter the path of the project folder where the CMakeLists.txt is located.
-
In “Where to build the binaries“, enter the previous path and add: /build.
-
Click on [Configure].
-
A dialog window asks you if CMake can create the “build” folder. Say yes.
-
Another dialog window will ask you to specify a generator for your project. Choose Visual Studio in Win64 and click on [Finish].
-
CMake may take a few seconds to configure the project.
-
Click on [Generate] to build the Visual Studio project files.
-
CMake has now generated your project in the build directory. You can directly open the solution by clicking on [Open Project] or by closing the cmake-gui window and opening the build folder.
-
A Visual Studio solution has been generated. Open Stereolabs.ZED.sln and set it in
Release
mode.
The Csharp wrapper is using the C wrapper to interface with the ZED SDK. Therefore, you also need to build it following the same step as before.
- Open yourproject in Visual studio
- Right click on your project in the Solution Window and select
Add
->Project Reference
. - Click on
Browse
and select the Stereolabs.ZED.dll you just created before. Add it in your project. - For the moment you also need to manually copy the c wrapper (sl_zed_c.dll) at the same location, in yourproject.
Here is an example of the .NET API.
using System.Numerics;
namespace sl
{
class Program
{
static void Main(string[] args)
{
// Create the camera
Camera zedCamera = new Camera(0);
// Create default configuration parameters
InitParameters init_params = new InitParameters();
ERROR_CODE err = zedCamera.Open(ref init_params);
if (err != ERROR_CODE.SUCCESS)
Environment.Exit(-1);
// Get camera information (serial number)
int zed_serial = zedCamera.GetZEDSerialNumber();
Console.WriteLine("Hello! This is my serial number: " + zed_serial);
Console.ReadLine();
zedCamera.Close();
}
}
}
If you need assistance go to our Community site at https://community.stereolabs.com/