Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
pcl::ASCIIReader Class Reference

Ascii Point Cloud Reader. More...

#include <pcl/io/ascii_io.h>

+ Inheritance diagram for pcl::ASCIIReader:
+ Collaboration diagram for pcl::ASCIIReader:

Public Member Functions

 ASCIIReader ()
 
 ~ASCIIReader () override
 
int readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &file_version, int &data_type, unsigned int &data_idx, const int offset=0) override
 Read a point cloud data header from a FILE file. More...
 
int read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &file_version, const int offset=0) override
 Read a point cloud data from a FILE file and store it into a pcl/PCLPointCloud2. More...
 
template<typename PointT >
void setInputFields ()
 Set the ascii file point fields. More...
 
void setInputFields (const std::vector< pcl::PCLPointField > &fields)
 Set the ascii file point fields using a list of fields. More...
 
void setSepChars (const std::string &chars)
 Set the Separating characters for the ascii point fields 2. More...
 
void setExtension (const std::string &ext)
 Set the extension of the ascii point file type. More...
 
virtual int read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &file_version, const int offset=0)=0
 Read a point cloud data from a FILE 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 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...
 
- Public Member Functions inherited from pcl::FileReader
 FileReader ()=default
 empty constructor More...
 
virtual ~FileReader ()=default
 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...
 

Protected Member Functions

int parse (const std::string &token, const pcl::PCLPointField &field, std::uint8_t *data_target)
 Parses token based on field type. More...
 
std::uint32_t typeSize (int type)
 Returns the size in bytes of a point field type. More...
 

Protected Attributes

std::string sep_chars_ {", \n\r\t"}
 
std::string extension_ {".txt"}
 
std::vector< pcl::PCLPointFieldfields_
 
std::string name_ {"AsciiReader"}
 

Detailed Description

Ascii Point Cloud Reader.

Read any ASCII file by setting the separating characters and input point fields.

Author
Adam Stambler (adast.nosp@m.a@gm.nosp@m.ail.c.nosp@m.om)

Definition at line 55 of file ascii_io.h.

Constructor & Destructor Documentation

◆ ASCIIReader()

pcl::ASCIIReader::ASCIIReader ( )

◆ ~ASCIIReader()

pcl::ASCIIReader::~ASCIIReader ( )
override

Member Function Documentation

◆ parse()

int pcl::ASCIIReader::parse ( const std::string &  token,
const pcl::PCLPointField field,
std::uint8_t *  data_target 
)
protected

Parses token based on field type.

Parameters
[in]tokenstring representation of point fields
[in]fieldtoken point field type
[out]data_targetaddress that the point field data should be assigned to returns the size of the parsed point field in bytes

◆ read() [1/4]

int pcl::FileReader::read
inline

Read a point cloud data from a FILE file (FILE_V6 only!) and store it into a pcl/PCLPointCloud2.

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

FILE_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 in the file where to expect the true header to begin. One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple 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).

Definition at line 124 of file file_io.h.

◆ read() [2/4]

int pcl::ASCIIReader::read ( const std::string &  file_name,
pcl::PCLPointCloud2 cloud,
Eigen::Vector4f &  origin,
Eigen::Quaternionf &  orientation,
int &  file_version,
const int  offset = 0 
)
overridevirtual

Read a point cloud data from a FILE 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 > FILE_V7 - null if not present)
[out]orientationthe sensor acquisition orientation (only for > FILE_V7 - identity if not present)
[out]file_versionthe FILE version of the file (either FILE_V6 or FILE_V7)
[in]offsetthe offset in the file where to expect the true header to begin. One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple 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).

Implements pcl::FileReader.

◆ read() [3/4]

virtual int pcl::FileReader::read

Read a point cloud data from a FILE 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 > FILE_V7 - null if not present)
[out]orientationthe sensor acquisition orientation (only for > FILE_V7 - identity if not present)
[out]file_versionthe FILE version of the file (either FILE_V6 or FILE_V7)
[in]offsetthe offset in the file where to expect the true header to begin. One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple 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).

◆ read() [4/4]

template<typename PointT >
int pcl::FileReader::read ( typename PointT  )
inline

Read a point cloud data from any FILE 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 in the file where to expect the true header to begin. One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple 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).

Definition at line 142 of file file_io.h.

◆ readHeader()

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

Read a point cloud data header from a FILE file.

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

Returns:

  • < 0 (-1) on error
  • > 0 on success
    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 > FILE_V7 - null if not present)
    [out]orientationthe sensor acquisition orientation (only for > FILE_V7 - identity if not present)
    [out]file_versionthe FILE version of the file (either FILE_V6 or FILE_V7)
    [out]data_typethe type of data (binary data=1, ascii=0, etc)
    [out]data_idxthe offset of cloud data within the file
    [in]offsetthe offset in the file where to expect the true header to begin. One usage example for setting the offset parameter is for reading data from a TAR "archive containing multiple 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).

Implements pcl::FileReader.

◆ setExtension()

void pcl::ASCIIReader::setExtension ( const std::string &  ext)
inline

Set the extension of the ascii point file type.

Parameters
[in]extextension (example : ".txt" or ".xyz" )

Definition at line 128 of file ascii_io.h.

◆ setInputFields() [1/2]

template<typename PointT >
void pcl::ASCIIReader::setInputFields

Set the ascii file point fields.

Definition at line 47 of file ascii_io.hpp.

References fields_, and typeSize().

◆ setInputFields() [2/2]

void pcl::ASCIIReader::setInputFields ( const std::vector< pcl::PCLPointField > &  fields)

Set the ascii file point fields using a list of fields.

Parameters
[in]fieldsis a list of point fields, in order, in the input ascii file

◆ setSepChars()

void pcl::ASCIIReader::setSepChars ( const std::string &  chars)

Set the Separating characters for the ascii point fields 2.

Parameters
[in]charsstring of separating characters Sets the separating characters for the point fields. The default separating characters are " \n\t,"

◆ typeSize()

std::uint32_t pcl::ASCIIReader::typeSize ( int  type)
protected

Returns the size in bytes of a point field type.

Parameters
[in]typepoint field type returns the size of the type in bytes

Referenced by setInputFields().

Member Data Documentation

◆ extension_

std::string pcl::ASCIIReader::extension_ {".txt"}
protected

Definition at line 132 of file ascii_io.h.

◆ fields_

std::vector<pcl::PCLPointField> pcl::ASCIIReader::fields_
protected

Definition at line 133 of file ascii_io.h.

Referenced by setInputFields().

◆ name_

std::string pcl::ASCIIReader::name_ {"AsciiReader"}
protected

Definition at line 134 of file ascii_io.h.

◆ sep_chars_

std::string pcl::ASCIIReader::sep_chars_ {", \n\r\t"}
protected

Definition at line 131 of file ascii_io.h.


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