C#

You are currently viewing the documentation for the latest version (2.6.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

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

Sample List

Samples are divided into the following categories: Basic, Advanced, Util, Calibration, Pcl and Halcon.

  • Basic samples: Connect to the camera and acquire data.

  • Advanced samples: Acquire data in more complicated manners and set model-specific parameters.

  • Calibration samples: perform hand-eye calibration through Mech-Eye API.

  • Util samples: Obtain camera information and set common parameters.

The samples in each category and their descriptions are provided below.

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

  • TriggerNonStopAcquisition: Trigger a continuous scan of the target object, and then retrieve and save the acquired data.

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

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

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

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

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

  • WarmUp: Warm up the device.

Calibration
  • MultipleProfilersCalibration: Calibrate multiple laser profilers that simultaneously scan the same target object, and output the calibration results and errors, stitching results, as well as the stitched depth map and point cloud.

  • MoveDirVecCalibration: Calibrate the movement direction vector for a single laser profiler, and output calibration results and alignment parameters for subsequent stitching.

  • WidthExpansionCalibration: Perform width-expansion calibration and stitching for a single laser profiler, and output corrected calibration parameters and stitching results.

Util
  • HandleNanAndNegativeInDepth: Detect and process NaN and negative values in the depth data, and then generate and save the intensity image and depth map.

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

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

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

  • TriggerNonStopAcquisition

  • TriggerWithSoftwareAndEncoder

  • TriggerWithExternalDeviceAndEncoder

  • TriggerMultipleProfilersSimultaneously

  • UseVirtualDevice

  • WarmUp

  • HandleNanAndNegativeInDepth

  • MoveDirVecCalibration

  • MultipleProfilersCalibration

  • WidthExpansionCalibration

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.

Is this page helpful?

You can give a feedback in any of the following ways:

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.