1. C++ (Windows)

This section demonstrates how to configure the C++ samples with CMake and then build and run the samples with Visual Studio in Windows.

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

1.2. Requirements

  • Connect to a real camera that functions properly

  • Required software:

    • Mech-Eye SDK

    • Visual Studio (version 2015 and above recommended)

    • CMake (version 3.2 or above recommended)

  • Optional software: please install the software required by the samples you would like to use.

    OpenCV (version 3.4.5 recommended)

    PCL (version 1.12.1 recommended)

    CaptureColorMap

    √

    CaptureDepthMap

    √

    CapturePointCloud

    √

    CaptureHDRPointCloud

    √

    CapturePointCloudROI

    √

    CaptureCloudFromDepth

    √

    CaptureTimedAndPeriodically

    √

    √

    CaptureSimultaneouslyMultiCamera

    √

    √

    CaptureSequentiallyMultiCamera

    √

    √

Note

Instructions on installing the above software are provided below.

1.3. Instructions

Below are the step-by-step instructions from installing the required software to running a sample program.

1.3.1. Install Software

1.3.2. Set Environment Variables

  1. Right-click on This PC on the desktop, select Properties, and click on Advanced system settings in the pop-up window. In the popped up System Properties window, click on Environment Variables.

    ../../../_images/system_properties_1.png
  2. Select Path in the user variables, and click on Edit… to enter the Edit environment variable page.

    ../../../_images/system_properties_2.png
  3. Click on New to add a new directory, and press the Enter key to confirm adding. Repeat until you finish adding all the directories below, and click on OK to exit the window.

    ../../../_images/system_properties_3.png

    The following directories need to be added to Path:

    • C:/Program Files/OpenNI/Tools

    • xxx/opencv/build/x64/vc15/bin

1.3.3. Configure Solution in CMake

  1. Run CMake (cmake-gui).

    Note

    It is recommended to run CMake as Administrator.

  2. Set the paths as follows:

    ../../../_images/cmake_configure_1.png

    Where is the source code

    xxx/Mech-Eye SDK/API/samples

    Where to build the binaries

    xxx/Mech-Eye SDK/API/samples/build

  3. Click on Configure in the bottom, and set the following two fields according to the actual situation, and then click on Finish.

    ../../../_images/cmake_configure_2.png
  4. In the case where the following error message pops up:

    ../../../_images/cmake_configure_3.png

    Please type OpenCV_DIR in the Search field, double-click on the directory and change it to xxx/opencv/build/x64/vc14/lib. Then, click on Configure again.

    ../../../_images/cmake_configure_4.png
  5. When the log displays Configuring done, click on Generate. When the log displays Generating done, click on Open Project, and select Visual Studio in the pop-up window.

    ../../../_images/cmake_configure_5.png

1.3.4. Build Solution in Visual Studio

  1. In the toolbar, click on Debug and select Release.

    ../../../_images/vs_build_1.png
  2. You can see all the available samples in Solution Explorer.

    ../../../_images/vs_build_2.png
  3. Right-click on a sample, and select Set as Startup Project.

    ../../../_images/vs_build_3.png
  4. Click on icon_run in the toolbar to build the solution.

1.3.5. Run Sample Program

Take CaptureColorMap.exe as an example.

  1. Navigate to xxx/Mech-Eye SDK/API/samples/build/Release, and run CaptureColorMap.exe.

  2. Input the index of the camera you want to connect according to the instructions.

  3. When the program exits, you can find a colorMap.png (color image) under xxx/Mech-Eye SDK/API/samples/build.

    ../../../_images/csharp_color.png