C++ SDK Configuration
Windows
Runtime Environment Setup
In the Windows environment, RVC SDK will automatically add the runtime libraries into the system path during the installation process, you can check the runtime libraries information in the file under the installation directory:
/RVCSDK/examples/C++/CMakeLists.txt
To use the RVC SDK for C++ development, copy all the .dll files from the RVCSDK/runtime folder in the installation directory to the same directory as the .exe executable.
The following describes the steps to configure the C++ runtime environment on Win 10 system.
1. Install CMake
Download CMake from https://cmake.org/download/.
Download the .msi file for the current system version. When installing CMake, you need to add CMake to the system path for all users.
2. Install Visual Studio and C++ workloads
Recommended version: VS 2019 or VS 2017.
To install C++ workloads: When installing Visual Studio, check "Desktop development with C++" on the Visual Studio Installer "Workloads" page.
3. Install PCL and OpenCV
(1) Install PCL
PCL can be downloaded from https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.13.0.
Note that you need to download the two files listed in the box, and then double-click the .exe file to install them.
When installing PCL, you need to add PCL to the system path for all users and check the corresponding components.
(2) Install OpenCV
OpenCV download address: https://github.com/opencv/opencv/releases/tag/4.7.0.
Download opencv-4.7.0-windows.exe, unzip it to the installation directory, it will automatically generate the opencv folder.
Tip
To make sure CMake can find the OpenCV files, it is recommended to create a new OpenCV folder and install it under this path, as shown in the following figure.
4. Configure environment variables
In order to use OpenCV related functions, you need to configure environment variables for OpenCV.
On the desktop, right-click "This PC", click "Properties", find "Advanced system settings" in "Related settings". "and select "Environment Variables" in the "Advanced" tab.
Method 1: Click [New] in the list of user variables to create a new user variable.
Variable name - OpenCV_ROOT
Variable value - Select the folder where OpenCV is installed: OpenCV
Tip
This method needs to fulfill the previous step, i.e. create a new OpenCV folder first and and install it under this path.
Method 2: In the System Variables list, double-click the "Path" line (you can also select the Path line and then click [Edit]), and then click [New] in the pop-up window, add the paths of OpenCV installation directory:
/opencv/build/x64/vc16/bin
/opencv/build/x64/vc16/lib
/opencv/build/x64/vc16/lib
/opencv/build/include/opencv2
5. Configure the VC++ project
If you used method 2 in the previous step and generated with CMake, you may not be able to use OpenCV in Visual Studio and you need to complete the VC++ project configuration.
Open the ALL_BUILD project in Visual Studio and click the icon to open the Project Property Pages. Select the corresponding version in the Configuration column and set the include directories, library directories, and additional dependencies. The following operations are based on the Debug | x64 version for example.
Tip
The version of OpenCV installed here is 64-bit, so select x64. OpenCV is divided into Release and Debug versions, the configuration steps for Release version are the same as those for Debug version.
(1) Set the include directories
Select: Configuration Properties → VC++ Directories → General → Include Directories, click <Edit...>. In the pop-up window, add the paths under the OpenCV installation directory: /opencv/build/include and /opencv/build/include/opencv2.
(2) Set the library directories
Select: VC++ Directories → General → Library Directories, click <Edit...>. In the pop-up window, add the path under the OpenCV installation directory: /opencv/build/x64/vc16/lib.
(3) Set additional dependencies
Select: Configuration Properties → Custom Build Tool → General → Additional Dependencies, click <Edit...>. In the pop-up window, enter the .lib file name of the installed OpenCV version. The .lib file name can be found in the lib folder in the OpenCV installation directory: /opencv/build/x64/vc16/lib.
Tip
In the file name, 470 means OpenCV version is 4.7.0, with d means Debug version, without d means Release version, you can choose the corresponding version according to the working mode.
Running the Examples
1. Create the build folder
Go to the path in the installation directory: /RVCSDK/examples/C++ and create a "build" folder manually.
2. Use CMake to generate the project
Open CMake and configure the following two items:
Where is the source code - Select the path under the installation directory: /RVCSDK/examples/C++.
Where to build the binaries - Select the path under the installation directory: /RVCSDK/examples/C++/build.
Click [Configure], select the options according to the version, click [Finish]. After configuration, it prompts Configuring done. Click [Generate], if the generation succeed, it prompts Generating done.
When generating, if you find the following error for PCL and OpenCV.
You need to open the file: /RVCSDK/examples/C++/CMakeLists.txt in the installation directory, and modify the codes in lines 7 to 9:
option(USE_PCL "Enable samples which depend on Point Cloud Library (PCL)" ON)
//change OFF to ON
option(USE_Open3D "Enable samples which depend on Open3D" OFF)
option(USE_OpenCV "Enable samples which depend on OpenCV" ON)
//Modify OFF to ON
3. Build the solution
Open the solution RVCExampleCPP in Visual Studio, select ALL_BUILD in the Solution Explorer, right-click and select "Build".
When the build is complete, select the example you want to run, right-click and select "Set as Startup Project".
Click "Local Windows Debugger" in the menu bar to generate the solution.
After the example finishes running, the point cloud and images are saved in the /build/Data folder in the current execution path by default.
Linux
Runtime Environment Setup
In the Linux environment, RVC SDK provides CMake examples, which can be compiled directly. For information about the runtime libraries, please refer to the files in the installation directory:
/opt/RVC/examples/C++/CMakeLists.txt
The following describes the steps to configure the C++ runtime environment on Linux system, taking Debian 10 system as an example.
1. Install CMake and Make
Open the Terminal window and run the following command.
2. Install PCL and OpenCV
Install PCL:
Install OpenCV:
Running the Examples
1. Create the build folder
Use the cd command, switch to the C++ examples folder.
Use the mkdir command to create a build directory under the current path.
2. Build the C++ examples
Use the cd command again, switch to the build directory.
Build the C++ example with CMake.
3. Run the example
Take the CaptureUSB.cpp as an example, run it in the build directory:
After the program finishes running, the captured point cloud and images will be saved in the /build/Data folder in the current execution path by default.