属性设置说明 (GenICam 相机)
重要
目前支持的属性及其定义,请参见 camport4/include/TYFeatureList.h 头文件。
DeviceControl 相关属性说明
该模块提供设备(相机)及其传感器的一般信息与控制,主要用于在枚举过程中识别设备并获取传感器分辨率相关信息。此类别还包含与设备整体状态相关的其他信息及控制项。
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
Timestamp 读取时间戳
int64_t value;
ASSERT_OK(TYIntegerGetValue(hDevice, "Timestamp", &value));
LOGD("Timestamp %lld", value);
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));
AcquisitionControl 相关属性说明
该模块描述了与图像采集相关的所有功能,控制图像或数据的采集过程,如触发模式、帧率等。
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));
TransportLayerControl 相关属性说明
该模块提供传输层控制功能,主要包含数据包大小调整、丢包检测、流控制、带宽限制等功能。
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;
}
LightControl 相关属性说明
该模块阐述了照明控制相关的模型和功能,这些功能可应用于专用照明控制器,或具备集成照明控制功能的相机。
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));
SourceControl 相关属性说明
该模块主要描述多源采集设备的相关功能特性。以双目相机为例(可见光与红外光传感器),这类设备可通过单一物理接口传输多路数据,同时各传感器仍保持独立的可控功能。
该模块包含深度图像传感器组件(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 |
整型 |
设置饱和滤波的模糊核大小。 |
DepthSgbmSpeckleFilterEnable |
布尔型 |
散斑滤波开关。 |
DepthSgbmSpeckleFilterSize |
整型 |
设置散斑滤波器面积阈值。面积小于该阈值的聚类斑点会被滤除。该值越大,滤除的聚类斑点越多。 |
DepthSgbmSpeckleFilterMaxDiff |
浮点型 |
设置散斑滤波器聚类阈值。若相邻像素的深度差值小于该阈值,则认为该相邻像素属于同一个聚类斑点。该值越大,相邻像素属于同一聚类斑点越多。 |
DepthSgbmSpeckleFilterMaxPhysicalSize |
浮点型 |
最大物理尺寸。 |
对于整型的 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));
HDR 功能
HDRExposureCnt 用于设置参与 HDR 计算的图像帧数。
HDRExposureCnt |
对应可设置的曝光时间 |
|---|---|
1 |
ExposureTime |
2 |
ExposureTime、HDRExposureTime2 |
3 |
ExposureTime、HDRExposureTime2、HDRExposureTime3 |
4 |
ExposureTime、HDRExposureTime2、HDRExposureTime3、HDRExposureTime4 |
ASSERT_OK(TYIntegerSetValue(hDevice, "HDRExposureCnt", 4));
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 200));
ASSERT_OK(TYFloatSetValue(hDevice, "HDRExposureTime2", 1000));
ASSERT_OK(TYFloatSetValue(hDevice, "HDRExposureTime3", 3000));
ASSERT_OK(TYFloatSetValue(hDevice, "HDRExposureTime4", 4000));
UserSetControl 相关属性说明
该模块为设备设置的全局控制功能,支持载入或保存出厂设置及用户自定义配置。载入默认用户设置可确保设备处于仅需基础功能即可启动持续采集的工作状态。
UserSet 属性组分为两大类,一类是 Default 组,共有 8 组(default0 ~ default7),出厂时预置,不可修改组内参数及描述,仅可加载调用。 另一类是 UserSet 组,共有 8 组(userset8 ~ userset15),初始为空,用户可自定义参数并保存。灵活适配用户需求(如场景化配置存档)。
读取当前 UserSet 属性组
UserSetCurrent 用来读取当前相机使用的用户组,使用方法如下:
int64_t current_set = -1;
ASSERT_OK(TYIntegerGetValue(hDevice, "UserSetCurrent", ¤t_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", ¤tOffset));
std::cout << "Current file access offset: " << currentOffset << std::endl;
ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessLength", 400));
int64_t currentLength;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessLength", ¤tLength));
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
│
├── 设置打开模式
│ └── 设置 FileOpenMode (Write/ReadWrite)
│
├── 打开文件
│ ├── 设置 FileOperationSelector = Open
│ └── 执行 FileOperationExecute
│
├── 等待打开完成
│ └── 轮询 FileOperationStatus
│
├── 检查打开结果
│ └── 读取 FileOperationResult
│
├── 写文件操作
│ ├── 设置 FileOperationSelector = Write
│ ├── 设置 FileAccessOffset (写入起始位置)
│ ├── 设置 FileAccessLength (写入字节数)
│ ├── 设置 FileAccessBuffer (准备写入数据)
│ └── 执行 FileOperationExecute
│
├── 等待写入完成
│ └── 轮询 FileOperationStatus
│
├── 检查写入结果
│ └── 读取 FileOperationResult
│
├── 关闭文件
│ ├── 设置 FileOperationSelector = Close
│ └── 执行 FileOperationExecute
│
└── 结束
写文件示例代码
ASSERT_OK(TYEnumSetValue(hDevice, "FileSelector", 8));
ASSERT_OK(TYEnumSetString(hDevice, "FileOpenMode", "Write"));
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", "Write"));
ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessOffset", 0));
int64_t currentOffset;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessOffset", ¤tOffset));
std::cout << "Current file access offset: " << currentOffset << std::endl;
ASSERT_OK(TYIntegerSetValue(hDevice, "FileAccessLength", 400));
int64_t currentLength;
ASSERT_OK(TYIntegerGetValue(hDevice, "FileAccessLength", ¤tLength));
std::cout << "Current file access length: " << currentLength << " 字节" << std::endl;
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"));
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 │ ├── 设置打开模式 │ └── 设置 FileOpenMode (Read/Write/ReadWrite) │ ├── 删除文件操作 │ ├── 设置 FileOperationSelector = Delete │ └── 执行 FileOperationExecute │ ├── 等待操作完成 │ └── 轮询 FileOperationStatus │ └── 检查操作结果 └── 读取 FileOperationResult
删除文件示例代码
ASSERT_OK(TYEnumSetValue(hDevice, "FileSelector", 10));
ASSERT_OK(TYEnumSetString(hDevice, "FileOpenMode", "ReadWrite"));
ASSERT_OK(TYEnumSetString(hDevice, "FileOperationSelector", "Delete"));
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;
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", ¤tOffset));
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", ¤tLength));
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;
RegionSelector 相关属性说明
选择感兴趣的图像区域(ROI)进行传输,通过配置 Region 参数可自定义图像采集区域,以降低传输带宽和提高帧率。
RegionSelector 选择图像区域
选择需要使用的图像区域。以 PMD03 为例,相机拥有 10 个可配置图像区域(Region0 ~ Region9)。
ASSERT_OK(TYEnumSetString(hDevice, "RegionSelector", "Region0"));
Region 参数
配置 Region 的位置和大小参数。
参数名 |
数据类型 |
描述 |
|---|---|---|
WidthMax |
整型 |
当前分辨率的宽 |
HeightMax |
整型 |
当前分辨率的高 |
OffsetX |
整型 |
ROI 的横向起始位置 |
OffsetY |
整型 |
ROI 的纵向起始位置 |
Width |
整型 |
ROI 的横向宽度 |
Height |
整型 |
ROI 的纵向高度 |
重要
设置 Region 参数需满足以下约束:
OffsetX >= 0 且 Width > 0 且 OffsetX + Width <= WidthMax
OffsetY >= 0 且 Height > 0 且 OffsetY + Height <= HeightMax
OffsetX * bits_per_pixel % 8 == 0,且 Width * bits_per_pixel % 8 == 0
RegionMode 启用/关闭图像区域
选择是否启用当前选中的图像区域。
ASSERT_OK(TYEnumSetString(hDevice, "RegionMode", "On"));
以下示例展示完整的 Region 配置流程:先选择 SourceSelector 和 RegionSelector,然后配置位置和大小参数,最后启用 Region。
ASSERT_OK(TYEnumSetString(hDevice,"SourceSelector","Depth"));
ASSERT_OK(TYEnumSetString(hDevice, "RegionSelector", "Region0"));
ASSERT_OK(TYIntegerSetValue(hDevice, "OffsetX", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "OffsetY", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "Width", 1000));
ASSERT_OK(TYIntegerSetValue(hDevice, "Height", 1000));
ASSERT_OK(TYEnumSetString(hDevice, "RegionMode", "On"));
DigitalIOControl 相关属性说明
该模块控制设备的输入与输出信号功能,支持 IO 口选择、消抖配置及输出信号源设置。
LineSelector 选择 IO 口
选择需要操作的 IO 口对象。通常来说:
Line0/Line1 为相机的输入端口,对应 TriggerIn1 和 TriggerIn2
Line2/Line3 为相机的输出端口,对应 TriggerOut1 和 TriggerOut2
int64_t value = 0;
ASSERT_OK(TYEnumGetValue(hDevice, "LineSelector", &value));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "LineSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "LineSelector", _cnt_entry.data(), _cnt, &_cnt));
std::cout << "LineSelector has " << _cnt << " kinds, current 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(TYEnumSetValue(hDevice, "LineSelector", _cnt_entry[0].value));
LineSwFilter 设置输入 IO 口消抖时间
设置指定输入 IO 口的消抖时间,单位:ms。在此时间内,相机只能采集一帧图像。
ASSERT_OK(TYEnumSetString(hDevice, "LineSelector", "Line0"));
ASSERT_OK(TYIntegerSetValue(hDevice, "LineSwFilter", 1000));
LineSource 设置输出 IO 口信号源
设置输出 IO 口的信号源,支持以下三种模式:
Off— 不启用信号输出FrameTrigger— 每当收到软触发或硬触发信号时,指定 IO 口输出信号ExposureActive— 相机曝光时,指定 IO 口输出信号,信号电平保持时长约等于曝光时间
配置 Line2 为 FrameTrigger
ASSERT_OK(TYEnumSetString(hDevice, "LineSelector", "Line2"));
ASSERT_OK(TYEnumSetString(hDevice, "LineSource", "FrameTrigger"));
配置 Line3 为 ExposureActive
ASSERT_OK(TYEnumSetString(hDevice, "LineSelector", "Line3"));
ASSERT_OK(TYEnumSetString(hDevice, "LineSource", "ExposureActive"));
SequencerControl 相关属性说明
该模块支持序列控制功能,可通过预设多个参数序列实现不同场景下的参数自动切换。
SequencerMode 序列控制开关
启用(On)序列控制后,自动关闭序列的配置模式。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "On"));
SequencerConfigurationMode 序列编辑开关
启用(On)时,可对序列进行编辑。启用此功能需先关闭序列控制。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "On"));
SequencerSetSelector 选择序列编号
选取需要配置的序列。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "On"));
int64_t min, max, step, value, _value;
ASSERT_OK(TYIntegerGetMin(hDevice, "SequencerSetSelector", &min));
ASSERT_OK(TYIntegerGetMax(hDevice, "SequencerSetSelector", &max));
ASSERT_OK(TYIntegerGetStep(hDevice, "SequencerSetSelector", &step));
ASSERT_OK(TYIntegerGetValue(hDevice, "SequencerSetSelector", &value));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", max));
ASSERT_OK(TYIntegerGetValue(hDevice, "SequencerSetSelector", &_value));
printf("SequencerSetSelector: [%d,%d]-%d, origin value %d, current value %d\n", min, max, step, value, _value);
SequencerSetReset 清除序列原有设置
清除序列中原有的配置。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "On"));
// 序列 0
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", 0));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetReset"));
SequencerSetSave 保存序列编辑内容
对序列内容进行编辑后,保存编辑的内容。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "On"));
// 序列 0
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", 0));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetReset"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 1000));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 1));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Software"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "None"));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetSave"));
SequencerSetActive 读取当前序列编号
读取当前使用的序列编号。
int64_t SequencerSetActive = 0;
ASSERT_OK(TYIntegerGetValue(hDevice, "SequencerSetActive", &SequencerSetActive));
printf("SequencerSetActive %d\n", SequencerSetActive);
SequencerSetStart 设置序列开始编号
设置序列开始的编号。
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetStart", 1));
SequencerPathSelector 设置序列跳转路径
设置序列的跳转路径。每个序列支持 4 个路径(0~3),可为每个路径设置不同的触发条件。
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerPathSelector", 0));
SequencerSetNext 设置跳转目标序列
设置在触发条件满足时跳转的目标序列。
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 0));
SequencerTriggerSource 设置序列触发源
设置序列的触发源。需与 TriggerSource 保持一致。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Line0"));
SequencerTriggerActivation 设置触发有效边沿
设置序列触发源的有效边沿(上升沿或下降沿),当边沿发生跳变时触发序列跳转。边沿设置需与触发源能够接收的有效边沿一致。
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "RisingEdge"));
序列控制完整示例
配置三个序列(Set 0/1/2),通过不同的触发源实现序列间的自动切换。
ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "SingleFrame"));
ASSERT_OK(TYEnumSetString(hDevice, "TriggerSource", "Line0"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "On"));
// 配置 Set 0:曝光时间 10000μs
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", 0));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetReset"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 10000));
// Path 0:软触发跳转到 Set 1
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerPathSelector", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 1));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Software"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "None"));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetSave"));
// Path 1:Line0 上升沿跳转到 Set 2
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerPathSelector", 1));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 2));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Line0"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "RisingEdge"));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetSave"));
// 配置 Set 1:曝光时间 600μs
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", 1));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetReset"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 600));
// Path 0:软触发跳转到 Set 0
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerPathSelector", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 0));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Software"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "None"));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetSave"));
// 配置 Set 2:曝光时间 1000μs
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetSelector", 2));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetReset"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
ASSERT_OK(TYFloatSetValue(hDevice, "ExposureTime", 1000));
// Path 0:Line0 上升沿跳转到 Set 0
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerPathSelector", 0));
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetNext", 0));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerSource", "Line0"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerTriggerActivation", "RisingEdge"));
ASSERT_OK(TYCommandExec(hDevice, "SequencerSetSave"));
// 设置起始序列为 0 并启用序列控制
ASSERT_OK(TYIntegerSetValue(hDevice, "SequencerSetStart", 0));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerConfigurationMode", "Off"));
ASSERT_OK(TYEnumSetString(hDevice, "SequencerMode", "On"));
图像水印功能说明
启用图像水印功能后,相机图像中将携带曝光时间、激光亮度等信息,便于后续数据分析与调试。
TYHasImageWatermark 判断图像是否带水印
在 SDK 获取图像后调用,用于判断图像是否携带水印信息。
bool hasWatermark = false;
ASSERT_OK(TYHasImageWatermark(&frame.image[i], &hasWatermark));
printf("hasWatermark %s\n", hasWatermark ? "yes" : "no");
ImageWatermarkActive 开启/关闭水印功能
用于开启图像水印功能。
ASSERT_OK(TYBooleanSetValue(hDevice, "ImageWatermarkActive", true));
TYGetImageWatermarkVer 获取水印版本
获取图像水印版本号。
uint32_t ver = 0;
ASSERT_OK(TYGetImageWatermarkVer(&frame.image[i], &ver));
printf("ImageWatermarkVer = 0x%x\n", ver);
TYGetImageWatermark 获取水印信息
获取图像中的水印信息内容。
TY_IMAGE_WATER_MARK wm;
memset(&wm, 0, sizeof(wm));
ASSERT_OK(TYGetImageWatermark(&frame.image[i], &wm, sizeof(wm)));
printf(" deviceID: %s\n", wm.deviceID);
printf(" model: %s\n", wm.model);
printf(" timestamp: %llu\n", (unsigned long long)wm.timestamp);
printf(" frameCount: %llu\n", (unsigned long long)wm.frameCount);
printf(" sourceID: %u\n", wm.sourceID);
printf(" regionID: %u\n", wm.regionID);
printf(" triggerSource: %u\n", wm.triggerSource);
printf(" triggerCount: %u\n", wm.triggerCount);
printf(" aGain: %.4f\n", wm.aGain);
printf(" exposure: %.4f\n", wm.exposure);
printf(" undistortion: %u\n", wm.undistortion);
printf(" pixelFormat: 0x%08x\n", wm.pixelFormat);
printf(" laserBrightness: %u\n", wm.laserBrightness);
printf(" floodBrightness: %u\n", wm.floodBrightness);
printf(" userSet: %u\n", wm.userSet);
printf(" seqSet: %u\n", wm.seqSet);
水印数据结构
#define WATERMARKV1 0x10000 // WaterMark data struct of V1
typedef struct TY_IMAGE_WATER_MARK {
char deviceID[16]; // 相机序列号
char model[32]; // 相机型号名
uint64_t timestamp; // 图像时间戳
uint64_t frameCount; // 帧数,从0计数
uint32_t sourceID; // 图像源
uint32_t regionID; // 图像的区域编号
uint32_t triggerSource; // 触发源
uint32_t triggerCount; // 触发计数
float aGain; // 模拟增益
float exposure; // 曝光时间
uint32_t undistortion; // 畸变矫正状态
uint32_t pixelFormat; // 像素格式
uint32_t laserBrightness; // 激光亮度
uint32_t floodBrightness; // 泛光亮度
uint32_t userSet; // 用户设置组
uint32_t seqSet; // 序列设置
}TY_IMAGE_WATER_MARK;
EventControl 相关属性说明
该模块提供 GenICam 标准事件通知功能,支持多种事件的选择和通知控制。
EventSelector 选择事件
选择需要通知的事件,可同时开启多个事件通知。支持以下事件类型:
LinkSpeedChange— 相机网络速率发生变化时上报Test— 用于验证 SDK 事件回调机制是否正常工作,独立于图像采集FrameTrigger— 相机收到软触发信号时上报FrameTriggerMissed— 相机丢失软触发信号时上报Error— 相机发生错误时上报
ASSERT_OK(TYEnumSetString(hDevice, "EventSelector", "FrameTrigger"));
EventNotification 事件通知开关
设置事件通知的开关状态。
Off— 关闭事件通知On— 开启事件通知Once— 开启事件通知,但只通知一次
当 EventSelector 选择为 Test 时,事件通知不可被关闭。
ASSERT_OK(TYEnumSetString(hDevice, "EventNotification", "On"));
TestEventMode 测试事件模式
当 EventSelector 选择为 Test 时,选择需要测试的事件模式。
WithOutData— 只产生事件消息,不往事件寄存器写内容WithData— 产生事件消息,并往事件寄存器写内容,用于测试通道及数据完整性Burst— 产生事件消息,并往事件寄存器写内容,用于压力测试
ASSERT_OK(TYEnumSetString(hDevice, "EventSelector", "Test"));
ASSERT_OK(TYEnumSetString(hDevice, "TestEventMode", "Burst"));
TestEventGenerate 产生测试事件
当 EventSelector 选择为 Test 时,通过此命令产生事件。
ASSERT_OK(TYCommandExec(hDevice, "TestEventGenerate"));
GevMCDA 事件消息目标 IP 地址
事件消息的目标 IP 地址,相机将消息发送至此地址。OpenDevice 时自动配置,亦可自行设置。
uint32_t ip = (192 << 24) | (168 << 16) | (6 << 8) | 31;
ASSERT_OK(TYIntegerSetValue(hDevice, "GevMCDA", ip));
int64_t mcda = 0;
ASSERT_OK(TYIntegerGetValue(hDevice, "GevMCDA", &mcda));
printf("MCDA: %d.%d.%d.%d\n",
(mcda >> 24) & 0xFF,
(mcda >> 16) & 0xFF,
(mcda >> 8) & 0xFF,
(mcda) & 0xFF);
GevMCPHostPort 事件消息目标端口号
事件消息的目标端口号,相机将消息发送至此端口。OpenDevice 时自动配置,亦可自行设置。
ASSERT_OK(TYIntegerSetValue(hDevice, "GevMCPHostPort", 7001));
int64_t mcp = 0;
ASSERT_OK(TYIntegerGetValue(hDevice, "GevMCPHostPort", &mcp));
printf("GevMCPHostPort: %d\n", (int)mcp);
相机标定相关属性说明
readCalibData() 获取指定组件的标定参数
该接口定义在 genicam_utils.hpp 中,位于 {Camport4 SDK下载路径}/camport4/sample/sample_genicam_sfnc 示例文件夹下。使用时需在代码中包含该头文件:
#include "genicam_utils.hpp"
TY_CAMERA_CALIB_INFO depth_calib;
ASSERT_OK(readCalibData(hDevice, "Depth", depth_calib));
读取 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;
按照索引读取标定参数
IntrinsicValueSelector 读取内参索引值
按照索引读取 Sensor 内参中指定的数据,支持读取:Fx、Fy、Cx、Cy。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Depth"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "IntrinsicValueSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "IntrinsicValueSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetString(hDevice, "IntrinsicValueSelector", _cnt_entry[i].name));
double value = 0;
int error = TYFloatGetValue(hDevice, "IntrinsicValue", &value);
if (error == 0) {
printf("*************%s %2f **************\n", _cnt_entry[i].name, value);
} else {
printf("Read %s failed :%d\n", _cnt_entry[i].name, error);
}
}
RectifiedIntrinsicValueSelector 读取矫正后内参索引值
按照索引读取 Sensor 矫正后内参中指定的数据,支持读取:Fx、Fy、Cx、Cy。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Right"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "RectifiedIntrinsicValueSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "RectifiedIntrinsicValueSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetString(hDevice, "RectifiedIntrinsicValueSelector", _cnt_entry[i].name));
double value = 0;
int error = TYFloatGetValue(hDevice, "RectifiedIntrinsicValue", &value);
if (error == 0) {
printf("*************%s %2f **************\n", _cnt_entry[i].name, value);
} else {
printf("Read %s failed :%d\n", _cnt_entry[i].name, error);
}
}
RotationValueSelector 读取旋转矩阵索引值
按照索引读取 Sensor 旋转矩阵中指定的数据,支持读取:R11、R12、R13、R21、R22、R23、R31、R32、R33。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Right"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "RotationValueSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "RotationValueSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetString(hDevice, "RotationValueSelector", _cnt_entry[i].name));
double value = 0;
int error = TYFloatGetValue(hDevice, "RotationValue", &value);
if (error == 0) {
printf("*************%s %2f **************\n", _cnt_entry[i].name, value);
} else {
printf("Read %s failed :%d\n", _cnt_entry[i].name, error);
}
}
DistortionValueSelector 读取畸变参数索引值
按照索引读取 Sensor 畸变参数中指定的数据,支持读取:K1、K2、P1、P2、K3、K4、K5、K6、S1、S2、S3、S4。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Right"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "DistortionValueSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "DistortionValueSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetString(hDevice, "DistortionValueSelector", _cnt_entry[i].name));
double value = 0;
int error = TYFloatGetValue(hDevice, "DistortionValue", &value);
if (error == 0) {
printf("*************%s %2f **************\n", _cnt_entry[i].name, value);
} else {
printf("Read %s failed :%d\n", _cnt_entry[i].name, error);
}
}
ExtrinsicValueSelector 读取外参矩阵索引值
按照索引读取 Sensor 外参矩阵中指定的数据,支持读取:R11、R12、R13、Tx、R21、R22、R23、Ty、R31、R32、R33、Tz、E41、E42、E43、E44。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Left"));
uint32_t _cnt = 0;
ASSERT_OK(TYEnumGetEntryCount(hDevice, "ExtrinsicValueSelector", &_cnt));
std::vector<TYEnumEntry> _cnt_entry(_cnt);
ASSERT_OK(TYEnumGetEntryInfo(hDevice, "ExtrinsicValueSelector", _cnt_entry.data(), _cnt, &_cnt));
for (int i = 0; i < _cnt; i++) {
ASSERT_OK(TYEnumSetString(hDevice, "ExtrinsicValueSelector", _cnt_entry[i].name));
double value = 0;
int error = TYFloatGetValue(hDevice, "ExtrinsicValue", &value);
if (error == 0) {
printf("*************%s %2f **************\n", _cnt_entry[i].name, value);
} else {
printf("Read %s failed :%d\n", _cnt_entry[i].name, error);
}
}