This tutorial covers how to use the template class yarp::sig::PointCloud with pcl::PointCloud and stand alone.
A point cloud is a set of data points in a pre-defined coordinate system.
In a three-dimensional coordinate system, these points are usually defined by X, Y, and Z coordinates, and often are intended to represent the external surface of an object.
A point cloud can also contain other kinds of information such as the normals, the RGB, etc.
In YARP we support these point types:
These structures have been created to be compatible with the PCL's ones.
This code snippet shows how to send and then receive a yarp::sig::PointCloud through the YARP ports.
Note:** in this example, the type of the testPC
and inCloud
is the same but it is NOT mandatory.
If the type of the input yarp::sig::PointCloud is different, only the fields in common with the output type will be actually read, the missing ones will be set to default values.
For example, if you write a yarp::sig::PointCloud<yarp::sig::DataXYZRGBA>
and you want to read through a yarp::sig::PointCloud<yarp::sig::DataXYZNormal>
:
XYZ
fields will be filledNormal
fields will be set to defaultRGBA
will be ignoredThe flexibility on types has been implemented also for what concerns the initialization of the point cloud (copy constructor and assignment operator):
In this case pc3
will have only the XYZ
and Normal
values of pc1
because the RGBA
values have been lost in the construction of pc2
that not contains the RGBA
field.
YARP provides two functions that allow to compute yarp::sig::PointCloud
s given depth image and intrinsic parameters of the camera.
They are included in yarp/sig/PointCloudUtils.h
and they are:
Both functions assume that the images are already undistorted, no undistortion is performed.
yarp::sig::utilsdepthRgbToPC
needs also the colored frame in order to generate a colored PointCloud. It assumes that the the two frames are aligned.
You have to use intrinsics parameters of the depth sensor if the depth frame IS NOT aligned with the colored one. On the other hand use the intrinsic parameters of the RGB camera if the frames are aligned.
Here an example of usage:
Or:
The yarp::sig::PointCloud class has been implemented to be compatible with Point Cloud Library (PCL).
libYARP_pcl
makes yarp::sig::PointCloud compatible with PCL, and it is compiled if PCL is found during the YARP
configuration.
This library has two methods to transform between the two point clouds toPcl<T,T1>(...)
and fromPcl<T,T1>(...)
that can be used as follow
Note that these conversions (PCL -> YARP, YARP -> PCL) are made through a copy.
The YARP_pcl
library has also methods to save/load yarp point clouds to PCD files. These functions savePCD<T,T1>(...)
and loadPCD<T,T1>(...)
can be used as follows:
Note that these functions implicitly convert to and from PCL types.