3. C#

This section will show you how to run a C# sample in Windows.

3.1. Sample List

Samples are divided into five categories, Basic, Advanced, Util, Laser and UHP.

  • Basic: camera connection and basic capturing functions.

  • Advanced: advanced capturing functions.

  • Util: obtain information from a camera and set camera parameters.

  • Laser: for Laser/LSR series cameras only.

  • UHP: for UHP series cameras only.

3.2. Requirements

  1. Download Visual Studio 2019

    It is recommended to use Visual Studio 2019 or Visual Studio 2015.
  2. Choose and install workloads and individual components in Visual Studio

    Workloads: .NET desktop development, Desktop development with C++, Universal Windows Platform development
    ../../../_images/workloads.png
    Individual components: .NET Framework 4.8 targeting pack
    ../../../_images/sample_csharp_component.png
  3. Download and install Mech-Eye SDK

  4. Download or clone C# samples

  5. Connect to a real camera that functions properly

  6. The samples marked with (EmguCV) must be installed via NuGet Package Manager Emgu.CV.runtime.windows. Please refer to Install and manage packages in Visual Studio using the NuGet Package Manager for detailed instructions.

3.3. Instructions

3.3.1. Build Solution in Visual Studio

  1. Open MechEyeCSharpSamples.sln in Visual Studio.

    ../../../_images/csharp_open_project.png
    ../../../_images/csharp_chose_project.png
  2. Change the Solution Configuration from Debug to Release.

    ../../../_images/csharp_set_release.png
  3. Build solution.

    Right-click on Solution ‘MechEyeCSharpSamples’ in the Solution Explorer, and click on Build Solution in the context menu.

    ../../../_images/csharp_build_solution.png

3.3.2. Run Sample Program

The example below shows how to run CaptureColorMap.exe.

  1. Go to mecheye_csharp_samples-master ‣ source ‣ Build.

  2. Double-click on CaptureColorMap.exe.

    While the program is running, please follow the instructions to input the camera index, and then wait for the program to finish.

  3. After running the program, you will get colorMap in Build directory.

    ../../../_images/csharp_color1.png