2. C++ (Ubuntu)

This section will show you how to configure the Mech-Eye API C++ samples on Ubuntu.

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

2.2. Requirements

  1. Update the software source list and install the dependent libraries.

    sudo apt-get update
    sudo apt-get install -y build-essential pkg-config cmake
    
  2. Install Mech-Eye SDK.

    Please refer to Install Mech-Eye SDK on Ubuntu for the installation method.

    After installation, the path to the samples folder is /opt/mech-mind/mech-eye-sdk/samples/ .

  3. Install third-party libraries.

    Samples marked with (OpenCV) or marked with (PCL) require third-party libraries to be installed.

    Attention

    If using a virtual machine to install the software, please reserve more than 20G of disk space. Otherwise, the installation may fail.

    # Install PCL
    sudo apt-get install libpcl-dev
    
    wget https://github.com/opencv/opencv/archive/3.4.5.tar.gz
    tar -zxvf 3.4.5.tar.gz
    cd opencv-3.4.5
    mkdir build
    cd build
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=`pwd`/install ..
    make && make install
    pkg-config --modversion opencv
    

2.3. Instructions

  1. Compile samples.

    You can compile all samples at a time, or compile a selected sample.

    Attention

    Every time you modify a sample’s source file, please recompile the sample to update the executable

    • Compile all samples.

      1. Go to the folder samples.

        cd /opt/mech-mind/mech-eye-sdk/samples/
        
      2. Under the path /opt/mech-mind/mech-eye-sdk/samples/, open the file CMakeLists.txt, go to line 88 set(OpenCV_DIR "/home/ubuntu/3rdParties/opencv-3.4.5/build"), and replace the path in double quotes with your local OpenCV build path.

        sudo vi CMakeLists.txt
        
      3. Execute cmake and make in the current path.

        sudo cmake .
        sudo make
        

        After successful compilation, the samples are located in /opt/mech-mind/mech-eye-sdk/samples/.

    • Compile one sample.

      1. Take CaptureSequentiallyMultiCamera as an example. Go to the folder of the sample to compile.

        cd /opt/mech-mind/mech-eye-sdk/samples/Advanced/CaptureSequentiallyMultiCamera/
        
      2. This step is only required for samples using OpenCV. Under the path /opt/mech-mind/mech-eye-sdk/samples/Advanced/CaptureSequentiallyMultiCamera/, open the file CMakeLists.txt, go to line set(OpenCV_DIR "/home/ubuntu/3rdParties/opencv-3.4.5/build"). Replace the path in double quotes with your local OpenCV build path.

        sudo vi CMakeLists.txt
        
      3. Execute cmake and make in the current path.

        sudo cmake .
        sudo make
        

        After successful compilation, the sample is located in /opt/mech-mind/mech-eye-sdk/samples/Advanced/CaptureSequentiallyMultiCamera/

  2. Run a sample.

    Taking ConnectToCamera as an example. Under the path /opt/mech-mind/mech-eye-sdk/samples/.

    sudo ./ConnectToCamera
    

    The output is as follows:

    Find Mech-Eye device...
    Mech-Eye device index : 0
    ............................
    Camera Model Name: Mech-Eye Pro M Enhanced
    Camera ID:         NEC15221A3000001
    Camera IP Address: 192.168.xx.xx
    Hardware Version:  Vx.x.x
    Firmware Version:  Vx.x.x
    ............................
    
    Please enter the device index you want to connect: 0
    Connected to the Mech-Eye device successfully.
    Disconnected from the Mech-Eye device successfully.
    

    During the running of the program, please follow the prompts to select the ID of the camera to be connected, and wait for the program to finish running.

Attention

  • For samples involving point cloud capturing, regular users do not have permissions to write point cloud files, so sudo command should be used to execute the sample programs as the administrator.

  • For samples involving image or point cloud capturing, after the running is completed, the image or point cloud files are by default stored at /opt/mech-mind/mech-eye-sdk/samples/.

Tip

In the folder of each sample, the file ReadMe.txt provides a brief description of the sample.