API Descriptions (C#)

GetVersionString()

Gets VCameraSDK Version.

string versionString = UCV.CameraApi.Interop.Version.GetVersionString();
Console.WriteLine($"GetVersionString: {versionString}");

CameraUtils Class

CameraUtils is a static utility class provided by the SDK, dedicated to camera device discovery and network configuration.

Init()

Initializes the camera system environment.

CameraUtils.Init(true);

Note: The function mush be called before other operations.

DiscoverCameras()

Scans and discovers all available cameras.

CameraUtils.DiscoverCameras();

SetIpAddress()

Sets the camera’s IP to static. Needs to input the camera’s MAC address and the desired IP, netmask, and gateway.

string mac = "06:2E:68:E5:81:8C";
string ip = "192.168.6.37";
string mask = "255.255.255.0";
string gateway = "192.168.6.1";

CameraApiStatus status = CameraUtils.SetIpAddress(mac, ip, mask, gateway);
if (status == CameraApiStatus.Success)
{
    Console.WriteLine($"Successfully set the IP of the camera {mac} to {ip}");
}

SetDeviceDhcp()

Sets the camera’s IP to Dynamic. Needs to input the camera’s MAC address.

CameraUtils.SetDeviceDhcp("06:22:7F:05:9B:16");

CameraCapture Class

CameraCapture is a factory class defined by the Percipio SDK, specialized in instantiating and connecting camera devices with different configurations. It provides three static factory methods to create camera instances via serial number, IP address, or pre-configured information.

GetCameraBySerialNumber()

Obtains a camera object by its serial number.

CameraCapture.GetCameraBySerialNumber("207000159205");

GetCameraByIpAddress()

Obtains a camera object by its IP address.

CameraCapture.GetCameraByIpAddress("192.168.6.50");

GetCameraByDeviceInfo()

Obtains a camera object by the camera’s information.

// Camera initialization
CameraUtils.InitChannel();
// Discover all available cameras
CameraCapture camera = null;
var deviceList = CameraUtils.DiscoverCameras();
foreach (var list in deviceList)
{
     // Output camera info
     Console.WriteLine($"Serial Number: {list.Sn}, Model Name: {list.ModelName}, IP: {list.NetworkInfo.Ip}");
     if (list.Sn == "207000163420")
     {
         cc = CameraCapture.GetCameraByDeviceInfo(list);
         Console.WriteLine($"Target Camera Found: {list.ModelName}");
         break;
     }
 }

Camera Class

Provides core device control and image acquisition interface.

GetCameraInfo()

Obtains camera device information.

// Camera initialization
CameraUtils.InitChannel();
// Discover camera
var deviceList = CameraUtils.DiscoverCameras();
if (deviceList.Count == 0)
{
    Console.WriteLine("No camera found!");
    return;
}
// Connect camera and get camera info
foreach (var camInfo in deviceList)
{
    // Create camera instance
    CameraCapture cc = CameraCapture.GetCameraByDeviceInfo(camInfo);

    // Connect camera
    CameraApiStatus connectStatus = cc.Connect();
    if (connectStatus != CameraApiStatus.Success)
    {
        Console.WriteLine($"Connect camera {camInfo.Sn} failed: {connectStatus}");
        continue;
    }
    // Get camera information via GetCameraInfo()
    CameraInfo detailedInfo;
    CameraApiStatus infoStatus = cc.GetCameraInfo(out detailedInfo);
    if (infoStatus == CameraApiStatus.Success)
    {
        Console.WriteLine("\n====== Camera Detailed Information ======");
        Console.WriteLine($"   Model Name: {detailedInfo.ModelName}");
        Console.WriteLine($"   Serial Number: {detailedInfo.Sn}");
        Console.WriteLine($"   IP Address: {detailedInfo.NetworkInfo.Ip}");
        Console.WriteLine($"   Name: {detailedInfo.Name}");
        Console.WriteLine($"  Vendor Name: {detailedInfo.VendorName}");
        Console.WriteLine($"   Firmware Version: {detailedInfo.FirmwareVersion}");
        Console.WriteLine($"   State: {detailedInfo.State}");
        // Network Info
        Console.WriteLine($"   MAC Address: {detailedInfo.NetworkInfo.Mac}");
        Console.WriteLine($"   Subnet Mask: {detailedInfo.NetworkInfo.Netmask}");
        Console.WriteLine($"   Gateway: {detailedInfo.NetworkInfo.Gateway}");
        // Interface Info
        Console.WriteLine($"   Interface Type: {detailedInfo.InterfaceInfo.InterfaceType}");
        Console.WriteLine($"   Interface Name: {detailedInfo.InterfaceInfo.Name}");
    }
    else
    {
        Console.WriteLine($"Get Camera {camInfo.Sn} Detailed Information Failed: {infoStatus}");
    }
    // Disconnect camera
    cc.Disconnect();
}

Connect()

Connects the camera.

cc.Connect();

Disconnect()

Disconnects the camera.

cc.Disconnect();

Retrieve Camera State

Retrieves the camera state.

var status = cc.Connect();
if (status != CameraApiStatus.Success)
{
    Console.WriteLine($"Failed to connect camera: {status}");
    return;
}

StartCapture()

Starts image capture.

cc.StartCapture();

StopCapture()

Stops image capture.

cc.StopCapture();

GetFeature()

Retrieves 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.

CameraFeature feature;
CameraApiStatus status = cc.GetFeature("Left/ExposureTime", out feature);
Console.WriteLine($"GetFeature Left/ExposureTime Status: {status}");

GetAllFeatures()

Retrieves all features.

cc.GetAllFeatures();

FireSoftwareTrigger()

Sends a software trigger signal to a camera operating in software trigger mode.

cc.FireSoftwareTrigger();

GetImageModes()

Retrieves the image formats and resolutions that can be set for a specified sensor.

List<ImageMode> image_modes = cc.GetImageModes(SensorType.IrRight, out status);
if (status != CameraApiStatus.Success)
{
    Console.WriteLine($"GetImageModes failed : {status}");
}
else
{
    foreach (var mode in image_modes)
    {
        Console.WriteLine($"ImageModePixelFormat : {mode.RawPixelFormat} , ImageModeWidth : {mode.Width} , ImageModeHeight : {mode.Height}");
      }
}

GetCurrentImageMode()

Retrieves the current image format and resolution of a specified sensor.

var currentMode = cc.GetCurrentImageMode(SensorType.IrLeft, out status);
Console.WriteLine($"ImageModePixelFormat : {currentMode.RawPixelFormat} , ImageModeWidth : {currentMode.Width} , ImageModeHeight : {currentMode.Height}");

SetImageMode()

Sets the image format and resolution for a specified sensor.

ImageMode image_mode = new ImageMode();
image_mode.RawPixelFormat = RawPixelFormat.JPEG;
image_mode.Width = 640;
image_mode.Height = 480;
status = cc.SetImageMode(SensorType.Rgb, image_mode);
Console.WriteLine($"Set image format and resolution: {status}");

HasSensor()

Checks if the camera has a specified sensor.

// Read sensors supported by the camera
var sensorTypes = Enum.GetValues(typeof(SensorType)).Cast<SensorType>();
foreach (var sensorType in sensorTypes)
{
    if (cc.HasSensor(sensorType))
    {
        Console.WriteLine($"Supported sensor: {sensorType}");
    }
}

The camera supports the following sensor types:

  • DEPTH = “Depth”

  • LEFT = “Left”

  • RIGHT = “Right”

  • COLOR = “Color”

IsSensorEnabled()

Checks if a specified sensor of the camera is enabled.

// Read the enabled status of sensors supported by the camera
var sensorTypes = Enum.GetValues(typeof(SensorType)).Cast<SensorType>();
foreach (var sensorType in sensorTypes)
{
    if (cc.HasSensor(sensorType))
    {
        bool enabled;
        status = cc.IsSensorEnabled(sensorType, out enabled);
        if (status == CameraApiStatus.Success)
        {
            Console.WriteLine($"Sensor {sensorType}: {(enabled ? "Enabled" : "Disabled")}");
        }
    }
}

SetSensorEnabled()

Enables or disables image output for a specified sensor.

CameraApiStatus status = cc.SetSensorEnabled(SensorType.Depth, true);
if (status != CameraApiStatus.Success)
{
    Console.WriteLine($"Failed to set sensor enabled: {status}");
    return;
}

SetUndistortionEnabled()

Enables or disables distortion correction for images from a specified sensor.

cc.SetUndistortionEnabled(SensorType.Rgb, true);

IsMapDepthToColorEnabled()

Used to query whether depth-to-color image mapping (depth and color alignment) is enabled.

bool isEnabled;
CameraApiStatus status = cc.IsMapDepthToColorEnabled(out isEnabled);

if (status == CameraApiStatus.Success)
{
    Console.WriteLine($"Depth-to-color mapping: {(isEnabled ? "Enabled" : "Disabled")}");
}
else
{
    Console.WriteLine($"Failed to check depth-to-color mapping status: {status}");
}

SetMapDepthToColorEnabled()

Enables or disables depth-to-color image mapping (alignment between depth and color images).

status = cc.SetMapDepthToColorEnabled(true);
if (status != CameraApiStatus.Success)
{
    Console.WriteLine($"Failed to enable MapDepthToColor: {status}");
    return;
}

RegisterFrameSetCallback()

Registers an image callback function.

RegisterCameraEventCallback()

Registers a camera event callback function.

RegisterFeaturesChangedCallback()

Registers a feature change callback function.

UserSetManager Class

GetAllUserSets()

Retrieves all UserSets of the camera.

var userSetMgr = cc.GetUserSetManager();
var userSets = new List<UserSet>();
status = userSetMgr.GetAllUserSets(userSets);
Console.WriteLine("Available Usersets:");
for (int i = 0; i < userSets.Count; i++)
{
    Console.WriteLine($"  [{i}] {userSets[i].Name}");
}

SaveToUserSet()

Saves the current camera’s parameter settings to the specified Userset.

var userSetMgr = cc.GetUserSetManager();
status = userSetMgr.SaveToUserSet("Default");
if (status == CameraApiStatus.Success)
{
    Console.WriteLine("Parameter settings saved to Userset named Default");
}
else
{
    Console.WriteLine($"Save failed: {status}");
}

SaveToUserSetWithNewName()

Renames an existing Userset.

var userSetMgr = cc.GetUserSetManager();
status = userSetMgr.SaveToUserSetWithNewName("MyCustomConfig", "9876");
if (status == CameraApiStatus.Success)
{
    Console.WriteLine("Parameter settings saved as 9876");
}

LoadUserSet()

Loads the desired Userset.

// Get the Userset manager
var userSetMgr = cc.GetUserSetManager();
CameraApiStatus status = userSetMgr.LoadUserSet("HighAccuracy");
if (status == CameraApiStatus.Success)
{
    Console.WriteLine("High accuracy mode Userset loaded");
}
else
{
    Console.WriteLine($"Failed to load Userset set: {status}");
}

CurrentUserSet()

Reads the name of the currently used Userset.

// Get the Userset manager
var userSetMgr = cc.GetUserSetManager();
// Get the current Userset
string currentUserSet;
status = userSetMgr.CurrentUserSet(out currentUserSet);
if (status == CameraApiStatus.Success)
{
    if (string.IsNullOrWhiteSpace(currentUserSet))
    {
        Console.WriteLine("No Userset is currently set");
    }
    else
    {
        Console.WriteLine($"Current Userset: {currentUserSet}");
    }
}
else
{
    Console.WriteLine($"Failed to get current Userset: {status}");
}

GetPowerOnUserSet()

Reads the name of the default Userset when the camera powers on.

var userSetMgr = cc.GetUserSetManager();
// Get the current Userset at boot
string powerOnUserSet;
status = userSetMgr.GetPowerOnUserSet(out powerOnUserSet);
if (status == CameraApiStatus.Success)
{
    if (string.IsNullOrEmpty(powerOnUserSet))
    {
        Console.WriteLine("No Userset at boot is currently set");
    }
    else
    {
        Console.WriteLine($"Current Userset at boot: {powerOnUserSet}");
    }
}
else
{
    Console.WriteLine($"Failed to get Userset at boot: {status}");
}

SetPowerOnUserSet()

Sets the Userset when the camera powers on.

string optimizedConfig = "HighAccuracy";
status = userSetMgr.SetPowerOnUserSet(optimizedConfig);
if (status == CameraApiStatus.Success)
{
    Console.WriteLine($"Device configured to automatically load '{optimizedConfig}' mode on startup");
}

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,

Camera Feature Class

Basic Information Methods

IsValid()

Determines whether the camera supports this feature.

CameraFeature feature;
CameraApiStatus ret = cc.GetFeature("DepthScaleUnit", out feature);

bool isValid = feature.IsValid();
if (isValid)
{
    Console.WriteLine("\u001b[92m Feature is valid and available\u001b[0m");
}

FullName

Retrieves the full path name of the feature, typically including grouping information.

CameraFeature feature;
cc.GetFeature("DepthSgbmUniqueMaxCost", out feature);
string fullName = feature.FullName;
Console.WriteLine($"Full name: {fullName}");

Get Feature Type

Retrieves the feature type.

CameraFeature feature;
string featureName = "AcquisitionMode";
cc.GetFeature(featureName, out feature);
FeatureType type = feature.FeatureType;
Console.WriteLine($"{featureName} FeatureType is {type}");

VCameraSDK supports the following eight feature types:

  • Undefined

  • Bool

  • Int64

  • Float64

  • Enumeration

  • String

  • ByteArray

  • Dictionary

GetAccessMode()

Retrieves the camera feature permission.

CameraFeature feature;
CameraApiStatus ret = cc.GetFeature("Depth/ExposureTime", out feature);
CameraFeatureAccessMode access_mode;
ret = feature.GetAccessMode(out access_mode);
if (ret == CameraApiStatus.Success)
{
        Console.WriteLine($"Depth/ExposureTime AccessMode : {access_mode}");
}

VCameraSDK supports the following four access modes:

  • NotAvailable

  • Readable

  • Writable

  • ReadWritable

Value Operation Methods

GetValue()

Retrieves the current value of a feature.

  1. Integer feature

    CameraFeature feat;
    cc.GetFeature("DepthSgbmTextureFilterValueOffset", out feat);
    CameraValue currentValue;
    feat.GetValue(out currentValue);
    Console.WriteLine($"Left/ExposureTime current value: {currentValue.SingleValue}");
    
  2. Float feature

    CameraFeature feat;
    cc.GetFeature("Left/ExposureTime", out feat);
    CameraValue currentValue;
    feat.GetValue(out currentValue);
    Console.WriteLine($"Left/ExposureTime current value: {currentValue.SingleValue}");
    
  3. Enumeration feature

    CameraFeature feature;
    cc.GetFeature("DeviceLinkHeartbeatMode", out feature);
    CameraValue currentValue;
    feature.GetValue(out currentValue);
    Console.WriteLine($"DeviceLinkHeartbeatMode current value: {currentValue.SingleValue}");
    
  4. Boolean feature

    CameraFeature feat;
    cc.GetFeature("Texture/BalanceWhiteAuto", out feat);
    feat.SetValue(new CameraValue(CameraValueType.Int64, 31));
    CameraValue currentValue;
    feat.GetValue(out currentValue);
    Console.WriteLine($"Texture/BalanceWhiteAuto current value: {currentValue.SingleValue}");
    

SetValue()

Sets the value of a feature.

  1. Integer feature

    CameraFeature feat;
    status = cc.GetFeature("DepthSgbmTextureFilterValueOffset", out feat);
    feat.SetValue(new CameraValue(CameraValueType.Int64, 31));
    
  2. Float feature

    CameraFeature feat;
    cc.GetFeature("Left/ExposureTime", out feat);
    feat.SetValue(new CameraValue(CameraValueType.Double, 31));
    
  3. Enumeration feature

    CameraFeature feat;
    cc.GetFeature("DeviceLinkHeartbeatMode", out feat);
    feat.SetValue(new CameraValue(CameraValueType.String, "On"));
    
  4. Boolean feature

    CameraFeature feat;
    cc.GetFeature("Texture/BalanceWhiteAuto", out feat);
    feat.SetValue(new CameraValue(CameraValueType.Bool, false));
    Console.WriteLine($"Set status: {status}");
    

Range Query Methods

Get Range For Int Feature

Retrieves the value range of an integer feature.

CameraFeature feat;
status = cc.GetFeature("DepthSgbmTextureFilterValueOffset", out feat);
Int64Range range;
CameraApiStatus ret = feat.GetRange(out range);
if (ret == CameraApiStatus.Success)
{
    Console.WriteLine($"GetRange success: [{range.Min}, {range.Max}], Step: {range.Step}");
}

Applicable to: Integer features

Get Range For Float Feature

Retrieves the value range of a floating-point feature.

CameraFeature feat;
status = cc.GetFeature("Left/ExposureTime", out feat);
Float64Range range;
CameraApiStatus ret = feat.GetRange(out range);
if (ret == CameraApiStatus.Success)
{
    Console.WriteLine($"GetRange success: [{range.Min}, {range.Max}], Step: {range.Step}");
}

Applicable to: Float features

Enumeration Item Methods

GetEnumItems()

Retrieves all enumeration items of an enumeration feature.

CameraFeature feature;
cc.GetFeature("DeviceLinkHeartbeatMode", out feature);
List<EnumItem> enumItems = new List<EnumItem>();
status = feature.GetEnumItems(enumItems);
if (status == CameraApiStatus.Success)
{
    foreach (var item in enumItems)
    {
        Console.WriteLine($"Name: {item.Name}, Value: {item.Value}");
    }
}
else
{
    Console.WriteLine($"GetEnumItems failed: {status}");
}

Applicable to: Enumeration features