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 four categories, Basic, Advanced, Util and Laser.
Basic
ConnectToCamera : connect to a camera.
ConnectAndCaptureImage : connect to a camera can capture 2D images.
CaptureColorMap : capture color images from a camera.
CaptureDepthMap : capture depth maps from a camera.
CapturePointCloud : capture point clouds from a camera.
CaptureHDRPointCloud : capture point clouds in HDR mode from a camera.
CapturePointCloudROI : set an ROI and capture point clouds from a camera.
Advanced
CaptureCloudFromDepth : generate point clouds from depth maps.
CaptureTimedAndPeriodically : capture images periodically for a specified length of time to ready the camera.
CaptureSimultaneouslyMultiCamera : capture images from multiple cameras simultaneously.
CaptureSequentiallyMultiCamera : capture images from multiple cameras sequentially.
Util
GetCameraIntri : obtain and print the intrinsic parameters of the camera.
PrintDeviceInfo : print version information of Mech-Eye SDK and the camera firmware.
SetDepthRange : set the depth range of a camera.
SetUserSets : provide functions related to parameter groups, such as switching to a different parameter group, adding and deleting parameter groups, etc.
SetParameters : provide functions related to camera parameters, including all the functions of SetUserSets.
Laser
SetLaserFramePartitionCount : set the laser scan partition number for a laser camera.
SetLaserFrameRange : set the field of view for a laser camera.
SetLaserFringeCodingMode : set the fringe coding mode for a laser camera.
SetLaserPowerLevel : set the power level for a laser camera.
Attention
The samples above have been included in the installation package of Mech-Eye SDK.
2.2. Requirements¶
Update the software source list and install the dependent libraries.
sudo apt-get update sudo apt-get install -y build-essential pkg-config cmake
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/
.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¶
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.
Go to the folder
samples
.cd /opt/mech-mind/mech-eye-sdk/samples/
Under the path
/opt/mech-mind/mech-eye-sdk/samples/
, open the fileCMakeLists.txt
, go to line 88set(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
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.
Take CaptureSequentiallyMultiCamera as an example. Go to the folder of the sample to compile.
cd /opt/mech-mind/mech-eye-sdk/samples/Advanced/CaptureSequentiallyMultiCamera/
This step is only required for samples using OpenCV. Under the path
/opt/mech-mind/mech-eye-sdk/samples/Advanced/CaptureSequentiallyMultiCamera/
, open the fileCMakeLists.txt
, go to lineset(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
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/
。
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: V3.0.0 Firmware Version: V1.5.2 ............................ 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.