Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_IO_PNG_IO_H_
00041 #define PCL_IO_PNG_IO_H_
00042
00043 #include <pcl/pcl_macros.h>
00044 #include <pcl/point_cloud.h>
00045 #include <pcl/point_types.h>
00046 #include <string>
00047 #include <vector>
00048
00049 namespace pcl
00050 {
00051 namespace io
00052 {
00061 PCL_EXPORTS void
00062 saveCharPNGFile (const std::string& file_name, const unsigned char *mono_image, int width, int height, int channels);
00063
00072 PCL_EXPORTS void
00073 saveShortPNGFile (const std::string& file_name, const unsigned short *short_image, int width, int height, int channels);
00074
00082 PCL_EXPORTS void
00083 saveRgbPNGFile (const std::string& file_name, const unsigned char *rgb_image, int width, int height)
00084 {
00085 saveCharPNGFile(file_name, rgb_image, width, height, 3);
00086 }
00087
00093 void
00094 savePNGFile (const std::string& file_name, const pcl::PointCloud<unsigned char>& cloud)
00095 {
00096 saveCharPNGFile(file_name, &cloud.points[0], cloud.width, cloud.height, 1);
00097 }
00098
00105 void
00106 savePNGFile (const std::string& file_name, const pcl::PointCloud<unsigned short>& cloud)
00107 {
00108 saveShortPNGFile(file_name, &cloud.points[0], cloud.width, cloud.height, 1);
00109 }
00110
00116 template <typename T> void
00117 savePNGFile (const std::string& file_name, const pcl::PointCloud<T>& cloud)
00118 {
00119 std::vector<unsigned char> data(cloud.width * cloud.height * 3);
00120
00121 for (size_t i = 0; i < cloud.points.size (); ++i)
00122 {
00123 data[i*3 + 0] = cloud.points[i].r;
00124 data[i*3 + 1] = cloud.points[i].g;
00125 data[i*3 + 2] = cloud.points[i].b;
00126 }
00127 saveRgbPNGFile(file_name, &data[0], cloud.width, cloud.height);
00128 }
00129
00136 void
00137 savePNGFile (const std::string& file_name, const pcl::PointCloud<pcl::PointXYZL>& cloud)
00138 {
00139 std::vector<unsigned short> data(cloud.width * cloud.height);
00140
00141 for (size_t i = 0; i < cloud.points.size (); ++i)
00142 {
00143 data[i] = static_cast<unsigned short> (cloud.points[i].label);
00144 }
00145 saveShortPNGFile(file_name, &data[0], cloud.width, cloud.height,1);
00146 }
00147 }
00148 }
00149
00150 #endif //#ifndef PCL_IO_PNG_IO_H_