← Xvisio SDK 深度
← Xvisio 功能介绍和快速启动
← Xvisio SDK 文档主页
Xvisio SeerSense™ DS80 系列模组产品会使用到此类型 TOF Camera,其他产品可以参考对应的数据手册来确认 TOF Camera 类型。SONY 类型 TOF Camera 使用的也是 iTOF 算法 ,波长为940nm 。
SONY 类型 TOF Camera 可以支持多种工作模式以应对不同的主机处理能力和应用场景:
工作模式 | 描述 |
---|---|
IQ | Xvisio 设备端只做 IQ 计算,其余算法处理在主机 Xvisio SDK 中完成,此模式下的帧率取决于主机的性能。 |
M2 | Xvisio 设备端做 IQ 计算和 iq_to_depth 计算(包括一些过滤器:空间过滤器、时间过滤器、epsilion iq 过滤器),其余过程在主机 Xvisio SDK 中处理。 |
Labelize | 几乎完整的raw to depth处理在 Xvisio 设备端完成,主机 Xvisio SDK 只做了 labelize 处理。 |
工作模式类型定义:
enum class SonyTofLibMode { IQMIX_DF ,IQMIX_SF, LABELIZE_DF ,LABELIZE_SF ,M2MIX_DF ,M2MIX_SF };
支持单频 60MHz 或者双频 20MHz/120MHz ,所有的工作模式都能支持这两种调制频率,通常工作距离2米内建议使用单频模式,工作距离大于2米建议使用双频模式。双频下距离更远精度更高,单频的数据带宽和负载更低,具体参数请参考产品数据手册。
调制频率定义:
enum class SonyTofLibMode { IQMIX_DF ,IQMIX_SF, LABELIZE_DF ,LABELIZE_SF ,M2MIX_DF ,M2MIX_SF };
调制频率模式和工作模式共用一个类型。
支持两种分辨率:
所有的工作模式都能支持这两种分辨率。
分辨率类型定义:
enum class Resolution{ Unknown = -1,VGA = 0 ,QVGA ,HQVGA};
注意:SONY 类型 TOF 不支持HQVGA。
可以设置帧率,范围在5-30 fps ,但是受限于不同工作模式下的算力带宽负载限制,只有对应帧率可以达到设置要求才设置生效,对应的帧率请查看表格:
工作模式 | 调制频率模式 | 分辨率 | 帧率(fps) | USB 带宽(最大) |
---|---|---|---|---|
IQ | 双频 | VGA | 20-30 | 1132Mbps |
IQ | 单频 | VGA | 30 | 566Mbps |
M2 | 双频 | VGA | 5 | 264Mbps |
M2 | 单频 | VGA | 13 | 245Mbps |
Labelize | 双频 | VGA | 7 | 33Mbps |
Labelize | 单频 | VGA | 3 | 14Mbps |
IQ | 双频 | QVGA | 30 | 285Mbps |
IQ | 单频 | QVGA | 30 | 143Mbps |
M2 | 双频 | QVGA | 16 | 76Mbps |
M2 | 单频 | QVGA | 30 | 143Mbps |
Labelize | 双频 | QVGA | 13 | 15.2Mbps |
Labelize | 单频 | QVGA | 23 | 27Mbps |
用户根据使用场景和需求选择不同模式和设置。
帧率类型定义:
enum class Framerate{ FPS_5 ,FPS_10 ,FPS_15 ,FPS_20 ,FPS_25 ,FPS_30 };
Xvisio SDK提供了一个API可以同时设置 “工作模式”、“调制频率模式”、“分辨率”、“帧率” :
device->tofCamera()->setSonyTofSetting(xv::TofCamera::SonyTofLibMode::IQMIX_DF,
xv::TofCamera::Resolution::VGA,
xv::TofCamera::Framerate::FPS_30);
具体code参考demo-api.cpp(case 11),demo-api 。
Xvisio SDK 提供了一个可以替换当前 TOF 算法库所使用的 Filter 设置文件,如果您想使用此功能需要对 TOF 算法库的 Filter 格式及功能有一定的了解。
接口原型:
void setFilterFile(std::string filePath)
调用示例:
device->tofCamera()->setSonyTofSettingsetFilterFile("filterfile.bin");
SONY类型的 TOF 深度数据格式支持16位深度数据,单位毫米,并能够支持 IR 灰度数据。
/**
* @brief An image provided by a TOF camera.
* @note There are two manufacturers of TOF camera, Pmd and sony.
* Pmd TOF depth type is Depth_32,sony TOF depth type is Depth_16.
* Cloud type just use for Pmd point cloud,the coordinate system of the point cloud is the camera coordinate system, and the data unit is meters.
* Length, width and depth are in meters use Pmd TOF.
* Length, width and depth are in metmillimeterers use sony TOF.
*/
struct DepthImage {
enum class Type { Depth_16 = 0, Depth_32, IR, Cloud, Raw, Eeprom, IQ };
Type type = Type::Depth_32;
std::size_t width = 0; //!< width of the image (in pixel)
std::size_t height = 0; //!< height of the image (in pixel)
double confidence = 0.0; //!< confidence of depth [0.0,1.0]
std::shared_ptr<const std::uint8_t> data = nullptr; //! image of depth
unsigned int dataSize = 0;
double hostTimestamp = std::numeric_limits<double>::infinity(); //!< host timestamp of the physical measurement (in second based on the `std::chrono::steady_clock`).
std::int64_t edgeTimestampUs = (std::numeric_limits<std::int64_t>::min)(); //!< timestamp of the physical measurement (in microsecond based on edge clock).
/**
* @brief Convert to a #xv::RgbImage
*/
RgbImage toRgb() const;
};
说明:
使用注册回调方式获取 DepthImage,接口调用流程如下所示:
Xvisio SDK 提供了 API 可以把深度数据转换为点云数据格式。
/**
* @brief A point cloud of 3D points.
*/
struct PointCloud {
double hostTimestamp = std::numeric_limits<double>::infinity(); //!< host timestamp of ? (in second based on the `std::chrono::steady_clock`).
std::int64_t edgeTimestampUs = (std::numeric_limits<std::int64_t>::min)(); //!< timestamp of ? (in microsecond based on edge clock).
std::vector<Vector3f> points;
};
说明:
获取 PointCloud 必须要先获取 DepthImage,然后再调用接口做转换,流程如下:
device->tofCamera()->depthImageToPointCloud(tofDepthImage)
std::shared_ptr<xv::Device> device = nullptr;
auto device_list = xv::getDevices(10., "");
if (device_list.empty())`
{
LOG(LOG_Function,"initDevice faiiled:Timeout for device detection.");
return false;
}
device = device_list.begin()->second;
bool ret = m_xvDevice->tofCamera()->setSonyTofSetting(xv::TofCamera::SonyTofLibMode::IQMIX_SF,
xv::TofCamera::Resolution::VGA,
xv::TofCamera::Framerate::FPS_30);
if(!ret)
{
std::cout<<"set TOF Setting failed"<<std::endl;
}
int tofId = -1;
tofId = device->tofCamera()->registerCallback([&](xv::DepthImage const & tofDepthImage){
if (tof.type == xv::DepthImage::Type::Depth_16 ) {
//Operation on tofDepthImage
//...
//point cloud process
if(enableDevMap["tof_point_cloud"])
{
auto points = device->tofCamera()->depthImageToPointCloud(tofDepthImage)->points;
for (auto iter = points.begin(); iter != points.end();iter++)
{
auto point = *iter;
printf(buff, "x=%f ,y=%f ,z=%f\n", point[0], point[1], point[2]);
//...
}
}
}
else if(tof.type == xv::DepthImage::Type::IR )
{
//Operation on tofDepthImage
//...
}
});
//start tof
device->tofCamera()->start();
device->tofCamera()->unregisterCallback(tofId);
device->tofCamera()->stop();