44 #include <pcl/point_cloud.h>
45 #include <pcl/io/file_io.h>
46 #include <boost/interprocess/sync/file_lock.hpp>
114 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int &pcd_version,
115 int &data_type,
unsigned int &data_idx);
148 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int &pcd_version,
149 int &data_type,
unsigned int &data_idx,
const int offset = 0)
override;
216 int pcd_version,
bool compressed,
unsigned int data_idx);
237 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int &pcd_version,
const int offset = 0)
override;
276 template<
typename Po
intT>
int
282 pcd_version, offset);
315 map_synchronization_ = sync;
325 const Eigen::Vector4f &origin,
326 const Eigen::Quaternionf &orientation);
341 const Eigen::Vector4f &origin,
342 const Eigen::Quaternionf &orientation);
351 const Eigen::Vector4f &origin,
352 const Eigen::Quaternionf &orientation);
361 const Eigen::Vector4f &origin,
362 const Eigen::Quaternionf &orientation);
369 template <
typename Po
intT>
static std::string
371 const int nr_points = std::numeric_limits<int>::max ());
391 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
392 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
393 const int precision = 8);
403 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
404 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
414 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
415 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
429 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
430 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
444 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
445 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity ());
466 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
467 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
468 const bool binary =
false)
override
471 return (writeBinary (file_name, cloud, origin, orientation));
472 return (writeASCII (file_name, cloud, origin, orientation, 8));
492 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
493 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
494 const bool binary =
false)
496 return (
write (file_name, *cloud, origin, orientation, binary));
503 template <
typename Po
intT>
int
504 writeBinary (
const std::string &file_name,
515 template <
typename Po
intT>
int
516 writeBinaryCompressed (
const std::string &file_name,
524 template <
typename Po
intT>
int
525 writeBinary (
const std::string &file_name,
534 template <
typename Po
intT>
int
535 writeASCII (
const std::string &file_name,
537 const int precision = 8);
545 template <
typename Po
intT>
int
546 writeASCII (
const std::string &file_name,
549 const int precision = 8);
564 template<
typename Po
intT>
inline int
565 write (
const std::string &file_name,
567 const bool binary =
false)
570 return (writeBinary<PointT> (file_name, cloud));
571 return (writeASCII<PointT> (file_name, cloud));
588 template<
typename Po
intT>
inline int
589 write (
const std::string &file_name,
595 return (writeBinary<PointT> (file_name, cloud, indices));
596 return (writeASCII<PointT> (file_name, cloud, indices));
606 boost::interprocess::file_lock &lock);
614 boost::interprocess::file_lock &lock);
618 bool map_synchronization_{
false};
636 return (p.
read (file_name, cloud));
649 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
653 return (p.
read (file_name, cloud, origin, orientation, pcd_version));
661 template<
typename Po
intT>
inline int
665 return (p.
read (file_name, cloud));
685 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
686 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
687 const bool binary_mode =
false)
690 return (w.
write (file_name, cloud, origin, orientation, binary_mode));
707 template<
typename Po
intT>
inline int
711 return (w.
write<
PointT> (file_name, cloud, binary_mode));
730 template<
typename Po
intT>
inline int
734 return (w.
write<
PointT> (file_name, cloud,
false));
746 template<
typename Po
intT>
inline int
770 template<
typename Po
intT>
int
774 const bool binary_mode =
false)
778 return (w.
write<
PointT> (file_name, cloud, indices, binary_mode));
791 template<
typename Po
intT>
inline int
801 #include <pcl/io/impl/pcd_io.hpp>
Point Cloud Data (FILE) file format reader interface.
Point Cloud Data (FILE) file format writer.
Point Cloud Data (PCD) file format reader.
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) override
Read a point cloud data header from a PCD file.
int readHeader(std::istream &binary_istream, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, int &data_type, unsigned int &data_idx)
Read a point cloud data header from a PCD-formatted, binary istream.
PCDReader()=default
Empty constructor.
~PCDReader() override=default
Empty destructor.
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.
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.
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset=0) override
Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2.
int readBodyASCII(std::istream &stream, pcl::PCLPointCloud2 &cloud, int pcd_version)
Read the point cloud data (body) from a PCD stream.
int readBodyBinary(const unsigned char *data, pcl::PCLPointCloud2 &cloud, int pcd_version, bool compressed, unsigned int data_idx)
Read the point cloud data (body) from a block of memory.
int readHeader(const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
Read a point cloud data header from a PCD file.
Point Cloud Data (PCD) file format writer.
std::string generateHeaderASCII(const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation)
Generate the header of a PCD file format.
void resetLockingPermissions(const std::string &file_name, boost::interprocess::file_lock &lock)
Reset permissions for file locking (Boost 1.49+).
void setLockingPermissions(const std::string &file_name, boost::interprocess::file_lock &lock)
Set permissions for file locking (Boost 1.49+).
~PCDWriter() override=default
int write(const std::string &file_name, const pcl::PointCloud< PointT > &cloud, const bool binary=false)
Save point cloud data to a PCD file containing n-D points.
int writeBinary(std::ostream &os, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity())
Save point cloud data to a std::ostream containing n-D points, in BINARY format.
int writeBinaryCompressed(std::ostream &os, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity())
Save point cloud data to a std::ostream containing n-D points, in BINARY_COMPRESSED format.
std::string generateHeaderBinary(const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation)
Generate the header of a PCD file format.
int write(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const bool binary=false) override
Save point cloud data to a PCD file containing n-D points.
std::string generateHeaderBinaryCompressed(const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation)
Generate the header of a BINARY_COMPRESSED PCD file format.
int writeBinary(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity())
Save point cloud data to a PCD file containing n-D points, in BINARY format.
int write(const std::string &file_name, const pcl::PCLPointCloud2::ConstPtr &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const bool binary=false)
Save point cloud data to a PCD file containing n-D points.
void setMapSynchronization(bool sync)
Set whether mmap() synchornization via msync() is desired before munmap() calls.
int generateHeaderBinaryCompressed(std::ostream &os, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation)
Generate the header of a BINARY_COMPRESSED PCD file format.
int write(const std::string &file_name, const pcl::PointCloud< PointT > &cloud, const pcl::Indices &indices, bool binary=false)
Save point cloud data to a PCD file containing n-D points.
int writeASCII(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const int precision=8)
Save point cloud data to a PCD file containing n-D points, in ASCII format.
int writeBinaryCompressed(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity())
Save point cloud data to a PCD file containing n-D points, in BINARY_COMPRESSED format.
PointCloud represents the base class in PCL for storing collections of 3D points.
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
int savePCDFileASCII(const std::string &file_name, const pcl::PointCloud< PointT > &cloud)
Templated version for saving point cloud data to a PCD file containing a specific given cloud format.
int savePCDFile(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const bool binary_mode=false)
Save point cloud data to a PCD file containing n-D points.
int savePCDFileBinary(const std::string &file_name, const pcl::PointCloud< PointT > &cloud)
Templated version for saving point cloud data to a PCD file containing a specific given cloud format.
int loadPCDFile(const std::string &file_name, pcl::PCLPointCloud2 &cloud)
Load a PCD v.6 file into a templated PointCloud type.
int savePCDFileBinaryCompressed(const std::string &file_name, const pcl::PointCloud< PointT > &cloud)
Templated version for saving point cloud data to a PCD file containing a specific given cloud format.
Defines functions, macros and traits for allocating and using memory.
void read(std::istream &stream, Type &value)
Function for reading data from a stream.
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map, const std::uint8_t *msg_data)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
IndicesAllocator<> Indices
Type used for indices in PCL.
void write(std::ostream &stream, Type value)
Function for writing data to a stream.
Defines all the PCL and non-PCL macros used.
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
A point structure representing Euclidean xyz coordinates, and the RGB color.