Point Cloud Library (PCL)
1.11.1-dev
|
40 #include <pcl/conversions.h>
41 #include <pcl/point_cloud.h>
42 #include <pcl/PCLPointCloud2.h>
43 #include <pcl/io/boost.h>
46 #include <Eigen/Geometry>
86 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
87 int &file_version,
int &data_type,
unsigned int &data_idx,
const int offset = 0) = 0;
103 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int &file_version,
104 const int offset = 0) = 0;
125 Eigen::Vector4f origin;
126 Eigen::Quaternionf orientation;
128 return (
read (file_name, cloud, origin, orientation, file_version, offset));
140 template<
typename Po
intT>
inline int
146 file_version, offset);
180 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
181 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
182 const bool binary =
false) = 0;
194 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
195 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
196 const bool binary =
false)
198 return (
write (file_name, *cloud, origin, orientation, binary));
207 template<
typename Po
intT>
inline int
208 write (
const std::string &file_name,
210 const bool binary =
false)
219 return (
write (file_name, blob, origin, orientation, binary));
234 template <
typename Type>
inline
235 std::enable_if_t<std::is_floating_point<Type>::value>
238 const int point_size,
239 const unsigned int field_idx,
240 const unsigned int fields_count,
241 std::ostream &stream)
244 memcpy (&value, &cloud.
data[point_index * point_size + cloud.
fields[field_idx].offset + fields_count * sizeof (Type)],
sizeof (Type));
245 if (std::isnan (value))
251 template <
typename Type>
inline
252 std::enable_if_t<std::is_integral<Type>::value>
255 const int point_size,
256 const unsigned int field_idx,
257 const unsigned int fields_count,
258 std::ostream &stream)
261 memcpy (&value, &cloud.
data[point_index * point_size + cloud.
fields[field_idx].offset + fields_count * sizeof (Type)],
sizeof (Type));
265 template <>
inline void
268 const int point_size,
269 const unsigned int field_idx,
270 const unsigned int fields_count,
271 std::ostream &stream)
274 memcpy (&value, &cloud.
data[point_index * point_size + cloud.
fields[field_idx].offset + fields_count * sizeof (std::int8_t)],
sizeof (std::int8_t));
276 stream << boost::numeric_cast<int>(value);
279 template <>
inline void
282 const int point_size,
283 const unsigned int field_idx,
284 const unsigned int fields_count,
285 std::ostream &stream)
288 memcpy (&value, &cloud.
data[point_index * point_size + cloud.
fields[field_idx].offset + fields_count * sizeof (std::uint8_t)],
sizeof (std::uint8_t));
290 stream << boost::numeric_cast<unsigned int>(value);
303 template <
typename Type>
inline
304 std::enable_if_t<std::is_floating_point<Type>::value,
bool>
307 const int point_size,
308 const unsigned int field_idx,
309 const unsigned int fields_count)
312 memcpy (&value, &cloud.
data[point_index * point_size + cloud.
fields[field_idx].offset + fields_count * sizeof (Type)],
sizeof (Type));
313 return std::isfinite (value);
316 template <
typename Type>
inline
317 std::enable_if_t<std::is_integral<Type>::value,
bool>
328 template <
typename Type>
333 unsigned int field_idx,
334 unsigned int fields_count,
335 std::istringstream& is)
338 if (boost::iequals(st,
"nan")) {
339 value = std::numeric_limits<Type>::quiet_NaN();
345 value =
static_cast<Type
>(atof(st.c_str()));
349 fields_count *
sizeof(Type)],
350 reinterpret_cast<char*
>(&value),
356 copyStringValue<std::int8_t>(
const std::string& st,
359 unsigned int field_idx,
360 unsigned int fields_count,
361 std::istringstream& is)
368 val =
static_cast<int>(atof(st.c_str()));
370 value =
static_cast<std::int8_t
>(val);
373 fields_count *
sizeof(std::int8_t)],
374 reinterpret_cast<char*
>(&value),
375 sizeof(std::int8_t));
380 copyStringValue<std::uint8_t>(
const std::string& st,
383 unsigned int field_idx,
384 unsigned int fields_count,
385 std::istringstream& is)
393 val =
static_cast<int>(atof(st.c_str()));
395 value =
static_cast<std::uint8_t
>(val);
398 fields_count *
sizeof(std::uint8_t)],
399 reinterpret_cast<char*
>(&value),
400 sizeof(std::uint8_t));
415 template <
typename Type>
inline void
417 pcl::index_t point_index,
unsigned int field_idx,
unsigned int fields_count)
419 std::istringstream is;
420 is.imbue (std::locale::classic ());
421 detail::copyStringValue<Type> (st, cloud,point_index, field_idx, fields_count, is);
435 template <
typename Type>
inline void
437 pcl::index_t point_index,
unsigned int field_idx,
unsigned int fields_count,
438 std::istringstream& is)
440 detail::copyStringValue<Type> (st, cloud,point_index, field_idx, fields_count, is);
virtual ~FileReader()
empty destructor
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.
void copyStringValue(const std::string &st, pcl::PCLPointCloud2 &cloud, pcl::index_t point_index, unsigned int field_idx, unsigned int fields_count, std::istringstream &is)
FileReader()
empty constructor
virtual ~FileWriter()
Empty destructor.
PointCloud represents the base class in PCL for storing collections of 3D points.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
Point Cloud Data (FILE) file format writer.
int write(const std::string &file_name, const pcl::PointCloud< PointT > &cloud, const bool binary=false)
Save point cloud data to a FILE file containing n-D points.
FileWriter()
Empty constructor.
void read(std::istream &stream, Type &value)
Function for reading data from a stream.
std::vector<::pcl::PCLPointField > fields
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
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.
std::enable_if_t< std::is_floating_point< Type >::value, bool > isValueFinite(const pcl::PCLPointCloud2 &cloud, const pcl::index_t point_index, const int point_size, const unsigned int field_idx, const unsigned int fields_count)
Check whether a given value of type Type (uchar, char, uint, int, float, double, ....
Point Cloud Data (FILE) file format reader interface.
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
std::vector< std::uint8_t > data
void write(std::ostream &stream, Type value)
Function for writing data to a stream.
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 FILE file containing n-D points.
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
std::enable_if_t< std::is_floating_point< Type >::value > copyValueString(const pcl::PCLPointCloud2 &cloud, const pcl::index_t point_index, const int point_size, const unsigned int field_idx, const unsigned int fields_count, std::ostream &stream)
inserts a value of type Type (uchar, char, uint, int, float, double, ...) into a stringstream.
void copyStringValue(const std::string &st, pcl::PCLPointCloud2 &cloud, pcl::index_t point_index, unsigned int field_idx, unsigned int fields_count)
Copy one single value of type T (uchar, char, uint, int, float, double, ...) from a string.
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.