40 #ifndef PCL_IO_PNG_IO_H_
41 #define PCL_IO_PNG_IO_H_
43 #include <pcl/pcl_macros.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/point_types.h>
46 #include <pcl/console/print.h>
49 #include <pcl/io/point_cloud_image_extractors.h>
64 saveCharPNGFile (
const std::string& file_name,
const unsigned char *mono_image,
int width,
int height,
int channels);
75 saveShortPNGFile (
const std::string& file_name,
const unsigned short *short_image,
int width,
int height,
int channels);
85 saveRgbPNGFile (
const std::string& file_name,
const unsigned char *rgb_image,
int width,
int height)
129 else if (image.
encoding ==
"mono16")
135 PCL_ERROR (
"[pcl::io::savePNGFile] Unsupported image encoding \"%s\".\n", image.
encoding.c_str ());
145 "pcl::io::savePNGFile<typename T> (file_name, cloud) is deprecated, please use a new generic "
146 "function pcl::io::savePNGFile (file_name, cloud, field_name) with \"rgb\" as the field name."
148 template <
typename T>
void
151 std::vector<unsigned char> data(cloud.
width * cloud.
height * 3);
153 for (
size_t i = 0; i < cloud.
points.size (); ++i)
155 data[i*3 + 0] = cloud.
points[i].r;
156 data[i*3 + 1] = cloud.
points[i].g;
157 data[i*3 + 2] = cloud.
points[i].b;
169 "pcl::io::savePNGFile (file_name, cloud) is deprecated, please use a new generic function "
170 "pcl::io::savePNGFile (file_name, cloud, field_name) with \"label\" as the field name."
175 std::vector<unsigned short> data(cloud.
width * cloud.
height);
176 for (
size_t i = 0; i < cloud.
points.size (); ++i)
178 data[i] =
static_cast<unsigned short> (cloud.
points[i].label);
189 template <
typename Po
intT>
void
193 PointCloudImageExtractorPtr pcie;
194 if (field_name ==
"normal")
198 else if (field_name ==
"rgb")
202 else if (field_name ==
"label")
206 else if (field_name ==
"z")
210 else if (field_name ==
"curvature")
214 else if (field_name ==
"intensity")
220 PCL_ERROR (
"[pcl::io::savePNGFile] Unsupported field \"%s\".\n", field_name.c_str ());
224 if (pcie->extract (cloud, image))
230 PCL_ERROR (
"[pcl::io::savePNGFile] Failed to extract an image from \"%s\" field.\n", field_name.c_str());
237 #endif //#ifndef PCL_IO_PNG_IO_H_
Image Extractor which uses the data present in the "rgb" or "rgba" fields to produce a color image wi...
void savePNGFile(const std::string &file_name, const pcl::PointCloud< unsigned char > &cloud)
Saves 8-bit grayscale cloud as image to PNG file.
PCL_DEPRECATED(template< typename T > void savePNGFile(const std::string &file_name, const pcl::PointCloud< T > &cloud),"pcl::io::savePNGFile<typename T> (file_name, cloud) is deprecated, please use a new generic ""function pcl::io::savePNGFile (file_name, cloud, field_name) with \"rgb\" as the field name.")
Saves RGB fields of cloud as image to PNG file.
Image Extractor which uses the data present in the "curvature" field to produce a curvature map (as a...
std::vector< pcl::uint8_t > data
uint32_t height
The point cloud height (if organized as an image-structure).
Image Extractor which uses the data present in the "normal" field.
boost::shared_ptr< PointCloudImageExtractor< PointT > > Ptr
PCL_EXPORTS void saveRgbPNGFile(const std::string &file_name, const unsigned char *rgb_image, int width, int height)
Saves 8-bit encoded RGB image to PNG file.
Image Extractor which uses the data present in the "label" field to produce either monochrome or RGB ...
PCL_EXPORTS void saveShortPNGFile(const std::string &file_name, const unsigned short *short_image, int width, int height, int channels)
Saves 16-bit encoded image to PNG file.
Image Extractor which uses the data present in the "z" field to produce a depth map (as a monochrome ...
uint32_t width
The point cloud width (if organized as an image-structure).
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Image Extractor which uses the data present in the "intensity" field to produce a monochrome intensit...
PCL_EXPORTS void saveCharPNGFile(const std::string &file_name, const unsigned char *mono_image, int width, int height, int channels)
Saves 8-bit encoded image to PNG file.