C#

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

This topic introduces how to build the Mech-Eye API C# samples with Visual Studio on Windows.

Sample List

The following samples are currently provided:

  • AcquireProfileData: Acquire the profile data, generate the intensity image and depth map, and save the images.

  • AcquireProfileDataUsingCallback: Acquire the profile data using a callback function, generate the intensity image and depth map, and save the images.

  • AcquirePointCloud: Acquire the profile data, generate the point cloud, and save the point cloud in the CSV and PLY formats.

  • ManageUserSets: Manage parameter groups, such as obtaining the names of all parameter groups, adding a parameter group, switching the parameter group, and saving parameter settings to the parameter group.

  • RegisterProfilerEvent: Define and register the callback function for monitoring the laser profiler connection status.

Prerequisites

In order to use the C# samples of Mech-Eye API, the following prerequisites must be satisfied:

Obtain Samples

C# samples are included in the installation path of Mech-Eye SDK or can be obtained from GitHub by cloning. The samples in the installation path are the version at the time of Mech-Eye SDK release. The version on GitHub may contain the latest changes.

  • The samples in the installation path are located in xxx/Mech-Eye SDK-2.2.2/API/samples/csharp/profiler.

  • The samples cloned from GitHub are located in xxx/mecheye_csharp_samples/profiler.

Install Required Software

In order to use the C# samples of Mech-Eye API, Mech-Eye SDK and Visual Studio must be installed.

Install the Latest Version of Mech-Eye SDK

Please install or upgrade Mech-Eye SDK according to Mech-Eye SDK Installation Guide.

Install Visual Studio (Version 2019 or Above)

  1. Download the Visual Studio installer.

  2. When installing, select the following workloads and individual component, and then click Install.

    • Workloads in the Desktop & Mobile category:

      • .NET desktop development

      • Desktop development with C++

      • Universal Windows Platform development

    • Individual component: .NET Framework 4.8 targeting pack

C# Mech-Eye API is developed based on .NET Framework 4.8. If .NET Framework 4.8 is not installed, the samples cannot be built.

Install Emgu CV

Some samples contain functions that depend on the OpenCV software libraries. If you need to use the samples listed below, you must install Emgu CV (the .NET wrapper for OpenCV) through NuGet Package Manager in Visual Studio.

For detailed instructions, refer to the guide provided by Microsoft.

  • AcquireProfileData

  • AcquireProfileDataUsingCallback

Build and Run Samples

After building the samples in Visual Studio, select the appropriate way to run the samples.

Build Samples in Visual Studio

  1. Double-click MechEyeCSharpSamples.sln in the profiler folder.

  2. In Visual Studio toolbar, change the solution configuration from Debug to Release.

  3. In the menu bar, select Build  Build Solution. An executable file (.exe) is generated for each sample. The executable files are saved to the Build folder, located in the profiler folder.

Run Samples

You can run the samples in Visual Studio after building them, or run the samples by double-clicking the executable files.

Run a Sample in Visual Studio

  1. In the Solution Explorer panel, right-click a sample, and select Set as Startup Project.

  2. Click Local Windows Debugger in the toolbar to run the sample.

    While the sample is running, input the index of the laser profiler to which you want to connect according to the instruction, and press Enter to connect to the laser profiler.

  3. If image and/or point cloud files are saved by the sample, you can find the files in the Build folder.

Run the Executable File of a Sample

  1. Enter the Build folder in the profiler folder.

  2. Run the executable file with the same name as the sample.

    While the sample is running, input the index of the laser profiler to which you want to connect according to the instruction, and press Enter to connect to the laser profiler.

  3. If image and/or point cloud files are saved by the sample, you can find the files in the Build folder.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.