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.
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 :
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.
Add
-> Project Reference
.Browse
and select the Stereolabs.ZED.dll you just created before. Add it in your project.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/