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
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 |
|---|---|---|---|---|
ReadPCLVis3D |
YES |
|||
CaptureWritePCLVis3D |
YES |
|||
CaptureAndVisualizeNormals |
YES |
|||
StitchByTransformation |
||||
StitchByTransformationFromZDF |
||||
MaskPointCloud |
YES |
YES |
||
ROIBoxViaCheckerboard |
YES |
|||
UtilizeHandEyeCalibration |
YES |
|||
PoseConversions |
YES |
|||
ROIBoxViaArucoMarker |
YES |
YES |
||
CaptureUndistort2D |
YES |
|||
CreateDepthMap |
YES |
|||
ProjectAndFindMarker |
YES |
|||
ReprojectPoints |
YES |
|||
ReadProjectAndCaptureImage |
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 ../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 ../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 ../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 ../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 Install Zivid + HALCON for Windows for further instructions.
After you have installed Halcon, configure CMake to use Halcon samples.
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, PCL and OpenCV, you can run
cmake -DEIGEN3_INCLUDE_DIR=<path-to-eigen> -DUSE_PCL=ON -DOpenCV_DIR=<path-to-opencv> ../source
where <path-to-eigen> and <path-to-opencv> are the paths to your Eigen and OpenCV folders.