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.
Basic
ConnectToCamera: Connect to a Mech-Eye Industrial 3D Camera.
ConnectAndCaptureImage: Connect to a camera and obtain 2D image, depth map and 3D image.
CaptureColorMap (OpenCV): Obtain 2D image in OpenCV format from a camera.
CaptureDepthMap (OpenCV): Obtain depth map in OpenCV format from a camera.
CapturePointCloud (PCL): Obtain untextured and textured point clouds (PCL format) generated from images captured with a single exposure time.
CaptureHDRPointCloud (PCL): Obtain untextured and textured point clouds (PCL format) generated from images captured with multiple exposure times.
CapturePointCloudROI (PCL): Obtain untextured and textured point clouds (PCL format) of the objects in the ROI from a camera.
Advanced
CaptureCloudFromDepth (PCL): Construct point clouds from depth map and 2D image captured from a camera.
CaptureTimedAndPeriodically (OpenCV & PCL): Obtain 2D image, depth map and 3D images sequentially from multiple cameras.
CaptureSimultaneouslyMultiCamera (OpenCV & PCL): Obtain 2D image, depth map and 3D images simultaneously from multiple cameras.
CaptureSequentiallyMultiCamera (OpenCV & PCL): Obtain 2D image, depth map and 3D images periodically for the specified duration from a camera.
Util
GetCameraIntri: Get and print a camera’s intrinsic parameters.
PrintDeviceInfo: Get and print a camera’s information such as model, serial number and firmware version.
SetDepthRange: Set the range of depth values to be retained by a camera.
SetParameters: Set specified parameters to a camera.
SetUserSets: provide functions related to parameter groups, such as switching to a different parameter group, adding and deleting parameter groups, etc.
Laser
SetLaserFramePartitionCount: Divide the projector FOV into partitions and project structured light in one partition at a time. The output of the entire FOV is composed from images of all partitions.
SetLaserFrameRange: Set the projection range of the structured light. The entire projector FOV is from 0 to 100.
SetLaserFringeCodingMode: Set the coding mode of the structured light pattern.
SetLaserPowerLevel: Set the output power of the laser projector in percentage of max power. This affects the intensity of the laser light.
UHP
SetUHPCaptureMode: Set the capture mode (capture images with camera 1, with camera 2, or with both 2D cameras and compose the outputs).
SetUHPFringeCodingMode: Set the coding mode of the structured light pattern.
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: 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.