C++ (Windows)

Sample Program Overview

The C++ sample programs are located at VcameraSDK-X.X.X/cpp/example and include:

  • ConnectByIpAddress.cpp: Opens a network camera by IP address.

  • DepthToPointCloud.cpp: Converts depth images to point clouds in real time during continuous capture.

  • DumpAllFeatures.cpp: Lists the features supported by the camera.

  • DumpDeviceInfo.cpp: Lists camera information.

  • FetchFrame.cpp: Captures depth images in continuous capture mode.

  • FullExample1.cpp: Converts depth data to 3D point clouds in real time in software trigger mode.

  • ImageRegistration.cpp: Aligns the output depth image with the color image in software trigger mode.

  • ListDevices.cpp: Lists all cameras connected to the computer.

  • LoadFeaturesFromFile.cpp: Loads camera feature settings from a specified JSON file and applies them to the camera.

  • LoadFeaturesFromStorage.cpp: Loads feature settings from the camera Storage area. This sample applies only to non-GenICam cameras.

  • LogConfig.cpp: Configures the Vcamera SDK logging system.

  • ReadCalibInfo.cpp: Reads calibration parameters for a specified sensor.

  • ReadWriteFeatures.cpp: Demonstrates how to read and write camera features.

  • SaveFeaturesToFile.cpp: Saves updated feature settings to a specified JSON file.

  • SaveFeaturesToStorage.cpp: Saves feature settings to the device Storage area. This sample applies only to non-GenICam cameras.

  • SetIpAddress.cpp: Sets a static IP address.

  • SetUndistortion.cpp: Captures and outputs distortion-corrected left grayscale images and color images after receiving a software trigger command.

  • SoftTrigger.cpp: Captures and outputs depth images after receiving a software trigger command.

  • UserSetSelector.cpp: Selects a user set. This sample applies only to GenICam cameras.

  • ReconnectWhenOffline.cpp: Automatically reconnects the camera after disconnection and resumes image acquisition.

Install Dependencies

Dependency 1 — CMake

Note

The recommended CMake version is 3.25. Other versions are not tested and the compatibility is not guaranteed.

  1. Download Windows installation package from CMake Percipio website .

  2. Double click the downloaded .msi installer file and follow the wizard to complete the installation. Important: Select the option “Add CMake to PATH” during the installation process to configure system environment variables automatically.

Cmake-configuration

CMake Environment Configuration

  1. Open Command Prompt and execute the following command to validate installation success by checking the version information:

    cmake --version
    

Dependency 2 — Visual Studio

Note

The recommended Visual Studio version is 2022. Other versions are not tested and the compatibility is not guaranteed.

Download and install Visual Studio. Important: During installation, select the Desktop development with C++ workload under the Desktop and Mobile Applications category.

vs-install

Install Visual Studio

Dependency 3 — OpenCV (Optional)

Note

  1. OpenCV is an optional dependency. When not installed, OpenCV-dependent sample features (such as image saving) will be skipped, without affecting the overall compilation and running of the samples.

  2. The recommended OpenCV version is 4.11.0. Other versions are not tested and the compatibility is not guaranteed.

  1. Download the Windows pre-built library from the OpenCV Percipio website.

  2. Double-click the downloaded .exe file and record the installation path.

  3. After extraction, configure the OpenCV library path in the system environment variables.

    Detailed steps: Access the Environment Variables dialog box, select the “Path” entry, and click Edit. In the Edit Environment Variables dialog box, configure the OpenCV library path.

    wincompilestep4

    OpenCV Environment Configuration

Dependency 4 — USB Driver (Optional)

If you use a USB camera, complete Set Up USB Camera Environment before proceeding.

Compile Sample Programs

  1. Create a folder named build in the directory VcameraSDK-X.X.X/cpp/example .

  2. Launch cmake-gui.

  3. Specify the source code directory as “example” and the output directory for compilation as “example/build”.

    vcamera-compile-dir
  4. Click Configure, select the Visual Studio version, and click Finish.

    vcamera-compile-configure
  5. Click Generate.

    vcamera-compile-generate
  6. Click Open Project to open the project.

    vcamera-compile-openpro
  7. Select the build configuration “Release” (recommended) or “Debug”, select the platform “x64”, then click “Build” > “Build Solution”.

    vcamera-compile-end

Execution

  1. According to the build configuration (Release or Debug), copy all files from VcameraSDK-X.X.X/cpp/win/<build configuration>/bin to the VcameraSDK-X.X.X/cpp/example/build/<build configuration>/ directory. Do not mix files from different configurations.

  2. If the sample program uses OpenCV, copy the corresponding .dll files from the build\x64\vc16\bin folder under the OpenCV installation directory to the output directory of the corresponding configuration, such as VcameraSDK-X.X.X/cpp/example/build/Release/ or VcameraSDK-X.X.X/cpp/example/build/Debug/.

    Specific operations:

    • For the Release configuration, copy opencv_world<version>.dll (for example, opencv_world4120.dll).

    • For the Debug configuration, copy opencv_world<version>d.dll (for example, opencv_world4120d.dll).

  3. Run the sample program:

    .\FetchFrame.exe -sn <camera serial number> -depth
    
    Running the sample program