C# (.NET)

These examples demonstrate how to use the .NET wrapper with the Intel RealSense SDK.
They demonstrate how to easily use the SDK to include code snippets that access the camera into your applications.

Intel RealSense SDK 2.0 Installation Guidelines

Installation guidelines with CMake and Visual Studio, Core CLI and Mono are on GitHub

List of Intel RealSense SDK 2.0 Examples

Hello World

Here is a minimal depth application written in C#:

var pipe = new Pipeline();
pipe.Start();

while (true)
{
    using (var frames = pipe.WaitForFrames())
    using (var depth = frames.DepthFrame)
    {
        Console.WriteLine("The camera is pointing at an object " +
            depth.GetDistance(depth.Width / 2, depth.Height / 2) + " meters away\t");

        Console.SetCursorPosition(0, 0);
    }
}

📘

Note:

Since the SDK is holding-on to native hardware resources, it is critical to make sure you deterministically dispose of objects, especially those derived from Frame. Without releasing resources explicitly the Garbage Collector will not keep-up with new frames being allocated.

ExampleDescriptionLink to GitHub
DepthStreams depth frames for a headless devicecs-tutorial-depth
CaptureCaptures depth and color and renders to side-by-side windowscs-tutorial-capture
ProcessingAligns depth to color and applies the post processing filterscs-tutorial-processing
Software developmentDemonstrates usage of the software_device object, which allows users to create and control custom SDK devicecs-tutorial-software-dev
PoseDemonstrates how to obtain data from pose framescs-tutorial-pose