How to integrate RapidPixel SDK into your project
The RapidPixel SDK is a set of cross-platform C++ libraries that allow creating real-time video processing applications with proven performance. In order to build all libraries correctly, including those dependent on external libraries, start by installing the External dependencies. If the required external dependencies are not installed, only the libraries that do not rely on these dependencies will be built. The user can link the RapidPixel SDK to a C++ project as source code (CMake submodule) or as a compiled library. The RapidPixel SDK is compiled as a single library. The user just includes RapidPixel.h in C++ files. The RapidPixel SDK has different dependencies, but the user needs to link additional libraries to the project only if using a particular library with dependencies from the SDK. The RapidPixel SDK has special structure. Each library folder inside SDK is self-sufficient and can be used separately if necessary.
Then all you need to do is connect the RapidPixel SDK to your project, depending on your configuration:
External dependencies
Some of the libraries in the RapidPixel SDK are dependent on a few external libraries. If the external library (that is necessary for proper usage of the chosen repository) is not installed, the related repository of the RapidPixel SDK will not be built. The detailed list of libraries and their dependencies can be found here: RapidPixel.
Many libraries from the RapidPixel SDK use OpenCV and OpenMP. It is recommended to install OpenCV and OpenMP libraries in the OS before building or using the RapidPixel SDK and linking those libraries to your project. If you need to use a library with a particular dependency, please follow the installation instructions in such library documentation.
OpenMP install
OpenMP comes with many modern compilers. If you need to install it, follow these steps:
-
On Windows OpenMP is included in the Visual Studio installation, so no additional steps are required.
-
On Linux You may need to install the
libomp-dev
package:sudo apt-get install libomp-dev
OpenCV install
-
On Windows
Only versions >= 4.5.0 are supported. Download the OpenCV installer from the official website, for example LINK. Run the opencv-version-windows.exe file and extract the library to your desired directory, for example C:/Libs/OpenCV.
-
On Linux On Linux, it can be installed either from source code or from the apt package manager. If you are installing by using the package manager, ensure that you have the proper version of OpenCV. Command to install:
sudo apt-get install -y libopencv-dev
Linking OpenCV in a Visual Studio project on Windows
-
In Properties, go to VC++ Directories -> General -> Include Directories -> Edit and add the OpenCV include directory:
C:\Libs\OpenCV\opencv\build\include
-
In Properties, go to VC++ Directories -> General -> Library Directories -> Edit and add the OpenCV lib directory:
C:\Libs\OpenCV\opencv\build\x64\vc16\lib
-
In Properties, go to Linker -> Input -> Additional Dependencies -> Edit and add lib files, depending on your current project configuration:
Debug configuration: opencv_world480d.lib Release configuration: opencv_world480.lib
Linking OpenCV in a Qt Creator project on Windows
-
To include headers, edit the YourProject.pro file by adding:
INCLUDEPATH += C:\Libs\OpenCV\opencv\build\include
-
Specify lib files:
Debug { LIBS += C:\Libs\OpenCV\opencv\build\x64\vc16\lib\opencv_world480d.lib } Release { LIBS += C:\Libs\OpenCV\opencv\build\x64\vc16\lib\opencv_world480.lib }
How to build the SDK
-
Download the SDK package.
-
The unpacked folder should look like this:
RapidPixelSdk > example > modules > RapidPixel CMakeLists.txt GettingStarted.md RapidPixelConfig.cmake CMakeLists.txt
-
Open the terminal inside the RapidPixelSdk folder and run the following commands:
For Windows:
# Configure CMake project with specified build type (Debug/Release). cmake -B build # Build all libraries with proper target and specified build type (Debug/Release). cmake --build build --config Release --target ALL_BUILD
For Linux:
# Configure CMake project with specified build type (Debug/Release). cmake -B build -D CMAKE_BUILD_TYPE=Release # Build all libraries with proper target and specified build type (Debug/Release). cmake --build build --config Release --target all
-
Review your new RapidPixelSdk structure:
> RapidPixelSdk > build > docs > example > include > lib > modules > RapidPixel CMakeLists.txt RapidPixel.h GettingStarted.md RapidPixelConfig.cmake CMakeLists.txt
-
Now everything is set up to start using the RapidPixel SDK in your project. Check the Example application here to see an example of usage.
Connect using a CMake-based project
-
Go to your CMake-based project directory and modify the CMakeLists.txt file to include the RapidPixel library.
# Link the RapidPixel libraries find_package(RapidPixel REQUIRED) target_link_libraries(${PROJECT_NAME} RapidPixel)
-
Configure your project by defining the RapidPixel_DIR macro:
mkdir build cd build cmake .. -D RapidPixel_DIR=C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel
Connect using a Visual Studio project
-
Open your project, for instance YourProject.sln.
-
Right-click on YourProject in Solution Explorer and hit Properties.
-
In Properties, go to VC++ Directories -> General -> Include Directories -> Edit and add the RapidPixel include directory:
C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\include
-
In Properties, go to VC++ Directories -> General -> Library Directories -> Edit and add the RapidPixel lib directory:
Debug configuration: C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\lib\Debug Release configuration: C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\lib\Release
-
In Properties, go to Linker -> Input -> Additional Dependencies -> Edit and add the RapidPixel.lib or RapidPixeld.lib library, depending on your current project configuration:
Debug configuration: RapidPixeld.lib Release configuration: RapidPixel.lib
-
Remember to apply C++17 standard: General -> C++ Language Standard -> ISO C++17 Standard (/std:c++17).
-
Hit the Apply button and close the Properties page.
Connect using a Qt Creator project
-
Open your qmake project, for instance YourProject.
-
To include headers, edit the YourProject.pro file by adding:
INCLUDEPATH += C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\include
-
Specify lib files:
Debug { LIBS += C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\lib\Debug\RapidPixeld.lib } Release { LIBS += C:\Libs\Windows_RP_INCLUDE_PACK\RapidPixel\lib\Release\RapidPixel.lib }
-
Remember to keep C++17 language standard:
CONFIG += c++17
-
Save the YourProject.pro file; it is now ready to use the RapidPixel SDK.
Example application
The example application provides a brief showcase of how to include RapidPixel SDK headers into your project and use all utilities. The example is a CMake-based project with the following CMakeLists.txt file:
cmake_minimum_required(VERSION 3.15)
project(RapidPixelExample VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Create glob patterns for *.h and *.cpp files
file (GLOB H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file (GLOB CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# Concatenate the results (glob files) into variable
set (SOURCES ${CPP_FILES} ${H_FILES})
# Create executable from sources
if (NOT TARGET ${PROJECT_NAME})
add_executable(${PROJECT_NAME} ${SOURCES})
endif()
# Link the RapidPixel libraries
find_package(RapidPixel REQUIRED)
target_link_libraries(${PROJECT_NAME} RapidPixel)
find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} OpenMP::OpenMP_CXX)
While including RapidPixel SDK headers, remember to add RapidPixel/
before the library name; use the following structure:
#include <RapidPixel/LibraryNameHeader.h>
Alternatively, if it’s more convenient, you can include all headers at once using:
#include <RapidPixel/RapidPixel.h>
NOTE: Remember! To use a particular library, all the dependencies have to be included in your project. For instance, in order to use a library that is OpenCV and OpenMP dependent, you have to add the following code to your project:
find_package(OpenCV)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} OpenMP::OpenMP_CXX)
Source code of the example:
#include <iostream>
#include <RapidPixel/RapidPixel.h>
int main()
{
std::cout << "======================================" << std::endl;
std::cout << "========= RapidPixel example =========" << std::endl;
std::cout << "======================================" << std::endl;
std::cout << "VSourceOpenCv version: " << cr::video::VSourceOpenCv::getVersion() << std::endl;
std::cout << "VTracker version: " << cr::vtracker::VTracker::getVersion() << std::endl;
std::cout << "DnnOpenCvDetector version: " << cr::detector::DnnOpenCvDetector::getVersion() << std::endl;
return 0;
}
The example application is configured with the appropriate command, which sets up the necessary paths for the RapidPixel SDK and external dependencies such as OpenCV. The configuration will depend on the specific libraries of the SDK that the user wants to use. The command to configure the project is:
cmake -B build -D RapidPixel_DIR=path_to_RapidPixelSdk_folder -D OpenCV_DIR=path_to_opencv_folder
Adjust the paths according to your installations.