API 及属性说明
SDK 4.x.x 版本兼容并实现了 GenICam 标准规范的核心功能模块,包含标准特征命名规范、统一的参数访问接口等等。
取图流程 API
库加载
ASSERT_OK( TYInitLib() );
获取 SDK 版本信息
TY_VERSION_INFO ver;
ASSERT_OK( TYLibVersion(&ver) );
LOGD(" - lib version: %d.%d.%d", ver.major, ver.minor, ver.patch);
更新接口状态
LOGD("Update interface list");
ASSERT_OK( TYUpdateInterfaceList() );
获取接口数量
uint32_t n = 0;
ASSERT_OK( TYGetInterfaceNumber(&n) );
LOGD("Got %u interface list", n);
获取接口列表
std::vector<TY_INTERFACE_INFO> ifaces(n);
ASSERT_OK( TYGetInterfaceList(&ifaces[0], n, &n) );
ASSERT( n == ifaces.size() );
for(uint32_t i = 0; i < n; i++)
{
LOGI("Found interface %u:", i);
LOGI(" name: %s", ifaces[i].name);
LOGI(" id: %s", ifaces[i].id);
LOGI(" type: 0x%x", ifaces[i].type);
if(TYIsNetworkInterface(ifaces[i].type))
{
LOGI(" MAC: %s", ifaces[i].netInfo.mac);
LOGI(" ip: %s", ifaces[i].netInfo.ip);
LOGI(" netmask: %s", ifaces[i].netInfo.netmask);
LOGI(" gateway: %s", ifaces[i].netInfo.gateway);
LOGI(" broadcast: %s", ifaces[i].netInfo.broadcast);
}
}
打开接口
如网卡 MAC 地址为:88-a4-c2-b1-35-e3,IP地址为:192.168.6.45 (对应16进制的小端存储为2d06a8c0),则指定网卡时需要写成 “eth-88-a4-c2-b1-35-e32d06a8c0”,注意区分大小写。
char* iface_id = "eth-88-a4-c2-b1-35-e32d06a8c0";
ASSERT_OK(TYOpenInterface(iface_id, &hIface));
更新设备列表
设备信息包含以下数据:
typedef struct TY_DEVICE_BASE_INFO
{
TY_INTERFACE_INFO iface;
char id[32];///<device serial number
char vendorName[32];
char userDefinedName[32];
char modelName[32];///<device model name
TY_VERSION_INFO hardwareVersion; ///<deprecated
TY_VERSION_INFO firmwareVersion;///<deprecated
union {
TY_DEVICE_NET_INFO netInfo;
TY_DEVICE_USB_INFO usbInfo;
};
char buildHash[256];
char configVersion[256];
char reserved[256];
}TY_DEVICE_BASE_INFO;
获取设备数量
uint32_t n = 0;
TYGetDeviceNumber(hIface, &n);
获取设备列表
std::vector<TY_DEVICE_BASE_INFO> devs(n);
TYGetDeviceList(hIface, &devs[0], n, &n);
打开相机
ASSERT_OK( TYOpenDevice(hIface, selectedDev.id, &hDevice) );
获取帧缓冲空间大小
获取当前设备配置需要的帧缓冲空间大小。
uint32_t frameSize;
ASSERT_OK( TYGetFrameBufferSize(hDevice, &frameSize) );
LOGD(" - Get size of framebuffer, %d", frameSize);
分配帧缓冲并入队
把分配的帧缓冲推入缓冲队列。
char* frameBuffer[2] = {0};
LOGD(" - Allocate & enqueue buffers");
frameBuffer[0] = new char[frameSize];
frameBuffer[1] = new char[frameSize];
LOGD(" - Enqueue buffer (%p, %d)", frameBuffer[0], frameSize);
ASSERT_OK( TYEnqueueBuffer(hDevice, frameBuffer[0], frameSize) );
LOGD(" - Enqueue buffer (%p, %d)", frameBuffer[1], frameSize);
ASSERT_OK( TYEnqueueBuffer(hDevice, frameBuffer[1], frameSize) );
开始图像采集
LOGD("Start capture");
ASSERT_OK( TYStartCapture(hDevice) );
数据接收
在指定的时间内等待有效数据帧,指定时间内没有收到数据帧,函数会返回并报告错误状态。设置指定时间的单位:ms。
TYFetchFrame(hDevice, &frame, -1);
停止图像采集
TYStopCapture(hDevice);
清除缓冲队列
TYClearBufferQueue(hDevice);
关闭相机
TYCloseDevice(hDevice);
关闭接口
TYCloseInterface(hIface);
库卸载
TYDeinitLib();
日志设置相关 API
定义:
typedef enum TY_LOG_LEVEL_LIST
{
TY_LOG_LEVEL_VERBOSE = 1,
TY_LOG_LEVEL_DEBUG = 2,
TY_LOG_LEVEL_INFO = 3,
TY_LOG_LEVEL_WARNING = 4,
TY_LOG_LEVEL_ERROR = 5,
TY_LOG_LEVEL_NEVER = 9,
}TY_LOG_LEVEL_LIST;
typedef int32_t TY_LOG_LEVEL;
日志输出级别设置
设置日志系统的输出级别。输出优先级为:VERBOSE ⊃ DEBUG ⊃ INFO ⊃ WARNING ⊃ ERROR
。
// 设置为DEBUG级别
ASSERT_OK(TYSetLogLevel(TY_LOG_LEVEL_DEBUG));
日志前缀设置
为日志添加自定义前缀,方便区分不同来源的日志。
ASSERT_OK(TYSetLogPrefix("PERCIPIO SDK"));
指定级别输出
将指定级别及以下的日志输出到指定文件。
ASSERT_OK(TYAppendLogToFile("test_log.txt", TY_LOG_LEVEL_DEBUG));
使用 TCP 协议发送日志
将指定级别及以下的日志通过 TCP 协议发送至指定服务器。
ASSERT_OK(TYAppendLogToServer("tcp", "192.168.2.70", 8000, TY_LOG_LEVEL_DEBUG));
关闭日志文件输出
关闭日志文件输出并释放相关资源。
ASSERT_OK(TYRemoveLogFile("test_log.txt"));
停止日志发送
断开与日志服务器的 TCP 连接,停止日志发送。
ASSERT_OK(TYRemoveLogServer("tcp", "192.168.2.212", 8000));
参数信息查询 API
获取参数提示信息
char str[1024];
ASSERT_OK(TYParamGetToolTip(hDevice,"Distortion",str,sizeof(str)));
std::cout << "ToolTip:" << str << std::endl;
获取参数描述信息
char str[1024];
ASSERT_OK(TYParamGetDescriptor(hDevice,"Distortion",str,sizeof(str)));
std::cout << "Descriptor:" << str << std::endl;
获取参数用于显示的名称
char str[1024];
ASSERT_OK(TYParamGetDisplayName(hDevice,"Distortion",str,sizeof(str)));
std::cout << "DisplayName:" << str << std::endl;
获取参数数据类型
定义:
enum ParamType {
Command,
Integer,
Float,
Boolean,
Enumeration,
String,
ByteArray,
};
获取参数数据类型方法如下:
ParamType type;
ASSERT_OK(TYParamGetType(hDevice,"UserSetLoad",&type));
printf("Distortion type %d", type);
获取参数读写权限
定义:
typedef enum TY_ACCESS_MODE_LIST :uint32_t
{
TY_ACCESS_READABLE = 0x1,
TY_ACCESS_WRITABLE = 0x2,
}TY_ACCESS_MODE_LIST;
typedef uint8_t TY_ACCESS_MODE;
获取参数读写权限方法如下:
TY_ACCESS_MODE access_mode;
ASSERT_OK(TYParamGetAccess(hDevice, "DeviceFirmwareVersion", &access_mode));
printf("DeviceFirmwareVersion access mode %d\n", access_mode);
获取参数的可见等级
定义:
typedef enum TY_VISIBILITY_TYPE
{
BEGINNER = 0,
EXPERT = 1,
GURU = 2,
INVLISIBLE = 3
}TY_VISIBILITY_TYPE;
获取参数的可见等级方法如下:
TY_VISIBILITY_TYPE visibility;
ASSERT_OK(TYParamGetVisibility(hDevice, "DeviceFirmwareVersion", &visibility));
printf("DeviceFirmwareVersion visibility %d\n", visibility);
DeviceControl 相关属性说明
该模块提供设备(相机)及其传感器的一般信息与控制,主要用于在枚举过程中识别设备并获取传感器分辨率相关信息。此类别还包含与设备整体状态相关的其他信息及控制项。
读取相机固件版本
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;
读取相机硬件版本
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;
读取相机版本
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;
读取相机固件所有信息
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;
读取相机配置版本
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;
读取相机技术型号
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;
读取相机序列号
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;
读取相机制造商名
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;
读取相机制造商信息
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;
读取相机型号名
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;
读取相机生产时间
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;
读取相机标定时间
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;
读取相机网络连接速度
int64_t speed = 0;
ASSERT_OK(TYIntegerGetValue(hDevice, "DeviceLinkSpeed", &speed));
相机对时功能
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", "SyncTypeNTP"));
bool sync_ready = false;
ASSERT_OK(TYBooleanGetValue(hDevice, "TimeSyncAck", &sync_ready));
while (!sync_ready) {
ASSERT_OK(TYBooleanGetValue(hDevice, "TimeSyncAck", &sync_ready));
MSLEEP(10);
}
NTP对时服务器设置
设置 NTP 服务器 IP 后,相机对时模式为 SyncTypeNTP 时,将与指定的服务器进行对时。
ASSERT_OK(TYIntegerSetValue(hDevice, "NTPServerIP", 3232236033));//192.168.2.1
读取相机内部温度
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));
相机心跳功能
DeviceLinkHeartbeatMode
深度相机状态保持。SDK 与相机维持通信状态保持机制。默认为 true。
TYEnumSetValue( hDevice, "DeviceLinkHeartbeatMode", 1);
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);
设备帧接收超时时间
在相机配置完数据流以及分辨率后会自动估算一个时间,当上位机在此时间内没有收到相机的数据流,就会发生超时错误。 当设置值比估算值小时,取估算值。当设置值比估算大时,取设置值。
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+100));
重置设备寄存器
重置 UserSet 属性组参数的寄存器命令,恢复相机到上电时的状态。
- ::
ASSERT_OK(TYCommandExec(hDevice, “DeviceReset”));
AcquisitionControl 相关属性说明
该模块描述了与图像采集相关的所有功能,控制图像或数据的采集过程,如触发模式、帧率等。
获取相机支持的工作模式
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++) {
td::cout << " Name : " << _cnt_entry[i].name << " value : " << _cnt_entry[i].value << std::endl;
}
获取相机支持的触发源
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));
or (int i = 0; i < _cnt; i++) {
td::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"));
触发延迟时间
设置触发信号输入到开始曝光的延迟时间,单位:μ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));
帧率输出控制
设置相机采集图像帧率。
ASSERT_OK(TYEnumSetString(hDevice, "AcquisitionMode", "Continuous"));
ASSERT_OK(TYBooleanSetValue(hDevice, "AcquisitionFrameRateEnable", true));
ASSERT_OK(TYFloatSetValue(hDevice, "AcquisitionFrameRate", 2));
触发输出电平保持时间
在相机输出触发信号后,设置高/低电平的脉冲宽度时长,单位:μ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 相关属性说明
该模块提供传输层控制功能,主要包含数据包大小调整、丢包检测、流控制、带宽限制等功能。
网络最大传输单元大小
网络深度相机数据传输时,分组发送到链路上最大传输单元的大小。
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);
帧间延时
网络上两个物理数据包的发送间隔,用于降低网络数据发送拥塞程度。
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
读取相机 MAC 地址
读取相机 MAC 地址。读出来的值需自行转换成 XX:XX:XX:XX:XX:XX 格式。
int64_t value;
ASSERT_OK(TYIntegerGetValue(hDevice, "GevMACAddress", &value));
图像同步
设置图像是否同步输出。左右图像完全同步时,图像输出帧率低于不完全同步时图像输出帧率。
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);
数据流异步模式
深度相机的灰度图像、彩色图像和深度图像数据输出时,支持立即输出已获取到的图像数据。
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;
int32_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 相关属性说明
该模块阐述了照明控制相关的模型和功能,这些功能可应用于专用照明控制器,或具备集成照明控制功能的相机。
获取相机支持光源
其中,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));
激光器工作模式设置
获激光器支持的工作模式,并设置其工作模式。
其中,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;
int32_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 相关属性说明
该模块主要描述多源采集设备的相关功能特性。以双目相机为例(可见光与红外光传感器),这类设备可通过单一物理接口传输多路数据,同时各传感器仍保持独立的可控功能。
该模块包含深度图像传感器组件(Range)、彩色图像传感器组件(Intensity)、左单色图像传感器组件(BinocularLeft)、右单色图像传感器组件(BinocularRight)。
设置组件下的参数时,需先将 SourceSelector 切换至需要操作的组件下才可进行准确设置。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "BinocularLeft"));
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "BinocularRight"));
获取相机支持的组件
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;
}
图像格式设置
//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
//使能组件
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));
图像分辨率设置
设置图像格式完成后,获取图像支持的分辨率并完成设置。
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,即最优与次优匹配点的差值。 设定值越大,匹配代价越唯一,值越大错误匹配点过滤掉的越多。 |
DepthSgbmHFilterHalfWin |
布尔型 |
搜索滤波开关。 用于进一步优化深度图,去除噪声和不连续性,对物体边缘点云更友好。 |
DepthSgbmMedFilter |
布尔型 |
中值滤波开关。 用于消除孤立的噪声点,同时尽可能地保留图像的边缘信息。 |
DepthSgbmMedFilterThresh |
整型 |
中值滤波阈值。 设定值越大,过滤的噪点越多,但也可能会导致深度图的细节信息丢失。 |
DepthSgbmLRC |
布尔型 |
左右一致性检查开关。 |
DepthSgbmLRCDiff |
整型 |
左右一致性检查参数。 在进行立体匹配时,对于同一物体表面上的像素,左图匹配右图的视差为 LR,右图匹配左图的视差为 RL。当 ABS(LR-RL) < max LRC diff 时,则认为该点是可信匹配点。 左右一致性检查参数设定值越小,匹配越可靠。 |
DepthSgbmTextureFilterThreshold |
整型 |
设置纹理属性阈值。 用于优化深度图边缘检测,降低点云中的噪声与测量误差。 |
对于整型的 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));
深度测量值计算系数
深度图中每个像素的数据值与该系数的乘积可得到实际测得的距离,单位:mm。
该值会影响到最终的深度计算结果。若设定值过小,可能会导致深度计算出现误差。若设定值过大,可能会降低深度计算的精度。
//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
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);
深度有效距离范围设置
深度图中数值小于最小深度有效距离阈值的像素将被置为 0,不参与后续计算。
深度图中数值大于最大深度有效距离阈值的像素将被置为 0,不参与后续计算。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYIntegerSetValue(hDevice, "DepthRangeMin", 500));
ASSERT_OK(TYIntegerSetValue(hDevice, "DepthRangeMax", 1500));
自动曝光控制
图像传感器组件的自动曝光开关。部分深度相机的光学组件支持图像自动曝光。
//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
ASSERT_OK(TYBooleanSetValue(hDevice, "ComponentEnable", true));
ASSERT_OK(TYBooleanSetValue(hDevice, "ExposureAuto", true));
自动白平衡控制
自动白平衡功能适用于彩色图像传感器,通过调整 R、G、B 三个通道的数字增益值实现色彩空间的平衡。若要手动设置 R、G、B 三个通道的数字增益,需先关闭自动白平衡功能,否则自动白平衡功能会与手动设置的 R、G、B 通道数字增益冲突,影响图像效果。
//设置组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
ASSERT_OK(TYBooleanSetValue(hDevice, "BalanceWhiteAuto", true));
自动曝光的目标亮度
在优化高对比度场景的彩色图像成像效果时,目标亮度的调整非常重要。当感兴趣区域相对其他区域过暗时,增加目标亮度,直到可看到该区域的细节。当感兴趣区域相对其他区域过亮时,降低目标亮度,直到可看到该区域的细节。
//设置组件并使能组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
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));
曝光时间
不同图像传感器、不同帧率配置下的曝光时间可调范围不同。设置曝光时间前,如果图像传感器支持自动曝光设置,需要关闭自动曝光设置功能。
//设置组件并使能组件
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
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));
模拟增益
不同图像传感器的模拟增益可调范围不同。设置图像传感器组件的模拟增益时,需要先关闭自动曝光调整功能。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
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));
数字增益
彩色图像传感器模组的数字增益需要通过 R、G、B 三通道独立设置。设置增益时,如果传感器支持自动白平衡设置,需要先关闭自动白平衡功能。
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Intensity"));
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] --- %d\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("DigitalRed : [%f,%f] --- %d\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("DigitalRed : [%f,%f] --- %d\n", min, max, value);
ASSERT_OK(TYFloatSetValue(hDevice, "Gain", max));
畸变矫正开关
单色图像传感器组件默认输出未做畸变矫正的图像数据。
ASSERT_OK(TYBooleanSetValue(hDevice, "IRUndistortion", true));
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 属性组
//读相机支持加载 UserSet 的数量。
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;
}
}
//选择要加载的 UserSet
ASSERT_OK(TYEnumSetValue(hDevice, "UserSetSelector", _cnt_entry[0].value));
//加载 UserSet
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));
相机标定相关属性说明
读取 Sensor 宽/高
int64_t width, height;
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
ASSERT_OK(TYIntegerGetValue(hDevice, "IntrinsicWidth", &width));
ASSERT_OK(TYIntegerGetValue(hDevice, "IntrinsicHeight", &height));
读取内参矩阵
ASSERT_OK(TYEnumSetString(hDevice, "SourceSelector", "Range"));
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", "BinocularLeft"));
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", "Intensity"));
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", "BinocularLeft"));
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", "BinocularLeft"));
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;