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_