C# (Windows)

Sample Program Overview

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

  • DepthToPointCloud/Program.cs: Converts depth images to point clouds in real time during continuous capture.

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

  • FetchFrameContinuous/Program.cs: Captures depth images in continuous capture mode.

  • ImageRegistration/Program.cs: Aligns the output depth image with the color image in software trigger mode.

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

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

  • LoadFeaturesFromStorage/Program.cs: Loads feature settings from the camera Storage area. This sample applies only to non-GenICam cameras.

  • ReadCalibInfo/Program.cs: Reads calibration parameters for a specified sensor.

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

  • SaveFeaturesToFile/Program.cs: Saves updated feature settings to a specified JSON file.

  • SaveFeaturesToStorage/Program.cs: Saves feature settings to the device Storage area. This sample applies only to non-GenICam cameras.

  • SoftTrigger/Program.cs: Captures depth images after sending a software trigger command.

  • UserSetSelector/Program.cs: Selects a user set. This sample applies only to GenICam cameras.

  • ReconnectWhenOffline/Program.cs: Automatically reconnects the camera after disconnection and resumes image acquisition.

Install Dependencies

Install Visual Studio

Note

The recommended Visual Studio version is 2022. Other versions are not tested and the compatibility is not guaranteed.

Download and install Visual Studio. Important: During installation, select the .NET desktop development workload under the Desktop and Mobile Applications category.

Install Visual Studio

Install Visual Studio

Dependency 2 — USB Driver (Optional)

If you use a USB camera, complete Set Up USB Camera Environment before proceeding.

Compile Sample Programs

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

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

    Build Solution in Visual Studio

Execution

  1. According to the build configuration (Release or Debug), enter the corresponding VcameraSDK-X.X.X/csharp/net48/example/SampleOut/x64/<build configuration> directory.

  2. Open a terminal and execute the sample executables.

Execute C# Sample Program