属性设置说明 (Gige_2_1 相机)

重要

目前支持的属性及其定义,请参见 camport4/include/TYFeatureList.h 头文件。

Device Control 相关属性说明

该模块提供设备(相机)及其传感器的一般信息与控制,主要用于在枚举过程中识别设备并获取传感器分辨率相关信息。此类别还包含与设备整体状态相关的其他信息及控制项。

DeviceFirmwareVersion读取相机固件版本

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceFirmwareVersion", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceFirmwareVersion", &hash[0], len);
std::cout << "DeviceFirmwareVersion: " << hash << std::endl;

DeviceHardwareVersion读取相机硬件版本

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceHardwareVersion", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceHardwareVersion", &hash[0], len);
std::cout << "DeviceHardwareVersion: " << hash << std::endl;

DeviceVersion读取相机版本

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceVersion", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceVersion", &hash[0], len);
std::cout << "DeviceVersion: " << hash << std::endl;

DeviceBuildHash读取相机固件所有信息

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceBuildHash", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceBuildHash", &hash[0], len);
std::cout << "DeviceVersion: " << hash << std::endl;

DeviceConfigVersion读取相机配置版本

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceConfigVersion", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceConfigVersion", &hash[0], len);
std::cout << " DeviceConfigVersion: " << hash << std::endl;

DeviceTechModel读取相机技术型号

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceTechModel", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceTechModel", &hash[0], len);
std::cout << "DeviceTechModel: " << hash << std::endl;

DeviceSerialNumber读取相机序列号

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceSerialNumber", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceSerialNumber", &hash[0], len);
std::cout << "DeviceSerialNumber: " << hash << std::endl;

DeviceVendorName读取相机制造商名

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceVendorName", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceVendorName", &hash[0], len);
std::cout << "DeviceVendorName: " << hash << std::endl;

DeviceManufacturerInfo读取相机制造商信息

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceManufacturerInfo", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceManufacturerInfo", &hash[0], len);
std::cout << "DeviceManufacturerInfo: " << hash << std::endl;

DeviceModelName读取相机型号名

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceModelName", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceModelName", &hash[0], len);
std::cout << "DeviceModelName: " << hash << std::endl;

DeviceGeneratedTime读取相机生产时间

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceGeneratedTime", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceGeneratedTime", &hash[0], len);
std::cout << "DeviceGeneratedTime: " << hash << std::endl;

DeviceCalibrationTime读取相机标定时间

uint32_t len = 0;
TYStringGetLength(hDevice, "DeviceCalibrationTime", &len);
std::string hash(len, '\0');
TYStringGetValue(hDevice, "DeviceCalibrationTime", &hash[0], len);
std::cout << "DeviceCalibrationTime: " << hash << std::endl;

DeviceLinkSpeed读取相机网络连接速度

int64_t speed = 0;
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceLinkSpeed", &speed));
std::cout << "DeviceLinkSpeed: " << speed << std::endl;

DeviceTimeSyncMode相机对时功能

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "DeviceTimeSyncMode", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "DeviceTimeSyncMode", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

//设置相机的对时模式并判断是否对时成功

ASSERT_OK(TYEnumSetString(hDevice, "DeviceTimeSyncMode", "SyncTypeHost"));
bool sync_ready = false;
ASSERT_OK(TYBooleanGetValue(hDevice, "TimeSyncAck", &sync_ready));
while (!sync_ready) {
    ASSERT_OK(TYBooleanGetValue(hDevice, "TimeSyncAck", &sync_ready));
    MSLEEP(10);
}

NTPServerIP NTP对时服务器设置

设置 NTP 服务器 IP 后,相机对时模式为 SyncTypeNTP 时,将与指定的服务器进行对时。

ASSERT_OK(TYIntegerSetValue(hDevice, "NTPServerIP", 3232236033));//192.168.2.1

DeviceTemperatureSelector读取相机内部温度

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "DeviceTemperatureSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "DeviceTemperatureSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

//查询指定组件的温度
ASSERT_OK(TYEnumSetString(hDevice, "DeviceTemperatureSelector", "Color"));
double temperature = -1;
ASSERT_OK(TYFloatGetValue(hDevice, "DeviceTemperature", &temperature));
std::cout << "DeviceTemperature:" << temperature << std::endl;

DeviceLinkHeartbeatMode相机心跳功能

DeviceLinkHeartbeatMode

深度相机状态保持。SDK 与相机维持通信状态保持机制。默认为 On。

TYEnumSetString( hDevice, "DeviceLinkHeartbeatMode", "On");

DeviceLinkHeartbeatTimeout

深度相机状态保持时间设置。在该时间内未收到状态保持数据包,则判定系统与设备的连接出现异常。单位:ms。

int64_t min_Timeout, max_Timeout, Timeout_step,value_default,value_after;
ASSERT_OK(TYIntegerGetMin(hDevice, "DeviceLinkHeartbeatTimeout", &min_Timeout));
ASSERT_OK(TYIntegerGetMax(hDevice, "DeviceLinkHeartbeatTimeout", &max_Timeout));
ASSERT_OK(TYIntegerGetStep(hDevice, "DeviceLinkHeartbeatTimeout", &Timeout_step));
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceLinkHeartbeatTimeout", &value_default));
ASSERT_OK(TYIntegerSetValue(hDevice, "DeviceLinkHeartbeatTimeout", max_Timeout));
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceLinkHeartbeatTimeout", &value_after));
LOGD("DeviceLinkHeartbeatTimeout range: [%lld, %lld], step: %lld,default_value=%lld,new_value=%lld", min_Timeout, max_Timeout, Timeout_step, value_default,value_after);

DeviceFrameRecvTimeOut设备帧接收超时时间

在相机配置完数据流以及分辨率后会自动估算一个时间,当上位机在此时间内没有收到相机的数据流,就会发生超时错误。 当设置值比估算值小时,取估算值。当设置值比估算大时,取设置值。

char scr[1024];
ASSERT_OK(TYParamGetToolTip(hDevice, "DeviceFrameRecvTimeOut", scr, sizeof(scr)));
std::cout << "ToolTip:" << scr << std::endl;
int64_t min, max, step, value;
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceFrameRecvTimeOut", &value));
ASSERT_OK(TYIntegerGetMin(hDevice, "DeviceFrameRecvTimeOut", &min));
ASSERT_OK(TYIntegerGetMax(hDevice, "DeviceFrameRecvTimeOut", &max));
ASSERT_OK(TYIntegerGetStep(hDevice, "DeviceFrameRecvTimeOut", &step));
printf("DeviceFrameRecvTimeOut : [%d,%d] - %d,step %d\n", min, max, value,step);
ASSERT_OK(TYIntegerSetValue(hDevice, "DeviceFrameRecvTimeOut", value));

DeviceReset重置设备寄存器

重置 UserSet 属性组参数的寄存器命令,恢复相机到上电时的状态。

ASSERT_OK(TYCommandExec(hDevice, "DeviceReset"));

DeviceDataCompressType设备数据压缩类型

选择相机的数据压缩类型。

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "DeviceDataCompressType", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, " DeviceDataCompressType", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}
ASSERT_OK(TYEnumSetValue(hDevice, "DeviceDataCompressType", _cnt_entry[0].value));

Acquisition Control 相关属性说明

该模块描述了与图像采集相关的所有功能,控制图像或数据的采集过程,如触发模式、帧率等。

AcquisitionMode获取相机支持的工作模式

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "AcquisitionMode", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "AcquisitionMode", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

TriggerSource获取相机支持的触发源

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "TriggerSource", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "TriggerSource", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

设置连续工作模式

ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "Continuous"));

设置软触发工作模式

ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "SingleFrame"));
//触发源是软触发
ASSERT_OK(TYEnumSetString(hDevice, "TriggerSource", "Software"));
//通过此命令控制相机采图
ASSERT_OK(TYCommandExec(hDevice, "TriggerSoftware"));

设置硬触发工作模式

ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "SingleFrame"));
//触发源是 Line0
ASSERT_OK(TYEnumSetString(hDevice, "TriggerSource", "Line0"));

TriggerDelay触发延迟时间

设置触发信号输入到开始曝光的延迟时间,单位:μs。最大延迟时间 1300000 μs。

double default,m_min, m_max, m_step;
ASSERT_OK(TYFloatGetValue(hDevice, "TriggerDelay", &default));
ASSERT_OK(TYFloatGetMin(hDevice, "TriggerDelay", &m_min));
ASSERT_OK(TYFloatGetMax(hDevice, "TriggerDelay", &m_max));
ASSERT_OK(TYFloatGetStep(hDevice, "TriggerDelay", &m_step));
LOGD("DTriggerDelay=%f,range=:%f - %f,step: %f", default, m_min, m_max, m_step);
ASSERT_OK(TYFloatSetValue(hDevice, "TriggerDelay", m_min));

AcquisitionFrameRate帧率输出控制

设置相机采集图像帧率。

ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "Continuous"));
ASSERT_OK(TYBooleanSetValue(hDevice, "AcquisitionFrameRateEnable", true));
ASSERT_OK(TYFloatSetValue(hDevice, "AcquisitionFrameRate", 2));

TriggerDurationUs触发输出电平保持时间

在相机输出触发信号后,设置高/低电平的脉冲宽度时长,单位:μs。

ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "Continuous"));
ASSERT_OK(TYBooleanSetValue(hDevice, "AcquisitionFrameRateEnable", true));
ASSERT_OK(TYFloatSetValue(hDevice, "AcquisitionFrameRate", 2));
ASSERT_OK(TYIntegerSetValue(hDevice, "TriggerDurationUs", 66000));

Transport Layer Control 相关属性说明

该模块提供传输层控制功能,主要包含数据包大小调整、丢包检测、流控制、带宽限制等功能。

DeviceStreamChannelPacketSize网络最大传输单元大小

网络深度相机数据传输时,分组发送到链路上最大传输单元的大小。

int64_t default_PacketSize,min_PacketSize, max_PacketSize, packet_step, value;
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceStreamChannelPacketSize", &default_PacketSize));
ASSERT_OK(TYIntegerGetMin(hDevice, "DeviceStreamChannelPacketSize", &min_PacketSize));
ASSERT_OK(TYIntegerGetMax(hDevice, "DeviceStreamChannelPacketSize", &max_PacketSize));
ASSERT_OK(TYIntegerGetStep(hDevice, "DeviceStreamChannelPacketSize", &packet_step));
//设置 PacketSize 
ASSERT_OK(TYIntegerSetValue(hDevice, "DeviceStreamChannelPacketSize", min_PacketSize));
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceStreamChannelPacketSize", &value));
LOGD("DeviceStreamChannelPacketSize default=%d range: [%lld, %lld], step: %lld,value=%lld", default_PacketSize, min_PacketSize, max_PacketSize, packet_step, value);

GevSCPD帧间延时

网络上两个物理数据包的发送间隔,用于降低网络数据发送拥塞程度。

int64_t min_PacketDelay, max_PacketDelay, packet_step,value_default,value_after;
ASSERT_OK(TYIntegerGetMin(hDevice, "GevSCPD", &min_PacketDelay));
ASSERT_OK(TYIntegerGetMax(hDevice, "GevSCPD", &max_PacketDelay));
ASSERT_OK(TYIntegerGetStep(hDevice, "GevSCPD", &packet_step));
ASSERT_OK(TYIntegerGetValue(hDevice, "GevSCPD", &value_default));
//设置 PacketDelay 
ASSERT_OK(TYIntegerSetValue(hDevice, "GevSCPD", max_PacketDelay));
ASSERT_OK(TYIntegerGetValue(hDevice, "GevSCPD", &value_after));
LOGD("PacketDelay  range: [%lld, %lld], step: %lld,default_value=%lld,new_value=%lld", min_PacketDelay, max_PacketDelay, packet_step, value_default,value_after);

读取当前 IP/Netmask/Gateway

读取相机当前 IP 地址、地址掩码、网关。

int64_t CurrentIP, CurrentMask, CurrentGateWay;
CurrentIP = CurrentMask = CurrentGateWay = -1;
ASSERT_OK(TYIntegerGetValue(hDevice, "GevCurrentIPAddress", &CurrentIP));
ASSERT_OK(TYIntegerGetValue(hDevice, "GevCurrentSubnetMask", &CurrentMask));
ASSERT_OK(TYIntegerGetValue(hDevice, "GevCurrentDefaultGateway", &CurrentGateWay));
printf("CurrentIP %llu  CurrentMask %llu CurrentGateWay %llu\n", CurrentIP, CurrentMask, CurrentGateWay);

设置相机 IP/Netmask/Gateway

设置相机静态IP地址。设置后需重启相机,方可生效。

ASSERT_OK(TYIntegerSetValue(hDevice, "GevPersistentIPAddress", 3232236220));//192.168.2.188
ASSERT_OK(TYIntegerSetValue(hDevice, "GevPersistentSubnetMask", 4294967040));//255.255.255.0
ASSERT_OK(TYIntegerSetValue(hDevice, "GevPersistentDefaultGateway", 3232236033));//192.168.2.1

GevMACAddress读取相机 MAC 地址

读取相机 MAC 地址。读出来的值需自行转换成 XX:XX:XX:XX:XX:XX 格式。

int64_t value;
ASSERT_OK(TYIntegerGetValue(hDevice, "GevMACAddress", &value));

CmosSync图像同步

设置图像是否同步输出。左右图像完全同步时,图像输出帧率低于不完全同步时图像输出帧率。

bool CmosSync,CmosSync_after;
ASSERT_OK(TYBooleanGetValue(hDevice, "CmosSync", &CmosSync));
LOGD("CmosSync=%d", CmosSync);
ASSERT_OK(TYBooleanSetValue(hDevice, "CmosSync", 0));
ASSERT_OK(TYBooleanGetValue(hDevice, "CmosSync", &CmosSync_after));
LOGD("CmosSync_after=%d", CmosSync_after);

DeviceStreamAsyncMode数据流异步模式

深度相机的灰度图像、彩色图像和深度图像数据输出时,支持立即输出已获取到的图像数据。

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "DeviceStreamAsyncMode", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "DeviceStreamAsyncMode", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "DeviceStreamAsyncMode" << " has " << _cnt << " kinds of " << "DeviceStreamAsyncMode" << std::endl;
int64_t _value = -1;
ASSERT_OK(TYEnumGetValue(hDevice, "DeviceStreamAsyncMode", &_value));
std::cout << "  Default value : " << _value << std::endl;
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

Light Control 相关属性说明

该模块阐述了照明控制相关的模型和功能,这些功能可应用于专用照明控制器,或具备集成照明控制功能的相机。

LightControllerSelector获取相机支持光源

其中,LightController0 表示激光器,LightController1 表示泛光灯。

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "LightControllerSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "LightControllerSelector", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "LightControllerSelector" << " has " << _cnt << " kinds of " << "LightControllerSelector" << std::endl;
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

激光器使能与亮度调节

开启激光器,读取激光器强度的范围及调节步长并且设置激光强度。

//选择激光器
ASSERT_OK(TYEnumSetString(hDevice, "LightControllerSelector", "LightController0"));
//打开激光器
ASSERT_OK(TYBooleanSetValue(hDevice, "LightEnable", true));
int64_t min_brightness, max_brightness, step;
ASSERT_OK(TYIntegerGetMin(hDevice, "LightBrightness", &min_brightness));
ASSERT_OK(TYIntegerGetMax(hDevice, "LightBrightness", &max_brightness));
ASSERT_OK(TYIntegerGetStep(hDevice, "LightBrightness", &step));
LOGD("Laser brightness range: [%lld, %lld], step: %lld", min_brightness, max_brightness, step);
//设置激光强度
ASSERT_OK(TYIntegerSetValue(hDevice, "LightBrightness", 100));

LaserWorkMode激光器工作模式设置

获得激光器支持的工作模式,并设置其工作模式。

其中,Sync表示两个激光器同时闪烁,Alternate表示两个激光器交替闪烁,Left表示只有左激光器工作,Right表示只有右激光器工作。

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "LaserWorkMode", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "LaserWorkMode", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "LaserWorkMode" << " has " << _cnt << " kinds of " << "LaserWorkMode" << std::endl;
int64_t _value = -1;
ASSERT_OK(TYEnumGetValue(hDevice, "LaserWorkMode", &_value));
std::cout << "  Default value : " << _value << std::endl;
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}
ASSERT_OK(TYEnumSetString(hDevice, "LaserWorkMode", _cnt_entry[0].name));

红外泛光灯使能与亮度调节

开启红外泛光灯,读取泛光灯亮度的范围及调节步长并且设置亮度。

//选择红外泛光灯
ASSERT_OK(TYEnumSetString(hDevice, "LightControllerSelector", "LightController1"));
//打开红外泛光灯
ASSERT_OK(TYBooleanSetValue(hDevice, "LightEnable", true));
int64_t min_brightness, max_brightness, step;
ASSERT_OK(TYIntegerGetMin(hDevice, "LightBrightness", &min_brightness));
ASSERT_OK(TYIntegerGetMax(hDevice, "LightBrightness", &max_brightness));
ASSERT_OK(TYIntegerGetStep(hDevice, "LightBrightness", &step));
LOGD("Laser brightness range: [%lld, %lld], step: %lld", min_brightness, max_brightness, step);
//设置红外泛光亮度
ASSERT_OK(TYIntegerSetValue(hDevice, "LightBrightness", 100));

Source Control 相关属性说明

该模块主要描述多源采集设备的相关功能特性。以双目相机为例(可见光与红外光传感器),这类设备可通过单一物理接口传输多路数据,同时各传感器仍保持独立的可控功能。

该模块包含深度图像传感器组件(Depth)、彩色图像传感器组件(Texture)、左单色图像传感器组件(Left)、右单色图像传感器组件(Right)。

设置组件下的参数时,需先将 SourceSelector 切换至需要操作的组件下才可进行准确设置。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Right"));

SourceSelector获取相机支持的组件

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "SourceSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "SourceSelector", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "SourceSelector" << " has " << _cnt << " kinds of " << "SourceSelector" << std::endl;
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}

PixelFormat图像格式设置

//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
//使能组件
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "PixelFormat", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "PixelFormat", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "PixelFormat" << " has " << _cnt << " kinds of " << "PixelFormat" << std::endl;
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}
ASSERT_OK(TYEnumSetString(hDevice, "PixelFormat", _cnt_entry[0].name));

BinningHorizontal图像分辨率设置

设置图像格式完成后,获取图像支持的分辨率并完成设置。

uint32_t _cnt0 = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "BinningHorizontal", &_cnt0));
std::vector<TYEnumEntry> _cnt_entry0(_cnt0);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "BinningHorizontal", _cnt_entry0.data(), _cnt0, &_cnt0));
std::cout << "BinningHorizontal" << " has " << _cnt0 << " kinds of " << "BinningHorizontal" << std::endl;
for (int i = 0; i < _cnt0; i++) {
    std::cout << "  Name : " << _cnt_entry0[i].name << " value : " << _cnt_entry0[i].value << std::endl;
}
ASSERT_OK(TYEnumSetString(hDevice, "BinningHorizontal", _cnt_entry0[0].name));

SGBM 属性设置

参数名

数据类型

描述

DepthSgbmDisparityNumber

整型

设置视差搜索范围。匹配窗口在搜索过程中的视差搜索范围。

设定值越大,相机Z方向的测量范围越大,算力会增加。

DepthSgbmDisparityOffset

整型

设置开始搜索的视差值。

设定值越小,Z方向最大测量值(Zmax)越大,即测量范围越远,但设定值下限受景深影响。

DepthSgbmMatchWinHeight

整型

设置视差匹配窗口的高。设定值必须为奇数。

DepthSgbmMatchWinWidth

整型

设置视差匹配窗口的宽。设定值必须为奇数。

DepthSgbmImageNumber

整型

设置用于深度计算的 IR 图像数量。

设定值越大,输出深度图像质量越好,帧率越小。设定值上限受相机算力影响。

DepthSgbmSemiParamP1

整型

相邻像素 (+/-1) 约束惩罚参数 P1。

设定值越大,深度图越平滑。

防止出现不连续或不合理的深度值,有效抑制噪声和不连续性。

DepthSgbmSemiParamP1Scale

整型

相邻像素 (+/-1) 约束惩罚参数 P1_scale,值越小越平滑。

DepthSgbmSemiParamP2

整型

周围像素约束惩罚参数 P2。

设定值越大,深度图越平滑。P2 > P1。

该参数可以有效地处理纹理丰富区域,减少误匹配的数量。

DepthSgbmUniqueFactor

整型

唯一性检查参数 1,即最优与次优匹配点的百分比。

设定值越大,匹配代价越唯一,值越大错误匹配点过滤掉的越多。

DepthSgbmUniqueAbsDiff

整型

唯一性检查参数 2,即最优与次优匹配点的差值。

设定值越大,匹配代价越唯一,值越大错误匹配点过滤掉的越多。

DepthSgbmUniqueMaxCost

整型

唯一性约束的最大代价比率,用于过滤不可靠的视差。值越大,约束越严格,更少匹配,但更可靠。

DepthSgbmHFilterHalfWin

布尔型

搜索滤波开关。

用于进一步优化深度图,去除噪声和不连续性,对物体边缘点云更友好。

DepthSgbmMedFilter

布尔型

中值滤波开关。

用于消除孤立的噪声点,同时尽可能地保留图像的边缘信息。

DepthSgbmMedFilterThresh

整型

中值滤波阈值。

设定值越大,过滤的噪点越多,但也可能会导致深度图的细节信息丢失。

DepthSgbmLRC

布尔型

左右一致性检查开关。

DepthSgbmLRCDiff

整型

左右一致性检查参数。

在进行立体匹配时,对于同一物体表面上的像素,左图匹配右图的视差为 LR,右图匹配左图的视差为 RL。当 ABS(LR-RL) < max LRC diff 时,则认为该点是可信匹配点。

左右一致性检查参数设定值越小,匹配越可靠。

DepthSgbmTextureFilterEnable

布尔型

纹理滤波开关。

DepthSgbmTextureFilterThreshold

整型

纹理过滤的阈值。 用于确定一个区域是否具有足够的纹理来进行可靠的立体匹配。

DepthSgbmTextureFilterWindowSize

整型

纹理滤波的检测窗口大小。

DepthSgbmTextureFilterValueOffset

整型

纹理强度计算的偏移量,用于调整纹理检测的灵敏度。

DepthSgbmTextureFilterMaxDistance

整型

设置纹理滤波的最大有效距离。

DepthSgbmSaturateFilterEnable

布尔型

饱和滤波开关。

DepthSgbmSaturateFilterVal

整型

设置饱和滤波的阈值。

DepthSgbmSaturateFilterDilateSize

整型

设置饱和滤波的膨胀核大小。

DepthSgbmSaturateFilterBlurSize

整型

设置饱和滤波的模糊核大小。

  • 对于整型的 SGBM 参数,读取参数可设置范围及调节步长,其设置方法如下:

    将代码中 cfg.feature_name.c_str() 替换成需要设置的参数即可。

    int64_t min, max, step, default_value;
    min = max = step = default_value = -1;
    ASSERT_OK(TYIntegerGetMin(hDevice, cfg.feature_name.c_str(), &min));
    ASSERT_OK(TYIntegerGetMax(hDevice, cfg.feature_name.c_str(), &max));
    ASSERT_OK(TYIntegerGetStep(hDevice, cfg.feature_name.c_str(), &step));
    ASSERT_OK(TYIntegerGetValue(hDevice, cfg.feature_name.c_str(), &default_value));
    std::cout << cfg.feature_name.c_str() << " : [" << min << "," << max << "] -- " << step << " ,default : " << default_value << std::endl;
    ASSERT_OK(TYIntegerSetValue(hDevice, cfg.feature_name.c_str(), min+step));
    
  • 对于布尔型的 SGBM 参数,读取参数可设置范围及调节步长,其设置方法如下:

    将代码中 cfg.feature_name.c_str() 替换成需要设置的参数即可。

    ASSERT_OK(TYBooleanSetValue(hDevice, cfg.feature_name.c_str(), true));
    

DepthScaleUnit深度测量值计算系数

深度图中每个像素的数据值与该系数的乘积可得到实际测得的距离,单位:mm。

该值会影响到最终的深度计算结果。若设定值过小,可能会导致深度计算出现误差。若设定值过大,可能会降低深度计算的精度。

//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));

double  Suint_out = -1, Suint_min = -1, Suint_max = -1, Suint_step = -1;
ASSERT_OK(TYFloatGetValue(hDevice, "DepthScaleUnit", &Suint_out));
ASSERT_OK(TYFloatGetMin(hDevice, "DepthScaleUnit", &Suint_min));
ASSERT_OK(TYFloatGetMax(hDevice, "DepthScaleUnit", &Suint_max));
ASSERT_OK(TYFloatGetStep(hDevice, "DepthScaleUnit", &Suint_step));
LOGD(" get value=%f, range: %f-%f,step:%f\n", Suint_out, Suint_min, Suint_max, Suint_step);

DepthRangeMin/Max深度有效距离范围设置

深度图中数值小于最小深度有效距离阈值的像素将被置为 0,不参与后续计算。

深度图中数值大于最大深度有效距离阈值的像素将被置为 0,不参与后续计算。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYIntegerSetValue(hDevice, "DepthRangeMin", 500));
ASSERT_OK(TYIntegerSetValue(hDevice, "DepthRangeMax", 1500));

ExposureAuto自动曝光控制

图像传感器组件的自动曝光开关。大部分相机的 Texture 组件支持图像自动曝光。仅 GM 系列相机的 Left/Right 组件支持自动曝光。

//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", true));

AutoFunctionAOIOffsetX/OffsetY/Width/Height自动曝光区域

设置图像传感器的自动曝光配置的统计范围,此功能需开启自动曝光。通过设置自动曝光区域,实现在复杂光照条件下的精准曝光控制。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", true));
ASSERT_OK(TYIntegerSetValue(hDevice, "AutoFunctionAOIOffsetX", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "AutoFunctionAOIOffsetY", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "AutoFunctionAOIWidth", 640));
ASSERT_OK(TYIntegerSetValue(hDevice, "AutoFunctionAOIHeight", 480));

注解

  • AutoFunctionAOIWidth + AutoFunctionAOIOffsetX < 图像宽

  • AutoFunctionAOIHeight + AutoFunctionAOIOffsetY < 图像高

ExposureAutoUpperLimit/LowerLimit自动曝光上限/下限

自动曝光上限/下限设定后,其曝光时间将被严格约束在预设范围内。在高亮度场景下,曝光时间以 LowerLimit 为下限。在低照度场景下,曝光时间以 UpperLimit 为上限。当曝光时间达到设定限值时,将自动启用增益补偿,以确保图像亮度稳定。

仅 GM 系列相机的 Left/Right 组件支持设置自动曝光上限/下限。

示例代码:设置 Left 组件的自动曝光下限。如需设置上限,将示例代码中的 “ExposureAutoLowerLimit” 替换成 “ExposureAutoUpperLimit” 即可。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", " Left "));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", true));
double fmin, fmax, fstep, fdefault_value;
fmin = fmax = fstep = fdefault_value = -1.0f;
ASSERT_OK(TYFloatGetMin(hDevice, "ExposureAutoLowerLimit", &fmin));
ASSERT_OK(TYFloatGetMax(hDevice, "ExposureAutoLowerLimit", &fmax));
ASSERT_OK(TYFloatGetStep(hDevice, "ExposureAutoLowerLimit", &fstep));
ASSERT_OK(TYFloatGetValue(hDevice, "ExposureAutoLowerLimit", &fdefault_value));
std::cout << "ExposureAutoLowerLimit" << " : [" << fmin << "," << fmax << "] -- " << fstep << " ,default : " << fdefault_value << std::endl;
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureAutoLowerLimit", fmin));

BalanceWhiteAuto自动白平衡控制

自动白平衡功能适用于彩色图像传感器,通过调整 R、G、B 三个通道的数字增益值实现色彩空间的平衡。若要手动设置 R、G、B 三个通道的数字增益,需先关闭自动白平衡功能,否则自动白平衡功能会与手动设置的 R、G、B 通道数字增益冲突,影响图像效果。

//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "BalanceWhiteAuto", true));

ExposureTargetBrightness自动曝光的目标亮度

在优化高对比度场景的彩色图像成像效果时,目标亮度的调整非常重要。当感兴趣区域相对其他区域过暗时,增加目标亮度,直到可看到该区域的细节。当感兴趣区域相对其他区域过亮时,降低目标亮度,直到可看到该区域的细节。

//设置组件并使能组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", true));
int64_t min, max, step, default_value;
min = max = step = default_value = -1.0;
ASSERT_OK(TYIntegerGetMin(hDevice, "ExposureTargetBrightness", &min));
ASSERT_OK(TYIntegerGetMax(hDevice, "ExposureTargetBrightness", &max));
ASSERT_OK(TYIntegerGetStep(hDevice, "ExposureTargetBrightness", &step));
ASSERT_OK(TYIntegerGetValue(hDevice, "ExposureTargetBrightness", &default_value));
std::cout << "ExposureTargetBrightness" << " : [" << min << "," << max << "] -- " << step << " ,default : " << default_value << std::endl;
ASSERT_OK(TYIntegerSetValue(hDevice, "ExposureTargetBrightness", 4000));

ExposureTime曝光时间

不同图像传感器、不同帧率配置下的曝光时间可调范围不同。设置曝光时间前,如果图像传感器支持自动曝光设置,需要关闭自动曝光设置功能。

//设置组件并使能组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
//关闭自动曝光
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", false));
double fmin, fmax, fstep, fdefault_value;
fmin = fmax = fstep = fdefault_value = -1.0f;
ASSERT_OK(TYFloatGetMin(hDevice, "ExposureTime", &fmin));
ASSERT_OK(TYFloatGetMax(hDevice, "ExposureTime", &fmax));
ASSERT_OK(TYFloatGetStep(hDevice, "ExposureTime", &fstep));
ASSERT_OK(TYFloatGetValue(hDevice, "ExposureTime", &fdefault_value));
std::cout << "ExposureTime" << " : [" << fmin << "," << fmax << "] -- " << fstep << " ,default : " << fdefault_value << std::endl;
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 100.5));

AnalogAll模拟增益

不同图像传感器的模拟增益可调范围不同。设置图像传感器组件的模拟增益时,需要先关闭自动曝光调整功能。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", false));
double fmin, fmax, fstep, fdefault_value;
fmin = fmax = fstep = fdefault_value = -1.0f;
ASSERT_OK(TYEnumSetString(hDevice, "GainSelector", "AnalogAll"));
ASSERT_OK(TYFloatGetMin(hDevice, "Gain", &fmin));
ASSERT_OK(TYFloatGetMax(hDevice, "Gain", &fmax));
ASSERT_OK(TYFloatGetStep(hDevice, "Gain", &fstep));
ASSERT_OK(TYFloatGetValue(hDevice, "Gain", &fdefault_value));
std::cout << "Gain" << " : [" << fmin << "," << fmax << "] -- " << fstep << " ,default : " << fdefault_value <<
std::endl;
ASSERT_OK(TYFloatSetValue(hDevice, "Gain", 65535));

DigitalRed/Green/Blue数字增益

彩色图像传感器模组的数字增益需要通过 R、G、B 三通道独立设置。在设置增益前,若相机支持自动白平衡,需先将其关闭。

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "GainSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "GainSelector", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "GainSelector" << " has " << _cnt << " kinds of " << "GainSelector" << std::endl;
int32_t _value = -1;
ASSERT_OK(TYEnumGetValue(hDevice, "GainSelector", &_value));
std::cout << " Default value : " << _value << std::endl;
for (int i = 0; i < _cnt; i++) {
std::cout << " Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}
double min, max, value;
ASSERT_OK(TYEnumSetString(hDevice, "GainSelector", "DigitalRed"));
ASSERT_OK(TYFloatGetMin(hDevice, "Gain", &min));
ASSERT_OK(TYFloatGetMax(hDevice, "Gain", &max));
ASSERT_OK(TYFloatGetValue(hDevice, "Gain", &value));
printf("DigitalRed : [%f,%f] --- %f\n", min, max, value);
ASSERT_OK(TYFloatSetValue(hDevice, "Gain", min));
ASSERT_OK(TYEnumSetString(hDevice, "GainSelector", "DigitalGreen"));
ASSERT_OK(TYFloatGetMin(hDevice, "Gain", &min));
ASSERT_OK(TYFloatGetMax(hDevice, "Gain", &max));
ASSERT_OK(TYFloatGetValue(hDevice, "Gain", &value));
printf("DigitalGreen : [%f,%f] --- %f\n", min, max, value);
ASSERT_OK(TYFloatSetValue(hDevice, "Gain", min));
ASSERT_OK(TYEnumSetString(hDevice, "GainSelector", "DigitalBlue"));
ASSERT_OK(TYFloatGetMin(hDevice, "Gain", &min));
ASSERT_OK(TYFloatGetMax(hDevice, "Gain", &max));
ASSERT_OK(TYFloatGetValue(hDevice, "Gain", &value));
printf("DigitalBlue : [%f,%f] --- %f\n", min, max, value);
ASSERT_OK(TYFloatSetValue(hDevice, "Gain", max));

IRUndistortion畸变矫正开关

单色图像传感器组件默认输出未做畸变矫正的图像数据。

ASSERT_OK(TYBooleanSetValue(hDevice, "IRUndistortion", true));

UserSet Control 相关属性说明

该模块为设备设置的全局控制功能,支持载入或保存出厂设置及用户自定义配置。载入默认用户设置可确保设备处于仅需基础功能即可启动持续采集的工作状态。

UserSet 属性组分为两大类,一类是 Default 组,共有 8 组(default0 ~ default7),出厂时预置,不可修改组内参数及描述,仅可加载调用。 另一类是 UserSet 组,共有 8 组(userset8 ~ userset15),初始为空,用户可自定义参数并保存。灵活适配用户需求(如场景化配置存档)。

读取当前 UserSet 属性组

UserSetCurrent 用来读取当前相机使用的用户组,使用方法如下:

int64_t current_set = -1;
ASSERT_OK(TYIntegerGetValue(hDevice, "UserSetCurrent", &current_set));
printf("UserSetCurrent is %d\n", current_set);

加载指定 UserSet 属性组

//读相机支持加载 User Set 的数量。
TY_ACCESS_MODE access;
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "UserSetSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "UserSetSelector", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "UserSetSelector" << " has " << _cnt << " kinds of " << "UserSetSelector" << std::endl;
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetValue(hDevice, "UserSetSelector", _cnt_entry[i].value));
ASSERT_OK(TYParamGetAccess(hDevice, "UserSetLoad", &access));
if (access) {
std::cout << " Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << " can be
loaded!" << std::endl;
}
}
//选择要加载的 User Set
ASSERT_OK(TYEnumSetValue(hDevice, "UserSetSelector", _cnt_entry[0].value));
//加载 User Set
ASSERT_OK(TYCommandExec(hDevice, "UserSetLoad"));

读写 UserSet 属性组描述

Default 组不可修改描述。

//设置
ASSERT_OK(TYStringSetValue(hDevice, "UserSetDescription", "hahahahaha"));
//读取
uint32_t len = 0;
ASSERT_OK(TYStringGetLength(hDevice, "UserSetDescription", &len));
std::string hash(len, '\0');
ASSERT_OK(TYStringGetValue(hDevice, "UserSetDescription", &hash[0], len));
std::cout << "UserSetDescription : " << hash << std::endl;

保存 UserSet 属性组

将设置好的参数保存至 UserSet 属性组中。在调用 UserSetSave 前,必须先设置描述。

ASSERT_OK(TYEnumSetValue(hDevice, "UserSetSelector", 8));
ASSERT_OK(TYStringSetValue(hDevice, "UserSetDescription", "hahahahaha"));
ASSERT_OK(TYCommandExec(hDevice, "UserSetSave"));

设置默认加载 UserSet 属性组

ASSERT_OK(TYEnumSetValue(hDevice, "UserSetDefault", 0));

FileAccess Control 相关属性说明

FileAccessControl 模块用于实现设备内文件访问控制功能,能够对出厂预设、用户设置及自定义文件进行读取、写入或删除操作。其中,出厂预设文件(Default 0~7)为只读,用户设置(UserSet 0~7)与自定义文件(CustomFile 0~7)为可读写。

注解

下方是 FileAccess Control 相关的所有属性说明。另外,camport4/sample/sample_genicam_sfnc/sample_file_iostream 示例程序展示了文件读取、写入、删除操作的完整代码,可供开发参考。

读/写/删除文件流程图

文件读取操作流程
开始
│
├── 选择文件
│   └── 设置 FileSelector
│
├── 设置打开模式
│   └── 设置 FileOpenMode (Read/ReadWrite)
│
├── 打开文件
│   ├── 设置 FileOperationSelector = Open
│   └── 执行 FileOperationExecute
│
├── 等待打开完成
│   └── 轮询 FileOperationStatus
│
├── 检查打开结果
│   └── 读取 FileOperationResult
│
├── 读文件操作
│   ├── 设置 FileOperationSelector = Read
│   ├── 可选:读取 FileSize 获取文件大小
│   ├── 设置 FileAccessOffset (读取起始位置)
│   ├── 设置 FileAccessLength (读取字节数)
│   └── 执行 FileOperationExecute
│
├── 等待读取完成
│   └── 轮询 FileOperationStatus
│
├── 检查读取结果
│   └── 读取 FileOperationResult
│
├── 关闭文件
│   ├── 设置 FileOperationSelector = Close
│   └── 执行 FileOperationExecute
│
└── 结束
读文件示例代码
ASSERT_OK(TYEnumSetValue(hDevice, "FileSelector", 0));
ASSERT_OK(TYEnumSetString(hDevice, "FileOpenMode", "Read"));
ASSERT_OK(TYEnumSetString(hDevice, "FileOperationSelector", "Open"));
ASSERT_OK(TYCommandExec(hDevice, "FileOperationExecute"));
int64_t operationStatus;
ASSERT_OK(TYEnumGetValue(hDevice, "FileOperationStatus", &operationStatus));
if (operationStatus == 0) {
    std::cout << "Operation executed successfully" << std::endl;
}
else {
    std::cout << "Operation execution failed. Status code: " << operationStatus << std::endl;
}
int64_t operationResult;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileOperationResult", &operationResult));
std::cout << "File operation result: " << operationResult << std::endl;
ASSERT_OK(TYEnumSetString(hDevice, "FileOperationSelector", "Read"));
int64_t fileSize;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileSize", &fileSize));
std::cout << "File size: " << fileSize << " Byte" << std::endl;
ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessOffset", 0));
int64_t currentOffset;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessOffset", &currentOffset));
std::cout << "Current file access offset: " << currentOffset << std::endl;
ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessLength", 400));
int64_t currentLength;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessLength", &currentLength));
std::cout << "Current file access length: " << currentLength << " 字节" << std::endl;
ASSERT_OK(TYCommandExec(hDevice, "FileOperationExecute"));
ASSERT_OK(TYEnumGetValue(hDevice, "FileOperationStatus", &operationStatus));
if (operationStatus == 0) {
    std::cout << "Operation executed successfully" << std::endl;
}
else {
    std::cout << "Operation execution failed. Status code:" << operationStatus << std::endl;
}
ASSERT_OK(TYIntegerGetValue(hDevice, "FileOperationResult", &operationResult));
std::cout << "File operation result: " << operationResult << std::endl;
ASSERT_OK(TYEnumSetString(hDevice, "FileOperationSelector", "Close"));
ASSERT_OK(TYCommandExec(hDevice, "FileOperationExecute"));

FileSelector 文件选择器

用于选择目标操作文件,支持以下三种文件类型:

  • 出厂预设文件(Default 0~7)

  • 用户设置文件(UserSet 0~7)

  • 用户自定义文件(CustomFile 0~7)

uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "FileSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "FileSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
    std::cout << "  Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;}

ASSERT_OK(TYEnumSetValue(hDevice, "FileSelector", 16));

FileOpenMode文件打开模式

在操作流程初期用于设定文件访问权限,为后续操作建立权限基础。支持以下三种模式:

  • 0:Read(只读)

  • 1:Write(只写)

  • 2:ReadWrite(可读写)

权限规则:

  • 当 FileSelector 选择出厂预设文件时,只能将访问权限设置为 Read 模式;

  • 当 FileSelector 选择用户设置文件/用户自定义文件时,可将访问权限设置为 Read/Write/ReadWrite 模式。

ASSERT_OK(TYEnumSetValue(hDevice, "FileSelector", 16));

uint32_t count = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "FileOpenMode", &count));
std::vector<TYEnumEntry> entries(count);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "FileOpenMode", entries.data(), count, &count));
for (int i = 0; i < count; i++) {
    std::cout << "Name: " << entries[i].name << " value: " << entries[i].value << std::endl;
}

ASSERT_OK(TYEnumSetValue(hDevice, "FileOpenMode", 2));

FileOperationSelector操作类型选择

在操作执行阶段用于声明接下来要执行的具体文件操作类型,为 FileOperationExecute 提供明确的指令方向。

文件操作类型包括:

  • 0:Open 打开文件(始终允许,不受 FileOpenMode 的约束)

  • 1:Close 关闭文件(始终允许,不受 FileOpenMode 的约束)

  • 2:Read 读取文件(FileOpenMode 为 Read/ReadWrite 时允许)

  • 3:Write 写入文件(FileOpenMode 为 Write/ReadWrite 时允许)

  • 4:Delete 删除文件内容(始终允许,不受 FileOpenMode 的约束)

uint32_t count = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "FileOperationSelector", &count));
std::vector<TYEnumEntry> entries(count);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "FileOperationSelector", entries.data(), count, &count));

for (int i = 0; i < count; i++) {
    std::cout << "Name: " << entries[i].name << " value: " << entries[i].value << std::endl;
}


ASSERT_OK(TYEnumSetValue(hDevice, "FileOperationSelector", 0));

FileOperationExecute执行命令

文件操作流程中的执行触发器,在所有参数配置完成后启动实际操作。

ASSERT_OK(TYEnumSetValue(hDevice, "FileOperationSelector", 0));

ASSERT_OK(TYCommandExec(hDevice, "FileOperationExecute"));

FileOperationStatus执行状态

在执行 FileOperationExecute 后,通过轮询此属性来获取文件操作的执行状态。

  • 0:操作成功

  • 1:操作失败

int64_t operationStatus;
ASSERT_OK(TYEnumGetValue(hDevice, "FileOperationStatus", &operationStatus));

if (operationStatus == 0) {
    std::cout << "opertation success" << std::endl;
} else {
    std::cout << "opertation failed,status code: " << operationStatus << std::endl;
}

FileSize文件大小

用于获取当前选定文件的实际大小(单位:字节)。

ASSERT_OK(TYEnumSetValue(hDevice, "FileOperationSelector", 2));
int64_t fileSize;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileSize", &fileSize));
std::cout << "File size: " << fileSize << " Bites" << std::endl;

FileAccessOffset设置读写位置

用于设置文件读写操作的起始字节位置。

生效条件:本属性仅在 FileOperationSelector 设置为 Read 或 Write 时生效。

取值范围:

  • Read 模式:[0, 文件实际大小 - 1] (字节)

  • Write 模式:[0, 文件实际大小] (字节)

ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessOffset", 100));

int64_t currentOffset;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessOffset", &currentOffset));
std::cout << "Current file access offset: " << currentOffset << std::endl;

FileAccessLength 设置读写长度

用于设置单次读写操作的数据量大小,与 FileAccessOffset 配合使用,精确界定操作的数据范围。

生效条件:本属性仅在 FileOperationSelector 设置为 Read 或 Write 时生效。

取值范围:

  • Read 模式:[0, 文件实际大小 - 1] (字节)

  • Write 模式:[0, 文件实际大小] (字节)

ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessLength", 512));

int64_t currentLength;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessLength", &currentLength));
std::cout << "Current file access length: " << currentLength << " Bites" << std::endl;

FileAccessBuffer 数据缓冲区

FileAccessBuffer 作为数据中转缓冲区,在文件写入前暂存待写入数据,在文件读取后存储已读取数据。

std::vector<uint8_t> writeData = { 0x01, 0x02, 0x03, 0x04 };
uint32_t writeSize = static_cast<uint32_t>(writeData.size());
TY_STATUS status = TYByteArraySetValue(hDevice, "FileAccessBuffer",
    writeData.data(), writeSize);
if (status != TY_STATUS_OK) {
    printf("Write failure: 0x%08X\n", status);
    return false;
}
printf("Successful writing %u Byte\n", writeSize);
ASSERT_OK(TYCommandExec(hDevice, "FileOperationExecute"));

FileOperationResult 读写操作结果

在调用 FileOperationExecute 执行文件读写后,通过此属性获取读写的实际字节数。

int64_t operationResult;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileOperationResult", &operationResult));
std::cout << "文件操作结果: " << operationResult << std::endl;

相机标定相关属性说明

读取 Sensor 宽/高

int64_t width, height;
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
ASSERT_OK(TYIntegerGetValue(hDevice, "IntrinsicWidth", &width));
ASSERT_OK(TYIntegerGetValue(hDevice, "IntrinsicHeight", &height));

读取内参矩阵

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
double mat_intr_3x3[9];
ASSERT_OK(TYByteArrayGetValue(hDevice, "Intrinsic", reinterpret_cast<uint8_t*>(mat_intr_3x3),
sizeof(mat_intr_3x3)));
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[0]
<< std::setw(12) << mat_intr_3x3[1]
<< std::setw(12) << mat_intr_3x3[2] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[3]
<< std::setw(12) << mat_intr_3x3[4]
<< std::setw(12) << mat_intr_3x3[5] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[6]
<< std::setw(12) << mat_intr_3x3[7]
<< std::setw(12) << mat_intr_3x3[8] << std::endl;

读取校正矩阵

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
double mat_intr_3x3[9];
ASSERT_OK(TYByteArrayGetValue(hDevice, "Intrinsic2", reinterpret_cast<uint8_t*>(mat_intr_3x3),
sizeof(mat_intr_3x3)));
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[0]
<< std::setw(12) << mat_intr_3x3[1]
<< std::setw(12) << mat_intr_3x3[2] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[3]
<< std::setw(12) << mat_intr_3x3[4]
<< std::setw(12) << mat_intr_3x3[5] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_intr_3x3[6]
<< std::setw(12) << mat_intr_3x3[7]
<< std::setw(12) << mat_intr_3x3[8] << std::endl;

读取外参矩阵

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Texture"));
double mat_extrinsic_4x4[16];
ASSERT_OK(TYByteArrayGetValue(hDevice, "Extrinsic", reinterpret_cast<uint8_t*>(mat_extrinsic_4x4),
sizeof(mat_extrinsic_4x4)));
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_extrinsic_4x4[0]
<< std::setw(12) << mat_extrinsic_4x4[1]
<< std::setw(12) << mat_extrinsic_4x4[2]
<< std::setw(12) << mat_extrinsic_4x4[3] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_extrinsic_4x4[4]
<< std::setw(12) << mat_extrinsic_4x4[5]
<< std::setw(12) << mat_extrinsic_4x4[6]
<< std::setw(12) << mat_extrinsic_4x4[7] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_extrinsic_4x4[8]
<< std::setw(12) << mat_extrinsic_4x4[9]
<< std::setw(12) << mat_extrinsic_4x4[10]
<< std::setw(12) << mat_extrinsic_4x4[11] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_extrinsic_4x4[12]
<< std::setw(12) << mat_extrinsic_4x4[13]
<< std::setw(12) << mat_extrinsic_4x4[14]
<< std::setw(12) << mat_extrinsic_4x4[15] << std::endl;

读取旋转矩阵

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
double mat_rotation_3x3[9];
ASSERT_OK(TYByteArrayGetValue(hDevice, "Rotation", reinterpret_cast<uint8_t*>(mat_rotation_3x3),
sizeof(mat_rotation_3x3)));
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_rotation_3x3[0]
<< std::setw(12) << mat_rotation_3x3[1]
<< std::setw(12) << mat_rotation_3x3[2] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_rotation_3x3[3]
<< std::setw(12) << mat_rotation_3x3[4]
<< std::setw(12) << mat_rotation_3x3[5] << std::endl;
std::cout << "\t\t" << std::setw(12) << std::setfill(' ') << std::fixed << std::setprecision(6) << mat_rotation_3x3[6]
<< std::setw(12) << mat_rotation_3x3[7]
<< std::setw(12) << mat_rotation_3x3[8] << std::endl;

读取畸变矩阵

ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
double mat_distortion_12x1[12];
ASSERT_OK(TYByteArrayGetValue(hDevice, "Distortion", reinterpret_cast<uint8_t*>(mat_distortion_12x1),
sizeof(mat_distortion_12x1)));
std::cout << std::fixed << std::setprecision(6) << "\t\t";
for (size_t i = 0; i < sizeof(mat_distortion_12x1) / sizeof(double); i++) {
std::cout << std::setw(12) << mat_distortion_12x1[i];
}
std::cout << std::endl;