C++ (Linux)
Sample Program Overview
C++ sample programs are located in VcameraSDK-X.X.X/cpp/example and include:
ConnectByIpAddress.cpp: Opens a network camera using its IP address.DepthToTextureRegistration.cpp: Configures the camera in software trigger mode and aligns the output depth image with the color image.DepthToPointCloud.cpp: Configures the camera in continuous acquisition mode and converts depth data into point clouds in real time.DumpAllFeatures.cpp: Lists all features supported by the camera.DumpDeviceInfo.cpp: Lists camera information.FetchFrame.cpp: Configures the camera in continuous acquisition mode to capture depth images.FullExample1.cpp: Configures the camera in software trigger mode and converts depth data into point clouds in real time.ListDevices.cpp: Lists all cameras connected to the computer.ReadWriteFeatures.cpp: Demonstrates how to read and write camera features.SetIpAddress.cpp: Sets a static IP address for the camera.SetUndistortion.cpp: Configures the camera in software trigger mode. When the camera receives a software trigger command, it captures and outputs the undistorted left grayscale image and color image. All output images are automatically saved to the same directory as the executable.SoftTrigger.cpp: Configures the camera in software trigger mode. After receiving a software trigger command, the camera captures and outputs a depth image.UserSetSelector.cpp: Selects a user set, which is a saved group of camera feature settings. This sample only applies to Gige_2.1 cameras that support user sets.LogConfig.cpp: Configures the Vcamera SDK software logging system.SaveFeaturesToStorage.cpp: Saves parameter settings to the device Storage area. This sample only applies to Gige_2.0 cameras that do not support user sets.LoadFeaturesFromStorage.cpp: Loads parameter settings from the Storage area and applies them to the camera. This sample only applies to Gige_2.0 cameras that do not support user sets.SaveFeaturesToFile.cpp: Saves modified parameter settings to a specified JSON file.LoadFeaturesFromFile.cpp: Loads camera parameter settings from a specified JSON file and applies them to the camera.
Install Dependencies
Dependency 1 - CMake
Run the following command in the terminal to install CMake.
sudo apt-get install cmake
Verify the installation. If a version number is displayed, the installation succeeded.
cmake --version
Note
CMake 3.24.0 is recommended. This version has been fully validated for compatibility. Other versions have not been fully tested and compatibility is not guaranteed.
Dependency 2 - OpenCV (Optional)
If you need image processing functionality such as image saving, install OpenCV. If OpenCV is not installed, OpenCV-dependent samples are skipped automatically during compilation without affecting the overall build or execution of the samples.
sudo apt-get install libopencv-dev
Note
OpenCV 4.9.0 is recommended. This version has been fully validated for compatibility. Other versions have not been fully tested and compatibility is not guaranteed.
Dependency 3 - USB Driver (Optional)
If you need to use a USB camera, complete the USB camera environment preparation steps.
Build and Run
Build the sample programs.
cd example mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j4
Note
The cmake command supports the following options:
Build the release version (recommended):
-DCMAKE_BUILD_TYPE=ReleaseBuild the debug version:
-DCMAKE_BUILD_TYPE=DebugBuild with OpenCV support:
-DOpenCV_DIR=/path/to/opencv/build. Replace /path/to/opencv/cmake with the directory that contains OpenCVConfig.cmake, for example,-DOpenCV_DIR=/opt/opencv4.9/lib/cmake/opencv4.
If OpenCV is not installed, OpenCV-dependent samples are skipped automatically during compilation.
Run the program.
./FetchFrame -sn <camera_serial_number>