← Xvisio SDK Depth
← Xvisio Features and Quick Start
← Xvisio SDK Documentation Home Page
TOF will be widely used with Xvisio SeerSense™ GR45 and SeerLens™ One glass Pro modules. Refer to the corresponding datasheet of other modules to confirm the type of TOF camera. The PMD TOF camera also uses the iTOF algorithm, with a wavelength of 940nm.
Xvisio SDK provides three modes to apdat to different appplication. System will automatically adapt to the corresponding frequency mode, frame rate and exposure time after setting the mode:
Work Mode | Frequency Mode | Frame Rate | Exposure Time | Description |
---|---|---|---|---|
Short-distance | Singal-frequency | 30fps | 250us | It is suitable for the working scenes that need to be refreshed quickly within a distance of 1 meter, such as gesture or face recognition. |
Middle-distance | Double-frequency | 15fps | 450us | It is suitable for the working scenes that need to be refreshed quickly within a distance of 2 meters, such as object scanning and detection. |
Long-distance | Double-frequency | 5fps | 1200us | It is suitable for the working scenes with low refresh rate within a distance of 4 meters, such as 3D reconstruction. |
Work mode definition:
enum class DistanceMode { Short = 0, Middle, Long };
Set API examples:
device->tofCamera()->setDistanceMode(TofCamera::DistanceMode::Short);
Xvisio SDK provides a setting interface to set data stream mode. Different mode corresponds to different data stream types or combinations.
Data stream mode | Description |
---|---|
DepthOnly | Only output septh data streams |
CloudOnly | Only output cloud data streams (camera coordinate system) |
DepthAndCloud | Output depth and point cloud data streams simultaneously (camera coordinate system) |
None | No data stream output |
CloudOnLeftHandSlam | Only output point cloud data flow, the coordinate system is converted to SLAM coordinate system (left hand) |
Definition:
enum class StreamMode { DepthOnly = 0, CloudOnly, DepthAndCloud, None, CloudOnLeftHandSlam};
Set API Examples:
device->tofCamera()->setStreamMode(TofCamera::StreamMode::DepthAndCloud);
Xvisio SDK does't open the setting interface of modulation frequency" setting interface for PMD TOF camera. The corresponding single and dual frequency mode can only be selected by setting the working mode.
Xvisio SDK doesn't open the resolution setting for PMD TOF camera, the dafault resolution is 224*172.
The frame rates can be set with a range of 5-30FPS. Please check the table for the exposure time corresponding to different frame rates:
Frame Rate | Exposure Time |
---|---|
5fps | 2000us |
10fps | 1080us |
15fps | 720us |
20fps | 540us |
25fps | 440us |
30fps | 360us |
Users can choose different modes and settings according to usage scenarios and nrequirements.
Set API Examples:
device->tofCamera()->setFramerate(30.0f);
The frame rate value of parameter transmission is float type, with a range of 5-30.
The data volume of PMD TOF is relatively small. Here are different data type bandwidths under 30fps:
Data | Bandwidth |
---|---|
Depth | 35.2Mbps |
Cloud | 105.8Mbps |
IR | 17.6Mbps |
PMD TOF can enable or disable IR data stream output. It is default that IR data stream can't be output.
It is set by HID command. IR enable command: “0x02,0x10,0xf5,0x02,0x01”,IR disable command: “0x02,0x10,0xf5,0x02,0x00” .
Set API Examples:
std::vector<unsigned char> result(63);
bool bOK = device->hidWriteAndRead({0x02,0x10,0xf5,0x02,0x01}, result);
if(bOK)
std::cout << "Enable IR successfully" << std::endl;
else
std::cout << "Enable IR failed" << std::endl;
PMD TOF depth data and point cloud data are 32-bit depth data with a unit of meter which also support IR gray data.
/**
* @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;
};
Notes:
Get DepthImage by register callback way. The interface call process is as follows:
Xvisio SDK provides API which can convert depth data to point cloud data format.
Section 3 introduces that if point cloud data is directly obtained in DepthImage, this method is reported on the Xvisio device side. It also supports the API introduced in this section to convert depth data into point cloud data format.
Both of the methods can be used, and users can choose one of them.
/**
* @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;
};
Notes:
To convert Pointcloud, firstly you should obtain the DepthImage, and then call the interface for conversion. The process is as follows:
device->tofCamera()->depthImageToPointCloud(tofDepthImage)
Define Xvisio Device
std::shared_ptr<xv::Device> device = nullptr;
Read device_list, set timeout value to 10 seconds(recommonds value which can be shorten.)
auto device_list = xv::getDevices(10., "");
Judge whether the obtained device is empty. It fails if it is empty.
if (device_list.empty())`
{
LOG(LOG_Function,"initDevice faiiled:Timeout for device detection.");
return false;
}
Get device(only for single equipment, please refer to the corresponding document description for multiple equipments.)
device = device_list.begin()->second;
Register callback. Get depth data or IR data and point cloud data in the callback definition.
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
//...
}
else if(tof.type == xv::DepthImage::Type::Cloud )
{
//Operation on tofDepthImage
//...
}
});
Start TOF
//start tof
device->tofCamera()->start();
Stop TOF
The tofId used here is the value assigned when registering callback.
device->tofCamera()->unregisterCallback(tofId);
device->tofCamera()->stop();
← Xvisio SDK Depth
← Xvisio Features and Quick Start
← Xvisio SDK Documentation Home Page