Skip to content

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/.

CMakeDownload

Download the .msi file for the current system version. When installing CMake, you need to add CMake to the system path for all users.

CMakeInstall

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.

CppWorkloads_en

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.

PCLDownload

When installing PCL, you need to add PCL to the system path for all users and check the corresponding components.

PCLPath_en

PCLComponents_en

(2) Install OpenCV

OpenCV download address: https://github.com/opencv/opencv/releases/tag/4.7.0.

OpenCVDownload

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.

OpenCVInstall_en

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.

SystemSettings_en

EnvironmentVariable_en

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.

OpenCVROOT_en

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

OpenCVPaths_en

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.

ProjectAttribute_en

AttributeDebugx64_en

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.

OpenCVInclude_en

OpenCVIncludePath_en

(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.

OpenCVLib_en

OpenCVLibPath_en

(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.

OpenCVLibFile_en

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.

OpenCVDependencies_en

OpenCVDependenciesPath_en

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.

CMakex64Cpp

CppCMakeConfigure

When generating, if you find the following error for PCL and OpenCV.

PCL samples have been disabled.
OpenCV samples have been disabled.

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".

CppBuild_en

When the build is complete, select the example you want to run, right-click and select "Set as Startup Project".

CppStartProject_en

Click "Local Windows Debugger" in the menu bar to generate the solution.

WindowsDebug_en

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.

sudo apt-get install cmake make

2. Install PCL and OpenCV

Install PCL:

sudo apt-get install libpcl-dev

Install OpenCV:

sudo apt-get install libopencv-dev

Running the Examples

1. Create the build folder

Use the cd command, switch to the C++ examples folder.

cd /opt/RVC/examples/C++

Use the mkdir command to create a build directory under the current path.

mkdir build

2. Build the C++ examples

Use the cd command again, switch to the build directory.

cd build

Build the C++ example with CMake.

cmake ...
make

3. Run the example

Take the CaptureUSB.cpp as an example, run it in the build directory:

. /CaptureUSB

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.