Point Cloud Library (PCL)  1.7.1
List of all members | Public Types | Public Member Functions
pcl::PCDReader Class Reference

Point Cloud Data (PCD) file format reader. More...

#include <pcl/io/pcd_io.h>

+ Inheritance diagram for pcl::PCDReader:

Public Types

enum  { PCD_V6 = 0, PCD_V7 = 1 }
 Various PCD file versions. More...
 

Public Member Functions

 PCDReader ()
 Empty constructor. More...
 
 ~PCDReader ()
 Empty destructor. More...
 
int readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, int &data_type, unsigned int &data_idx, const int offset=0)
 Read a point cloud data header from a PCD file. More...
 
int readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
 Read a point cloud data header from a PCD file. More...
 
int read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset=0)
 Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2. More...
 
int read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
 Read a point cloud data from a PCD (PCD_V6) and store it into a pcl/PCLPointCloud2. More...
 
template<typename PointT >
int read (const std::string &file_name, pcl::PointCloud< PointT > &cloud, const int offset=0)
 Read a point cloud data from any PCD file, and convert it to the given template format. More...
 
- Public Member Functions inherited from pcl::FileReader
 FileReader ()
 empty constructor More...
 
virtual ~FileReader ()
 empty destructor More...
 
int read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
 Read a point cloud data from a FILE file (FILE_V6 only!) and store it into a pcl/PCLPointCloud2. More...
 
template<typename PointT >
int read (const std::string &file_name, pcl::PointCloud< PointT > &cloud, const int offset=0)
 Read a point cloud data from any FILE file, and convert it to the given template format. More...
 

Detailed Description

Point Cloud Data (PCD) file format reader.

Author
Radu B. Rusu

Definition at line 52 of file pcd_io.h.

Member Enumeration Documentation

anonymous enum

Various PCD file versions.

PCD_V6 represents PCD files with version 0.6, which contain the following fields:

  • lines beginning with # are treated as comments
  • FIELDS ...
  • SIZE ...
  • TYPE ...
  • COUNT ...
  • WIDTH ...
  • HEIGHT ...
  • POINTS ...
  • DATA ascii/binary

Everything that follows DATA is intepreted as data points and will be read accordingly.

PCD_V7 represents PCD files with version 0.7 and has an important addon: it adds sensor origin/orientation (aka viewpoint) information to a dataset through the use of a new header field:

  • VIEWPOINT tx ty tz qw qx qy qz
Enumerator
PCD_V6 
PCD_V7 

Definition at line 81 of file pcd_io.h.

Constructor & Destructor Documentation

pcl::PCDReader::PCDReader ( )
inline

Empty constructor.

Definition at line 56 of file pcd_io.h.

pcl::PCDReader::~PCDReader ( )
inline

Empty destructor.

Definition at line 58 of file pcd_io.h.

Member Function Documentation

int pcl::PCDReader::read ( const std::string &  file_name,
pcl::PCLPointCloud2 cloud,
Eigen::Vector4f &  origin,
Eigen::Quaternionf &  orientation,
int &  pcd_version,
const int  offset = 0 
)
virtual

Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2.

Parameters
[in]file_namethe name of the file containing the actual PointCloud data
[out]cloudthe resultant PointCloud message read from disk
[out]originthe sensor acquisition origin (only for > PCD_V7 - null if not present)
[out]orientationthe sensor acquisition orientation (only for > PCD_V7 - identity if not present)
[out]pcd_versionthe PCD version of the file (either PCD_V6 or PCD_V7)
[in]offsetthe offset of where to expect the PCD Header in the file (optional parameter). One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple PCD files: TAR files always add a 512 byte header in front of the actual file, so set the offset to the next byte after the header (e.g., 513).
Returns
  • < 0 (-1) on error
  • == 0 on success

Implements pcl::FileReader.

Referenced by pcl::outofcore::OutofcoreOctreeDiskContainer< PointT >::insertRange(), pcl::io::loadPCDFile(), pcl::LineRGBD< PointXYZT, PointRGBT >::loadTemplates(), and pcl::outofcore::OutofcoreOctreeDiskContainer< PointT >::readRange().

int pcl::PCDReader::read ( const std::string &  file_name,
pcl::PCLPointCloud2 cloud,
const int  offset = 0 
)

Read a point cloud data from a PCD (PCD_V6) and store it into a pcl/PCLPointCloud2.

Note
This function is provided for backwards compatibility only and it can only read PCD_V6 files correctly, as pcl::PCLPointCloud2 does not contain a sensor origin/orientation. Reading any file

PCD_V6 will generate a warning.

Parameters
[in]file_namethe name of the file containing the actual PointCloud data
[out]cloudthe resultant PointCloud message read from disk
[in]offsetthe offset of where to expect the PCD Header in the file (optional parameter). One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple PCD files: TAR files always add a 512 byte header in front of the actual file, so set the offset to the next byte after the header (e.g., 513).
Returns
  • < 0 (-1) on error
  • == 0 on success
template<typename PointT >
int pcl::PCDReader::read ( const std::string &  file_name,
pcl::PointCloud< PointT > &  cloud,
const int  offset = 0 
)
inline

Read a point cloud data from any PCD file, and convert it to the given template format.

Parameters
[in]file_namethe name of the file containing the actual PointCloud data
[out]cloudthe resultant PointCloud message read from disk
[in]offsetthe offset of where to expect the PCD Header in the file (optional parameter). One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple PCD files: TAR files always add a 512 byte header in front of the actual file, so set the offset to the next byte after the header (e.g., 513).
Returns
  • < 0 (-1) on error
  • == 0 on success

Definition at line 204 of file pcd_io.h.

References pcl::fromPCLPointCloud2(), pcl::read(), pcl::PointCloud< T >::sensor_orientation_, and pcl::PointCloud< T >::sensor_origin_.

int pcl::PCDReader::readHeader ( const std::string &  file_name,
pcl::PCLPointCloud2 cloud,
Eigen::Vector4f &  origin,
Eigen::Quaternionf &  orientation,
int &  pcd_version,
int &  data_type,
unsigned int &  data_idx,
const int  offset = 0 
)
virtual

Read a point cloud data header from a PCD file.

Load only the meta information (number of points, their types, etc), and not the points themselves, from a given PCD file. Useful for fast evaluation of the underlying data structure.

Attention
The PCD data is always stored in ROW major format! The read/write PCD methods will detect column major input and automatically convert it.
Parameters
[in]file_namethe name of the file to load
[out]cloudthe resultant point cloud dataset (only the header will be filled)
[out]originthe sensor acquisition origin (only for > PCD_V7 - null if not present)
[out]orientationthe sensor acquisition orientation (only for > PCD_V7 - identity if not present)
[out]pcd_versionthe PCD version of the file (i.e., PCD_V6, PCD_V7)
[out]data_typethe type of data (0 = ASCII, 1 = Binary, 2 = Binary compressed)
[out]data_idxthe offset of cloud data within the file
[in]offsetthe offset of where to expect the PCD Header in the file (optional parameter). One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple PCD files: TAR files always add a 512 byte header in front of the actual file, so set the offset to the next byte after the header (e.g., 513).
Returns
  • < 0 (-1) on error
  • == 0 on success

Implements pcl::FileReader.

Referenced by pcl::outofcore::OutofcoreOctreeDiskContainer< PointT >::getDataSize(), and pcl::outofcore::OutofcoreOctreeDiskContainer< PointT >::OutofcoreOctreeDiskContainer().

int pcl::PCDReader::readHeader ( const std::string &  file_name,
pcl::PCLPointCloud2 cloud,
const int  offset = 0 
)

Read a point cloud data header from a PCD file.

Load only the meta information (number of points, their types, etc), and not the points themselves, from a given PCD file. Useful for fast evaluation of the underlying data structure.

Attention
The PCD data is always stored in ROW major format! The read/write PCD methods will detect column major input and automatically convert it.
Parameters
[in]file_namethe name of the file to load
[out]cloudthe resultant point cloud dataset (only the header will be filled)
[in]offsetthe offset of where to expect the PCD Header in the file (optional parameter). One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple PCD files: TAR files always add a 512 byte header in front of the actual file, so set the offset to the next byte after the header (e.g., 513).
Returns
  • < 0 (-1) on error
  • == 0 on success

The documentation for this class was generated from the following file: