C#

You are currently viewing the documentation for version 2.4.0. To access documentation for other versions, click the "Switch Version" button located in the upper-right corner of the page.

■ To use the latest version, visit the Mech-Mind Download Center to download it.

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

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:

  • TriggerWithSoftwareAndFixedRate: Trigger data acquisition with the software + fixed rate method, and then retrieve and save the acquired data.

  • TriggerWithExternalDeviceAndFixedRate: Trigger data acquisition with the external + fixed rate method, and then retrieve and save the acquired data.

  • TriggerWithSoftwareAndEncoder: Trigger data acquisition with the software + encoder method, and then retrieve and save the acquired data.

  • TriggerWithExternalDeviceAndEncoder: Trigger data acquisition with the external + encoder method, and then retrieve and save the acquired data.

  • TriggerMultipleProfilersSimultaneously: Trigger multiple laser profilers to acquire data asynchronously, and then retrieve and save the acquired data.

  • BlindSpotFiltering: Detect and remove the false data caused by blind spots and obtain the filtered profile data.

  • NoiseRemoval: Remove the noise in the depth data and obtain the filtered profile data.

  • ProfileAlignment: Correct the X-axis and Z-axis vibrations in the profiles (aligning the profiles) and obtain the corrected profile data.

  • RenderDepthMap: Obtain and save the depth map rendered with the jet color scheme.

  • TransformPointCloud: Obtain and save the point clouds in the custom reference frame.

  • 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.

  • PrintProfilerStatus: Obtain and print the laser profiler’s information, such as model, serial number, firmware version, and temperatures.

  • RegisterProfilerEvent: Define and Register the callback function for monitoring laser profiler events.

  • UseVirtualDevice: Acquire the profile data stored in a virtual device, generate the intensity image and depth map, and save the images.

For different methods of triggering the laser profiler to acquire data, refer to Methods for Triggering Data Acquisition.

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.4.0/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.

  • BlindSpotFiltering

  • NoiseRemoval

  • ProfileAlignment

  • RenderDepthMap

  • TriggerWithSoftwareAndFixedRate

  • TriggerWithExternalDeviceAndFixedRate

  • TriggerWithSoftwareAndEncoder

  • TriggerWithExternalDeviceAndEncoder

  • TriggerMultipleProfilersSimultaneously

  • UseVirtualDevice

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.