Read point cloud data based on field name
reads the point field from the
fielddata = readField(
pcloud, specified by
fieldname and returns it in
fieldname does not exist, the function displays an error. To
preserve the structure of the point cloud data, see Preserving Point Cloud Structure.
Load sample ROS messages including a ROS point cloud message,
'x' field name available on the point cloud message.
x = readField(ptcloud,'x');
pcloud— Point cloud
Point cloud, specified as a
PointCloud2 object handle for a
sensor_msgs/PointCloud2 ROS message.
fieldname— Field name of point cloud data
Field name of point cloud data, specified as a string scalar or character vector. This string
must match the field name exactly. If
not exist, the function displays an error.
fielddata— List of field values from point cloud
List of field values from point cloud, returned as a matrix. Each row of the matrix is a point
cloud reading, where n is the number of points and
c is the number of values for each point. If the
point cloud object being read has the
PreserveStructureOnRead property set to true, the
points are returned as an
matrix. For more information, see Preserving Point Cloud Structure.
Point cloud data can be organized in either 1-D lists or in 2-D image styles. 2-D image styles
usually come from depth sensors or stereo cameras. The input
PointCloud2 object contains a
property that is either
Suppose you set the property to
pcloud.PreserveStructureOnRead = true;
Now calling any read functions (
readField) preserves the organizational
structure of the point cloud. When you preserve the structure, the output matrices are
of size m-by-n-by-d, where
m is the height, n is the width, and
d is the number of return values for each point. Otherwise, all
points are returned as a x-by-d list. This
structure can be preserved only if the point cloud is organized.