Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Getting Started with C++

The CVB++ API is a modern, object-oriented C++ wrapper for the core CVB SDK. It is implemented as a header-only library and provides a convenient and type-safe interface on top of the underlying C API. This design allows seamless integration into C++ projects without the need for separate library binaries or additional build steps.

To ensure long-term reliability and compatibility, CVB is built on a stable and well-defined core interface:

The CVB C-API maintains a stable application binary interface (ABI), ensuring that applications built against a specific version continue to work with newer CVB versions without requiring recompilation, as long as the interface contract remains unchanged.

Note
While the C++, .NET, and Python wrappers are not strictly bound to API stability, they are designed with a strong focus on API consistency and backward compatibility. Therefore, even in these higher-level APIs, changes are introduced carefully and in a controlled manner to maintain a stable development experience.

Prerequisites

  • CVB must be installed successfully.
  • Supported operating system:
    • Windows 10 or later
    • Ubuntu 20.04.
  • Your compiler must be fully C++14-compliant.
  • CMake version 3.5 or higher.
  • On Windows, if you are using Microsoft Visual Studio, use version 2015 (MSVC 14.0) or newer.
  • If you want to display images, you can integrate Qt/QML as described in C++ - Image Display Using Qt/QML.

Building a Sample Application with CMake

To compile a CVB-based application using CMake, you first need to install CMake and ensure it is available in your system’s PATH.

If you want to generate a Microsoft Visual Studio solution or compile CVB code on any other platform using CMake, you need to create a CMakeLists.txt file. Your CVB installation already includes sample projects with CMake support. You can find them in %CVB%%/Tutorial (on Windows) or $CVB/tutorial (on Linux). A list of all C++ example programs can also be found here.

A minimal CMakeLists.txt starts with the required CMake version, the C++ standard to use, and the project name:

cmake_minimum_required(VERSION 3.5)
project(CppCameraIPConfig)
set (CMAKE_CXX_STANDARD 14)

Next, add the following lines to locate the FindCVB.cmake module, which is provided in %CVB%cmake. This module allows CMake to find and correctly link against the necessary CVB libraries:

#find CVB
file(TO_CMAKE_PATH "$ENV{CVB}/cmake" CVB_MODULE_PATH)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CVB_MODULE_PATH}")
find_package(CVB REQUIRED)

Then, define your executable and link it with the required CVB libraries using target_link_libraries. All available CVB targets are defined in FindCVB.cmake. To find out which CVB target corresponds to the namespaces and classes you are using, refer to the list of CVB libraries.

add_executable(${PROJECT_NAME}
main.cpp )
target_link_libraries(${PROJECT_NAME}
CVB::CVCDriver
CVB::CVCImg;
CVB::CVCUtilities;
CVB::CVCore;
CVB::CVGenApi;
)

C++ API Concept

The CVB C++ wrapper is located in your CVB installation directory under CVB%\Lib\C\cvb. All classes and functions are part of the Cvb namespace. Additional namespaces and classes are used for specific functionality.

To use the wrapper, include the corresponding header file and call the functions via the Cvb namespace:

#include <cvb/device_factory.hpp>
auto devices = Cvb::DeviceFactory::Discover(Cvb::DiscoveryFlags::IgnoreVins);
static std::vector< DiscoveryInformation > Discover()

Image Display with Qt/QML

To display images with CVB, you can use Qt. For more details, refer to C++ - Image Display Using Qt/QML.

Next Steps and Further Reading

C++ Example Programs in CVB Installation
Code Examples
C++ API Documentation

C++ - Image Display Using Qt/QML
CVB Development Workflow Overview