C# (Windows)

Sample Program Overview

C# sample programs are located in VcameraSDK-X.X.X/csharp/net48/example and include:

  • DepthToPointCloud/Program.cs: Configures the camera in continuous acquisition mode and converts depth data into point clouds in real time.

  • DepthToTextureRegistration/Program.cs: Configures the camera in software trigger mode and aligns the output depth image with the color image.

  • SoftTrigger/Program.cs: Configures the camera in software trigger mode. After a software trigger command is sent, the camera captures a depth image.

  • DumpAllFeatures/Program.cs: Lists the features supported by the current camera.

  • ReadWriteFeatures/Program.cs: Demonstrates how to read and write features.

  • UserSetSelector/Program.cs: Selects a user set, which is a saved group of camera feature settings. This sample only applies to Gige_2.1 cameras that support user sets.

  • FetchFrameContinuous/Program.cs: Configures the camera in free-run mode to capture depth images.

  • ListDevices/Program.cs: Lists all cameras connected to the computer.

  • SaveFeaturesToStorage/Program.cs: Saves parameter settings to the device Storage area. This sample only applies to Gige_2.0 cameras that do not support user sets.

  • LoadFeaturesFromStorage/Program.cs: Loads parameter settings from the Storage area and applies them to the camera. This sample only applies to Gige_2.0 cameras that do not support user sets.

  • SaveFeaturesToFile/Program.cs: Saves modified parameter settings to a specified JSON file.

  • LoadFeaturesFromFile/Program.cs: Loads camera parameter settings from a specified JSON file and applies them to the camera.

Install Dependencies

Dependency 1 - Visual Studio

Note

Visual Studio 2022 is recommended. This version has been fully validated for compatibility. Other versions have not been fully tested and compatibility is not guaranteed.

Download and install Visual Studio. Select the .NET desktop development workload under the desktop development category.

vs-install

Visual Studio Installation

Dependency 2 - USB Driver (Optional)

If you need to use a USB camera, complete the Set Up USB Camera steps.

Build

  1. Double-click VcameraExample.sln under VcameraSDK-X.X.X/csharp/net48/example to open the project.

  2. Select the build configuration, either “Release” or “Debug”, set the platform to “x64”, then click “Build” > “Build Solution”. The Release configuration is recommended.

    vcamera-cs-manager

Run

  1. Based on the selected build configuration, Release or Debug, go to the corresponding directory VcameraSDK-X.X.X/csharp/net48/example/SampleOut/x64/<build_configuration>.

  2. Open a terminal and run the generated .exe file.

vcamera-compile-end