API Descriptions (C++)
GetVersionString()
Gets VCameraSDK Version.
// Include the header file at the beginning of the code
#include "sdk/version.h"
// Print VCameraSDK version
std::cout << "GetVersionString:" << GetVersionString() << std::endl;
CameraUtils Class
CameraUtils is a static utility class provided by the SDK, dedicated to camera discovery and network configuration.
Init()
Initializes the underlying camera communication library.
CameraUtils::Init(true);
Important
Direct connection mode (default and recommended): Call
Init(true). This mode is suitable for most users. Each camera can be connected by only one process at a time in this mode.RPC mode (advanced): Call
Init(false). This mode supports multi-process connections. It is intended only for scenarios that require multi-process access and is not recommended for most users. To use this mode, copy the files inVcameraSDK-X.X.X/rpc/to the program directory. For detailed usage instructions, contact Percipio Technical Support.
DiscoverCameras()
Discovers the currently available cameras and returns a list of CameraInfo (including MAC address, current IP, etc.).
CameraUtils::Init();
auto devicelist = CameraUtils::DiscoverCameras();
for (auto& device : devicelist) {
std::cout << "======Device Information======" << std::endl;
std::cout << " " << "serial_number : " << device.serial_number << std::endl;
std::cout << " " << "status : " << (int)device.state << std::endl;
std::cout << " " << "model : " << device.model << std::endl;
std::cout << " " << "vendor : " << device.vendor << std::endl;
std::cout << " " << "name : " << device.name << std::endl;
std::cout << " " << "firmware_version : " << device.firmware_version << std::endl;
std::cout << " " << "network_info.mac : " << device.network_info.mac << std::endl;
std::cout << " " << "network_info.ip : " << device.network_info.ip << std::endl;
std::cout << " " << "network_info.netmask : " << device.network_info.netmask << std::endl;
std::cout << " " << "network_info.gateway : " << device.network_info.gateway << std::endl;
std::cout << " " << "network_info.broadcast : " << device.network_info.broadcast << std::endl;
std::cout << "Interface Information" << std::endl;
std::cout << " " << "interface_info.id : " << device.interface_info.id << std::endl;
std::cout << " " << "interface_type : " << (int)device.interface_info.interface_type << std::endl;
std::cout << " " << "interface_info.name : " << device.interface_info.name << std::endl;
std::cout << " " << "interface_info.network_info.broadcast : " << device.interface_info.network_info.broadcast << std::endl;
std::cout << " " << "interface_info.network_info.gateway : " << device.interface_info.network_info.gateway << std::endl;
std::cout << " " << "interface_info.network_info.ip : " << device.interface_info.network_info.ip << std::endl;
std::cout << " " << "interface_info.network_info.mac : " << device.interface_info.network_info.mac << std::endl;
std::cout << " " << "interface_info.network_info.netmask : " << device.interface_info.network_info.netmask << std::endl;
std::cout << " " << "usb_info.address : " << device.usb_info.address << std::endl;
std::cout << " " << "usb_info.bus : " << device.usb_info.bus << std::endl;
}
SetIpAddress()
Sets the camera’s IP to static. It has two usage methods:
First method: Input the camera’s MAC address and the desired IP, netmask, and gateway.
CameraUtils::Init(); auto devicelist = CameraUtils::DiscoverCameras(); CameraApiStatus ret = CameraUtils::SetIpAddress("06:20:FD:B6:D4:95","192.168.6.85","255.255.255.0","192.168.6.1"); if (ret.IsSuccess()) { printf("Set camera static ip success!\n"); } else { printf("Set camera static ip failed : %s\n", ret.message().c_str()); }
Second method: Input the camera’s CamInfo and the desired IP, netmask, and gateway.
CameraUtils::Init(); auto devicelist = CameraUtils::DiscoverCameras(); for (auto& device : devicelist) { if (device.network_info.mac == "06:20:FD:B6:D4:95" && device.interface_info.id == "eth-88-a4-c2-b1-35-e37f06a8c0") { CameraApiStatus ret = CameraUtils::SetIpAddress(device, "192.168.6.88", "255.255.255.0", "192.168.6.1"); if (ret.IsSuccess()) { printf("Set camera static ip success!\n"); } else { printf("Set camera static ip failed : %s\n", ret.message().c_str()); } } }
SetIpToDynamic()
Sets the camera IP to dynamic. It has two usage methods:
First method: Input the camera’s MAC address.
CameraUtils::Init(); auto devicelist = CameraUtils::DiscoverCameras(); CameraApiStatus ret = CameraUtils:: SetIpToDynamic ("06:20:FD:B6:D4:95"); if (ret.IsSuccess()) { printf("Set camera Dynamic ip success!\n"); } else { printf("Set camera Dynamic ip failed : %s\n", ret.message().c_str()); }
Second method: Input the camera’s CamInfo.
CameraUtils::Init(); auto devicelist = CameraUtils::DiscoverCameras(); for (auto& device : devicelist) { if (device.network_info.mac == "06:20:FD:B6:D4:95" && device.interface_info.id == "eth-88-a4-c2-b1-35-e37f06a8c0") { CameraApiStatus ret = CameraUtils::SetIpToDynamic(device); if (ret.IsSuccess()) { printf("Set camera dynamic ip success!\n"); } else { printf("Set camera dynamic ip failed : %s\n", ret.message().c_str()); } } }
CameraFactor Class
CameraFactory is a factory class defined by the Percipio SDK, specialized in instantiating and connecting cameras with different configurations. It provides three static factory methods to create camera instances via serial number, IP address, or pre-configured information.
GetCameraBySerialNumber()
Creates a camera instance by its serial number.
Camera camera = CameraFactory::GetCameraBySerialNumber("207000159118");
GetCameraByIpAddress()
Creates a camera instance by its IP address.
Camera camera = CameraFactory::GetCameraByIpAddress("192.168.6.58");
GetCameraByCameraInfo()
Creates a camera instance by the camera’s information.
Camera camera;
auto devicelist = CameraUtils::DiscoverCameras();
for (auto& list : devicelist) {
if(list.serial_number == "207000162237")
camera = CameraFactory::GetCameraByCameraInfo(list);
}
Camera Class
Provides core device control and image acquisition interface.
Note
Camera Instance Usage Workflow:
Create Camera instance -> Connect() -> Perform other operations -> Disconnect()
GetCameraInfo()
Obtains camera information.
CameraInfo information;
CameraApiStatus ret = camera.GetCameraInfo(information);
if (ret.IsSuccess()) {
printf("\033[91mGetCameraInfo success\033[0m\n");
std::cout << "Device Information" << std::endl;
std::cout << " " << "serial_number : " << information.serial_number << std::endl;
std::cout << " " << "status : " << (int)information.state << std::endl;
std::cout << " " << "model : " << information.model << std::endl;
std::cout << " " << "vendor : " << information.vendor << std::endl;
std::cout << " " << "name : " << information.name << std::endl;
std::cout << " " << "firmware_version : " << information.firmware_version << std::endl;
std::cout << " " << "network_info.mac : " << information.network_info.mac << std::endl;
std::cout << " " << "network_info.ip : " << information.network_info.ip << std::endl;
std::cout << " " << "network_info.netmask : " << information.network_info.netmask << std::endl;
std::cout << " " << "network_info.gateway : " << information.network_info.gateway << std::endl;
std::cout << " " << "network_info.broadcast : " << information.network_info.broadcast << std::endl;
std::cout << "Interface Information" << std::endl;
std::cout << " " << "interface_info.id : " << information.interface_info.id << std::endl;
std::cout << " " << "interface_type : " << (int)information.interface_info.interface_type << std::endl;
std::cout << " " << "interface_info.name : " << information.interface_info.name << std::endl;
std::cout << " " << "interface_info.network_info.broadcast : " << information.interface_info.network_info.broadcast << std::endl;
std::cout << " " << "interface_info.network_info.gateway : " << information.interface_info.network_info.gateway << std::endl;
std::cout << " " << "interface_info.network_info.ip : " << information.interface_info.network_info.ip << std::endl;
std::cout << " " << "interface_info.network_info.mac : " << information.interface_info.network_info.mac << std::endl;
std::cout << " " << "interface_info.network_info.netmask : " << information.interface_info.network_info.netmask << std::endl;
std::cout << " " << "usb_info.address : " << information.usb_info.address << std::endl;
std::cout << " " << "usb_info.bus : " << information.usb_info.bus << std::endl;
}
Connect()
Connects to the camera.
camera.Connect();
Disconnect()
Disconnects from the camera.
camera.Disconnect();
GetCameraState()
Obtains the camera state.
CameraState camerastate;
CameraApiStatus ret = camera.GetCameraState(camerastate);
if (ret.IsSuccess()) {
printf("\033[96mCameraState %d\033[0m\n", camerastate);
}
else {
printf("\033[91mGetCameraState failed :%s\033[0m\n", ret.message().c_str());
}
StartCapture()
Controls the camera to start capturing images.
camera.StartCapture();
StopCapture()
Controls the camera to stop capturing images.
camera.StopCapture();
GetFeature()
Obtains a feature for setting.
Important
The list of features supported by the SDK for configuration can be found in {SDK_INSTALLATION_PATH}\Percipio_SDK\doc\feature_list.txt.
Feature feature;
CameraApiStatus ret = camera.GetFeature("AcquisitionMode", feature);
if (!ret.IsSuccess()) {
printf("\033[91mGetFeature failed :%s\033[0m\n", ret.message().c_str());
}
GetAllFeatures()
Get all features.
std::vector<percipio::Feature> features;
status = camera.GetAllFeatures(features);
For detailed usage examples, refer to the sample program VcameraSDK-X.X.X/cpp/example/DumpAllFeatures.cpp.
FireSoftwareTrigger()
Sends a software trigger signal to a camera operating in software trigger mode.
CameraApiStatus status = camera.FireSoftwareTrigger();
std::cout << "FireSoftwareTrigger status= " << status.message() << std::endl;
GetImageModes()
Obtains the image formats and resolutions that can be set for a specified sensor.
std::vector<ImageMode> image_mode;
CameraApiStatus ret = camera.GetImageModes(SensorType::Depth, image_mode);
if (!ret.IsSuccess()) {
printf("\033[91mGetImageModes failed :%s\033[0m\n", ret.message().c_str());
}
else {
for (auto& mode : image_mode) {
printf("ImageModePixelFormat : %d , ImageModeWidth :%d ,ImageModeHeight :%d\n ", mode.pixel_format , mode.width, mode.height);
}
}
GetCurrentImageMode()
Obtains the current image format and resolution of a specified sensor.
ImageMode image_mode;
camera.GetCurrentImageMode(SensorType::Depth, image_mode);
printf("CurrentImageModePixelFormat : %d , ImageModeWidth :%d ,ImageModeHeight :%d\n ", image_mode.pixel_format , image_mode.width, image_mode.height);
SetImageMode()
Sets the image format and resolution for a specified sensor.
ImageMode image_mode;
image_mode.pixel_format = RawPixelFormat::Coord3D_C16;
image_mode.width = 320;
image_mode.height = 240;
CameraApiStatus ret = camera.SetImageMode(SensorType::Depth, image_mode);
printf("\033[91mSetImageMode1 :%s\033[0m\n", ret.message().c_str());
HasSensor()
Determines whether the camera has a specified sensor.
bool has_sensor;
CameraApiStatus ret = camera.HasSensor(SensorType::Right, has_sensor);
if (!ret.IsSuccess()) {
printf("\033[91mHasSensor Call failed :%s\033[0m\n", ret.message().c_str());
}
else {
printf("HasSensor : %s\n", has_sensor ? "true" : "false");
}
IsSensorEnabled()
Determines whether a specified sensor of the camera is enabled.
bool is_enable;
ret = camera.IsSensorEnabled(SensorType::Texture, is_enable);
if (!ret.IsSuccess()) {
printf("\033[91mIsSensorEnabledCallfailed:%s\033[0m\n", ret.message().c_str());
}
else {
printf("IsSensorEnabled:%s\n", is_enable ? "true" : "false");
}
SetSensorEnabled()
Enables/disables image output for a specified sensor.
CameraApiStatus ret = camera.SetSensorEnabled(SensorType::Left, true);
if (!ret.IsSuccess()) {
printf("\033[91mSetSensorEnabled Call failed :%s\033[0m\n", ret.message().c_str());
}
SetUndistortionEnabled()
Applies/removes distortion correction for images from a specified sensor.
CameraApiStatus ret = camera.SetUndistortionEnabled(SensorType::Left, true);
printf("\033[91mSetUndistortionEnabled:%s\033[0m\n", ret.message().c_str());
IsMapDepthToTextureEnabled()
Used to query whether depth-to-color image mapping (depth and color alignment) is enabled.
bool isEnabled = false;
status = camera.IsMapDepthToTextureEnabled(isEnabled);
if (!status.IsSuccess()) {
std::cout << "Failed to check depth-to-color mapping status: " << status.message() << std::endl;
return -1;
}
std::cout << "Current depth-to-color mapping status: " << (isEnabled ? "Enabled" : "Disabled") << std::endl;
SetMapDepthToTextureEnabled()
Enables or disables depth-to-color image mapping (alignment between depth and color images).
status = camera.SetMapDepthToTextureEnabled(true);
if (!status.IsSuccess()) {
std::cout << "enable MapDepthToTexture err " << status.message() << std::endl;
return -1;
}
For the detailed usage example, please refer to the sample program Percipio_SDK/API/cpp/example/DepthToColorRegistration.cpp.
SaveFeaturesToFile()/LoadFeaturesFromFile()
These interfaces are used to save camera configurations to a JSON file and to load configurations from a JSON file and apply them to the camera.
Note
Save behavior differs by camera type:
Gige_2_0 cameras: Only parameters modified after the camera is connected are saved. Parameters already stored before connection are not recorded.
Gige_2_1 cameras: As many parameters as possible are saved. For the specific list of saved parameters, refer to
doc/feature_save_gige2_1.txtin the installation directory.
Save Configurations to a File:
std::string file_path_save = u8"D:/tmp/1.json";
status = camera.SaveFeaturesToFile(file_path_save);
Load Configurations from a File:
std::string file_path_load = u8"D:/tmp/1.json";
std::string error_message;
status = camera.LoadFeaturesFromFile(file_path_load, error_message);
For detailed usage examples, refer to the following sample programs:
VcameraSDK-X.X.X/cpp/example/SaveFeaturesToFile.cppVcameraSDK-X.X.X/cpp/example/LoadFeaturesFromFile.cpp
SaveFeaturesToStorage()/LoadFeaturesFromStorage()
These interfaces are used to save camera configurations to the internal storage area and to load configurations from the internal storage area.
Note
These interfaces apply only to Gige_2_0 cameras.
For Gige_2_1 cameras, use the user-set-manager-C++ interface.
Save Configurations to the Internal Storage Area:
bool save_to_storage = true;
if (save_to_storage) {
status = camera.SaveFeaturesToStorage();
}
Load Configurations from the Internal Storage Area:
status = camera.StopCapture();
std::string error_message;
status = camera.LoadFeaturesFromStorage(error_message);
For detailed usage examples, refer to the following sample programs:
VcameraSDK-X.X.X/cpp/example/SaveFeaturesToStorage.cppVcameraSDK-X.X.X/cpp/example/LoadFeaturesFromStorage.cpp
RegisterFrameSetCallback()
Registers an image callback function.
camera.RegisterFrameSetCallback([](const FrameSet& frameset){
cout << "FrameSetCallback" << endl;
Image image = frameset.GetImage(SensorType::Depth);
if(image.IsValid()){
cout << "Image: width:" << image.width() << " " << "height:" << image.height() << endl;
cout << "Image: frame index:" << image.frame_index() << endl;
cout << "Image: timestamp:" << image.time_stamp() << endl;
cout << "Image: sensor:" << image.sensor() << endl;
cout << "Image: sensor type:" <<(int)image.pixel_format() << endl;
cout << "Image: scale_unit:" << image.scale_unit() << endl;
cout << "Image: distortion:";for(float f : image.calib_info().distortion.data) cout << f << " "; cout << endl;
cout << "Image: intrinsic:";for(float f : image.calib_info().intrinsic.data) cout << f << " "; cout << endl;
cout << "Image: extrinsic:";for(float f : image.calib_info().extrinsic.data) cout << f << " "; cout << endl;
}
});
RegisterCameraEventCallback()
Registers a camera event callback function.
camera.RegisterCameraEventCallback(
[](CameraEventCode event_code, int error_code) {
switch (event_code) {
case CameraEventCode::Offlined:
printf("\033[93mWaiting for reconnecting ... ...\033[0m\n");
break;
case CameraEventCode::Started:
printf("\033[93mCamera Started ... ...\033[0m\n");
break;
case CameraEventCode::Opened:
printf("\033[93mCamera Opened ... ...\033[0m\n");
break;
case CameraEventCode::Stopped:
printf("\033[93mCamera Stopped ... ...\033[0m\n");
break;
case CameraEventCode::Closed:
printf("\033[93mCamera Closed ... ...\033[0m\n");
break;
case CameraEventCode::Error:
printf("\033[93mCamera Error ... ...\033[0m\n");
break;
}
}
);
UserSetManager Class
GetAllUserSets()
Obtains all UserSets of the camera.
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
for (auto usersets : usersetall) {
std::cout << usersets.sid << " " << usersets.name << std::endl;
}
Where,
sid: Unique identifier, cannot be changed, content is Default0-7, UserSet0-7.
name: The name of the UserSet
SaveToUserSet()
Saves the UserSet. This interface has two usage methods.
First method: Save using the UserSet name
vector<UserSet> usersetall; UserSetManager& usersetmanager = camera.GetUserSetManager(); CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall); ret = usersetmanager.SaveToUserSet("123"); if (ret.IsSuccess()) { printf("\033[92mSaveToUserSet success\033[0m\n"); }
Second method: Save using the UserSet object
vector<UserSet> usersetall; UserSetManager& usersetmanager = camera.GetUserSetManager(); CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall); if (ret.IsSuccess()) { for (auto usersets : usersetall) { std::cout << usersets.name << " " << usersets.sid << std::endl; if (usersets.name == "789") { ret = usersetmanager.SaveToUserSet(usersets); if(ret.IsSuccess()){ printf("\033[92mSaveToUserSet %s(sid: %s) success\033[0m\n", usersets.name.c_str(), usersets.sid.c_str()); } } } }
SaveToUserSetWithNewName()
Renames the UserSet and perform the save action. The first parameter is the old name, the second parameter is the new name.
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
ret = usersetmanager.SaveToUserSetWithNewName("123","Peace");
if (ret.IsSuccess()) {
printf("\033[92mSaveToUserSetWithNewName success\033[0m\n");
}
else {
printf("\033[91mSaveToUserSetWithNewName failed : %s\033[0m\n", ret.message().c_str());
}
LoadUserSet()
Loads the desired UserSet. Passes the name of the UserSet to load when calling, as shown in the code:
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
ret = usersetmanager.LoadUserSet("standard_ObstacleAvoidance");
if (ret.IsSuccess()) {
printf("\033[92mLoadUserSet success\033[0m\n");
}
else {
printf("\033[91mLoadUserSet failed : %s\033[0m\n", ret.message().c_str());
}
CurrentUserSet()
Reads the name of the currently used UserSet.
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
std::string CurrentUserSetName;
ret = usersetmanager.CurrentUserSet(CurrentUserSetName);
if (ret.IsSuccess()) {
printf("\033[95mCurrentUserSet : %s\033[0m\n", CurrentUserSetName.c_str());
}
GetPowerOnUserSet()
Reads the name of the default UserSet when the camera powers on.
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
std::string PowerOnUserSetName;
ret = usersetmanager.GetPowerOnUserSet(PowerOnUserSetName);
if (ret.IsSuccess()) {
printf("\033[95mPowerOnUserSet : %s\033[0m\n", PowerOnUserSetName.c_str());
}
SetPowerOnUserSet()
Sets the UserSet for when the camera powers on. Pass the name of the UserSet when calling.
vector<UserSet> usersetall;
UserSetManager& usersetmanager = camera.GetUserSetManager();
CameraApiStatus ret = usersetmanager.GetAllUserSets(usersetall);
ret = usersetmanager.SetPowerOnUserSet("HelloWorld");
if (ret.IsSuccess()) {
printf("\033[92mSetPowerOnUserSet success\033[0m\n");
}
else {
printf("\033[91mSetPowerOnUserSet failed : %s\033[0m\n",ret.message().c_str());
}
ImageProc Class
DepthImageToPointCloud()
Converts the input depth image into point cloud data.
CameraApiStatus status;
PointCloud point_cloud = ImageProc::DepthImageToPointCloud(image, &status);
// Among them, invalid points are represented by "nan".
std::vector<PointXYZ> points = pcOut.GetPoints();
For detailed usage instructions, refer to the sample program VcameraSDK-X.X.X/cpp/example/DepthImageToPointCloud.cpp.
PointCloudToDepthImage()
Convert a point cloud to a depth image.
Parameters: point cloud, depth intrinsic parameters, target width, target height, and depth scale factor (optional, default is 1).
Returns: a depth image.
TransformPointCloud()
Transform a point cloud to another coordinate system.
Parameters: point cloud, extrinsic matrix, and whether to use inverse transformation (optional, default is false).
Returns: the transformed point cloud object.
MapTextureImageToDepth()
Align a texture image to a depth image.
Parameters: texture image (distortion allowed) and target depth image (used to obtain size and calibration parameters).
Returns: an aligned texture image with the same size as the depth image.
MapGrayImageToDepth()
Align a grayscale image to a depth image.
Parameters: grayscale image (GRAY8 or GRAY16, distortion allowed) and target depth image (used to obtain size and calibration parameters).
Returns: an aligned grayscale image with the same size as the depth image.
MapDepthImageToTexture()
Align a depth image to a texture image.
Parameters: depth image (DEPTH16, distortion allowed) and texture image (used to obtain size and calibration parameters).
Returns: an aligned depth image with the same size as the texture image.
UndistortImage()
Undistort an image.
Parameters: image (GRAY8 / GRAY16 / RGB24 / DEPTH16) and new intrinsic parameters (optional, same as the input by default).
Returns: the undistorted image.
CameraApiStatusCode
Success,
Failure,
ArrayInfoInvalid,
ArrayInvalid,
CalibrationInfoInvalid,
CameraInvalid,
ComponentInvalid,
DeviceInvalid,
DeviceError,
DeviceIdle,
DeviceBusy,
DeviceLost,
DeviceInterfaceInvalid,
DeviceInterfaceTypeError,
DeviceInfoInvalid,
FeatureInvalid,
FeatureInfoInvalid,
FeatureTypeError,
FrameInvalid,
FrameMetadataInvalid,
FrameBufferInvalid,
FrameBufferConsumerInvalid,
FrameSetInvalid,
FrameSetStreamInvalid,
FrameSetConsumerInvalid,
TriggerModeError,
NotExist,
NotImplemented,
NotPermitted,
NotSupported,
OutOfMemory,
OutOfIndexRange,
OutOfValueRange,
ParameterInvalid,
StructureInfoInvalid,
StructureInvalid,
Timeout,
ValueInvalid,
ValueTypeError,
ValueInfoInvalid,
NullCameraHandle,
UserSetIsFull,
Set/Read Camera Features
IsValid()
Check whether the camera supports the specified feature.
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthRangeMax", feature);
bool isValid = ret.IsSuccess();
if (isValid) {
printf("\033[92m Feature is valid \033[0m\n");
}
else {
printf("\033[91m Error: %s (code: %d)\033[0m\n", ret.message().c_str(), (int)ret.code());
}
GetName()
Gets the name of the feature.
Feature feature;
CameraApiStatus ret = camera.GetFeature("LightController0/LightBrightness", feature);
if (ret.IsSuccess()) {
cout << feature.GetName() << endl;
} else {
printf("\033[91mGetFeature failed: %s\033[0m\n", ret.message().c_str());
}
GetAccessMode()
Gets the access permissions of the feature.
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthRangeMax", feature);
AccessMode access_mode;
ret = feature.GetAccessMode(access_mode);
if (ret.IsSuccess()) {
printf("\033[92mDepthRangeMax AccessMode :%d\033[0m\n", access_mode);
}
In VCameraSDK, feature access permissions are classified into the following four types:
0: The camera does not support this feature, or the feature is not supported in the current state (for example, exposure time is not supported when AEC is enabled).
1: The feature is read-only on this camera.
2: The feature is write-only on this camera.
3: The feature is readable and writable on this camera.
GetType()
Gets the type of the feature.
Feature feature;
camera.GetFeature("Depth/PixelFormat", feature);
FeatureType type = feature.GetType();
printf("\033[91mFeatureType is %d\033[0m\n", static_cast<int>(type));
In VCameraSDK, feature types are classified into the following eight categories:
enum class CAMERA_API_EXPORT FeatureType : int32_t {
Undefined,
Bool,
Int64,
Float64,
Enumeration,
String,
ByteArray,
Dictionary,
};
Int64 Type
Read the Feature Value
Feature feature;
Value value;
CameraApiStatus ret = camera.GetFeature("DeviceStreamChannelSelector", feature);
ret = feature.GetValue(value);
if (ret.IsSuccess()) {
printf("\033[92mGetValue success : %lld\033[0m\n", (int64_t)value);
}
Check the Feature Type
Feature feature;
Value value;
CameraApiStatus ret = camera.GetFeature("DeviceStreamChannelSelector", feature);
feature.GetValue(value);
if (value.IsInt64()) {
printf("\033[92mValueType is true\033[0m\n");
}
else {
printf("\033[91mValueType is wrong. ValueType:%d\033[0m\n", value.GetType());
}
Read the Feature Range
Feature feature;
CameraApiStatus ret = camera.GetFeature("LightController0/LightBrightness", feature);
Int64Range range;
ret = feature.GetRange(range);
if (ret.IsSuccess()) {
printf("\033[92mGetRange success : [%lld ,%lld], step : %lld\033[0m\n", range.minValue, range.maxValue, range.step);
}
Set the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("LightController0/LightBrightness", feature);
ret = feature.SetValue(10);
if (ret.IsSuccess()) {
printf("\033[92mSetValue success\033[0m\n");
}
else {
printf("\033[91mSetValue call failed : %s\033[0m\n", ret.message().c_str());
}
Complete Example
Feature feature;
AccessMode access_mode;
Int64Range range;
Value value;
CameraApiStatus ret = camera.GetFeature("LightController0/LightBrightness", feature);
ret = feature.GetAccessMode(access_mode);
printf("\033[95mAccessMode:%d\033[0m\n", static_cast<int>(access_mode));
ret = feature.GetValue(value);
printf("\033[95mValueType:%d\033[0m\n",value.GetType());
ret = feature.GetRange(range);
printf("\033[95mCurrentValue : %lld , Range : [%lld ,%lld] , Step : %lld\033[0m\n", (int64_t)value, range.minValue, range.maxValue, range.step);
ret = feature.SetValue(Value(80);
Bool Type
Read the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("Texture/ExposureAuto", feature);
Value value;
ret = feature.GetValue(value);
if (ret.IsSuccess()) {
printf("\033[92mGetValue success : %s\033[0m\n", value?"true":"false");
}
Check the Feature Type
Feature feature;
CameraApiStatus ret = camera.GetFeature("Texture/ExposureAuto", feature);
Value value;
feature.GetValue(value);
if (value.IsBool()) {
printf("\033[92mValueType is Bool\033[0m\n");
}
else {
printf("\033[91mValueType is not Bool\033[0m\n");
}
Set the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("Texture/ExposureAuto", feature);
Value value;
ret = feature.SetValue(false);
if (ret.IsSuccess()) {
printf("\033[92mSetValue success\033[0m\n");
}
else {
printf("\033[91mSetValue call failed : %s\033[0m\n", ret.message().c_str());
}
Complete Example
Feature feature;
AccessMode access_mode;
Value value;
CameraApiStatus ret = camera.GetFeature("Texture/ExposureAuto", feature);
ret = feature.GetAccessMode(access_mode);
printf("\033[95mTexture/ExposureAuto AccessMode:%d\033[0m\n", access_mode);
ret = feature.GetValue(value);
printf("\033[95mValueType:%d\033[0m\n", value.GetType());
printf("\033[95mCurrentValue : %s\033[0m\n", value?"true":"false");
ret = feature.SetValue(true);
Float64 Type
Read the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthScaleUnit", feature);
Value value;
ret = feature.GetValue(value);
if (ret.IsSuccess()) {
printf("\033[92mGetValue success : %f\033[0m\n", (double)value);
}
Check the Feature Type
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthScaleUnit", feature);
Value value;
feature.GetValue(value);
if (value.IsDouble()) {
printf("\033[92mValueType is float\033[0m\n");
}
else {
printf("\033[91mValueType is not float\033[0m\n");
}
Read the Feature Range
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthScaleUnit", feature);
Float64Range range;
ret = feature.GetRange(range);
if (ret.IsSuccess()) {
printf("\033[92mGetRange success : [%f , %f]\033[0m\n", range.minValue, range.maxValue);
}
Set the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("DepthScaleUnit", feature);
Value value;
ret = feature.SetValue(Value(0.25);
if (ret.IsSuccess()) {
printf("\033[92mSetValue success\033[0m\n");
}
else {
printf("\033[91mSetValue call failed : %s\033[0m\n", ret.message().c_str());
}
Complete Example
Feature feature;
AccessMode access_mode;
Float64Range range;
Value value;
CameraApiStatus ret = camera.GetFeature("DepthScaleUnit", feature);
ret = feature.GetAccessMode(access_mode);
printf("\033[95mDepthScaleUnit AccessMode:%d\033[0m\n", access_mode);
ret = feature.GetValue(value);
printf("\033[95mValueType:%d\033[0m\n", value.GetType());
ret = feature.GetRange(range);
printf("\033[95mCurrentValue : %f , Range : [%f ,%f] , Step : %f\033[0m\n", (double)value, range.minValue, range.maxValue, range.step);
ret = feature.SetValue(0.25);
Enumeration Type
Read the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("Texture/BinningHorizontal", feature);
Value value;
ret = feature.GetValue(value);
if (ret.IsSuccess()) {
printf("\033[92mGetValue success : %d\033[0m\n", (int64_t)value);
}
Check the Feature Type
Feature feature;
CameraApiStatus ret = camera.GetFeature("DeviceTimeSyncMode", feature);
Value value;
feature.GetValue(value);
if (value.IsInt64()) {
printf("\033[92mValueType is Enum\033[0m\n");
}
else {
printf("\033[91mValueType is not Enum\033[0m\n");
}
Read the Enumeration List
Feature feature;
CameraApiStatus ret = camera.GetFeature("DeviceTimeSyncMode", feature);
std::vector<EnumItem> enum_list;
ret = feature.GetEnumItems(enum_list);
if (ret.IsSuccess()) {
printf("\033[92mGetEnumItems success\033[0m\n");
for (auto& list : enum_list) {
printf("Name : %s ,Value :%d\n", list.name.c_str(), list.value);
}
}
Set the Feature Value
Feature feature;
CameraApiStatus ret = camera.GetFeature("DeviceTimeSyncMode", feature);
std::vector<EnumItem> enum_list;
feature.GetEnumItems(enum_list);
ret = feature.SetValue(enum_list[1].value);
if (ret.IsSuccess()) {
printf("\033[92mSetValue success\033[0m\n");
}
else {
printf("\033[91mSetValue Call failed :%s\033[0m\n", ret.message().c_str());
}
Complete Example
Feature feature;
AccessMode access_mode;
Value value;
CameraApiStatus ret = camera.GetFeature("DeviceTimeSyncMode", feature);
ret = feature.GetAccessMode(access_mode);
printf("\033[95mDeviceTimeSyncMode AccessMode:%d\033[0m\n", access_mode);
ret = feature.GetValue(value);
printf("\033[95mValueType:%d\033[0m\n", value.GetType());
printf("\033[95mCurretnValue : %d\033[0m\n", (int64_t)value);
std::vector<EnumItem> enum_list;
ret = feature.GetEnumItems(enum_list);
if (ret.IsSuccess()) {
printf("\033[92mGetEnumItems success\033[0m\n");
for (auto& list : enum_list) {
printf("Name : %s ,Value :%d\n", list.name.c_str(), list.value);
//Set
ret = feature.SetValue(list.value);
if (ret.IsSuccess()) {
printf("\033[92mSetValue success\033[0m\n");
}
else {
printf("\033[91mSetValue Call failed :%s\033[0m\n", ret.message().c_str());
}
}
}