Configure C++ Samples With Optional Dependencies
This tutorial shows how to configure optional dependencies for the Zivid C++ Samples with CMake.
Requirements
Optional requirements
Some of the samples depend on external libraries, in particular:
备注
The following instructions have been tested with these versions of the dependencies:
Visual Studio 2019 and higher
CMake 3.24 and higher
PCL 1.12.1
Eigen 3.4.0
OpenCV 4.7.0
Open3D 0.19.0
If you are using other versions, you may encounter issues.
Install the required dependencies based on the sample programs you want to run; see the table below.
Sample program |
PCL |
Eigen |
OpenCV |
Halcon |
Open3D |
---|---|---|---|---|---|
ReadPCLVis3D |
YES |
||||
CaptureWritePCLVis3D |
YES |
||||
CaptureHDRVisNormals |
YES |
||||
StitchByTransformation |
YES |
||||
StitchByTransformationFromZDF |
YES |
||||
MaskPointCloud |
YES |
YES |
|||
ROIBoxViaCheckerboard |
YES |
||||
UtilizeHandEyeCalibration |
YES |
||||
PoseConversions |
YES |
||||
ROIBoxViaArucoMarker |
YES |
YES |
|||
CaptureUndistort2D |
YES |
||||
CreateDepthMap |
YES |
||||
ProjectAndFindMarker |
YES |
||||
ReprojectPoints |
YES |
||||
ReadAndProjectImage |
YES |
||||
GammaCorrection |
YES |
||||
AllocateMemoryForPointCloudData |
YES |
||||
TransformPointCloudViaCheckerboard |
YES |
||||
TransformPointCloudViaArucoMarker |
YES |
||||
CaptureHalconViaGenICam |
YES |
||||
CaptureHalconViaZivid |
YES |
Install Eigen 3 from the package manager by running:
sudo apt install libeigen3-dev
Navigate to the build directory you created in zivid-cpp-samples and run
mkdir build
cd build
cmake -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3 -DUSE_OPENCV=OFF -DUSE_PCL=OFF -DUSE_OPEN3D=OFF ../source
cmake --build .
Install PCL from the package manager by running:
sudo apt install libpcl-dev
Navigate to the build directory you created in zivid-cpp-samples and run
mkdir build
cd build
cmake -DUSE_PCL=ON -DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF -DUSE_OPEN3D=OFF ../source
cmake --build .
Install OpenCV from the package manager by running:
sudo apt install libopencv-dev clang-tidy
Navigate to the build directory you created in zivid-cpp-samples and run
mkdir build
cd build
cmake -DUSE_OPENCV=ON -DUSE_EIGEN3=OFF -DUSE_PCL=OFF -DUSE_OPEN3D=OFF ../source
cmake --build .
Download and install prebuilt Open3D binaries from https://github.com/isl-org/Open3D/releases.
For version 0.19.0, download the tarball from https://github.com/isl-org/Open3D/releases/download/v0.19.0/open3d-devel-linux-x86_64-cxx11-abi-0.19.0.tar.xz
The tarball contains a folder named open3d-devel-linux-x86_64-cxx11-abi-0.19.0
.
Copy the contents of this folder to /usr/local
.
You can do this in one go by running the following command in the terminal:
sudo tar --strip-components=1 -xvf ./open3d-devel-linux-x86_64-cxx11-abi-0.19.0-C /usr/local
Navigate to the build directory you created in zivid-cpp-samples and run
mkdir build
cd build
cmake -DUSE_OPEN3D=ON -DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF -DUSE_PCL=OFF ../source
cmake --build .
Download the latest stable release of Eigen from http://eigen.tuxfamily.org/ and extract the folder to your desired destination. When configuring the CMake project, include Eigen to configure the samples that depend on it.
Navigate to the build directory you created in zivid-cpp-samples and run
cmake -DEIGEN3_INCLUDE_DIR=<path> -DUSE_OPENCV=OFF -DUSE_PCL=OFF -DUSE_EIGEN3=OFF ../source
where <path>
is the full path to where you installed Eigen, e.g. C:/Program Files/Eigen
.
Download and install prebuilt PCL binaries by choosing the .exe
at https://github.com/PointCloudLibrary/pcl/releases.
Check the option to install 3rd Party Libraries.

Some settings must be included in the PATH system variable before you can configure the Zivid PCL code samples.
On your PC, navigate to Control Panel → System and Security → System → Advanced System Settings → Environment Variables.
Under System variables, select the Path
variable and click Edit.

In the Edit environment variable window, click New and add the paths to the PCL binaries and OpenNI2 (3rd party library), e.g.
C:\Program Files\PCL 1.12.1\bin
C:\Program Files\OpenNI2\Tools
if you have installed PCL 1.12.1 and OpenNI2 in Program Files. You may have to sign out of your Windows account and in again for the changes to take place.
警告
You may have to manually link to some of the third-party PCL libraries, like VTK.
If you encounter errors, add the path to the binaries of the library in the PATH system variable.
E.g. for VTK, you would add C:/Program Files/PCL 1.12.1/3rdParty/VTK/bin
if you installed PCL 1.12.1 in Program Files.
When configuring the CMake project, the paths to PCL should already be configured.
Download and install prebuilt OpenCV binaries from https://opencv.org/releases/. Extract them to your desired destination, e.g.
C:\Users\Public
Some settings must be included in the PATH system variable before you can configure the Zivid OpenCV code samples.
On your PC, navigate to Control Panel → System and Security → System → Advanced System Settings → Environment Variables.
Under System variables, select the Path
variable and click Edit.

In the Edit environment variable window, click New and add the path to the OpenCV binaries, e.g.
C:\Program Files\opencv\build\x64\vc16\bin
if you have installed OpenCV 4.7.0 and extracted it to C:/Program Files/opencv
.
警告
You may have to sign out of your Windows account and in again for the changes to take place.
When configuring the CMake project, include OpenCV to configure the samples that depend on it.
Navigate to the build directory you created in zivid-cpp-samples and run
cmake -DOpenCV_DIR=<path> -DUSE_EIGEN3=OFF -DUSE_PCL=OFF ../source
where <path>
is the full path to the OpenCV build folder, e.g. C:/Program Files/opencv/build
.
You need Halcon installed on your PC to run the Halcon C++ samples. Go to 在Windows中安装Zivid + HALCON for further instructions.
After you have installed Halcon, configure CMake to use Halcon samples.
Navigate to the build directory you created in zivid-cpp-samples and run
cmake -DUSE_HALCON=ON -DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF -DUSE_PCL=OFF -DUSE_OPEN3D=OFF ../source
Download and install prebuilt Open3D binaries from https://github.com/isl-org/Open3D/releases. Open3D does not support multi-configuration builds, so you must choose which to configure for.
Extract them to your desired destination, e.g.
C:\Program Files\Open3D
C:\Program Files\Open3D-Debug
In order for CMake to find Open3D you must do one of the following:
set the
CMAKE_INSTALL_PREFIX
variable to point to the folder containing theCMake
folder, or you mustset the
Open3D_DIR
variable to point to the folder containing theOpen3DConfig.cmake
file
Navigate to the build directory you created in zivid-cpp-samples and run
cmake -DUSE_OPEN3D=ON -DCMAKE_INSTALL_PREFIX=<path-to-open3d> -DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF -DUSE_PCL=OFF ../source
where <path-to-open3d>
is the path to the Open3D folder, e.g. C:/Program Files/Open3D
.
In order to run the Open3D samples, you must add the Open3D binary folder to your PATH environment variable.
If you want to configure multiple dependencies at once, you can simply add multiple dependencies at the same time in CMake. For example, if you want to use all samples that require Eigen and Open3D, you can run
mkdir build
cd build
cmake -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3 -DUSE_OPEN3D=ON -DUSE_PCL=OFF -DUSE_OPENCV=OFF ../source
cmake -DEIGEN3_INCLUDE_DIR=<path-to-eigen> -DUSE_OPEN3D=ON -DCMAKE_INSTALL_PREFIX=<path-to-open3d> -DUSE_PCL=OFF -DUSE_OPENCV=OFF ../source
where <path-to-open3d>
is the path to the Open3D folder, e.g. C:/Program Files/Open3D
.