35 #include <liblas/liblas.hpp>
40 const pcl::PointCloud<pcl::PointXYZ> & cloud,
41 const std::vector<int> & cameraIds)
43 UASSERT_MSG(cameraIds.empty() || cameraIds.size() == cloud.size(),
44 uFormat(
"cameraIds=%d cloud=%d", (
int)cameraIds.size(), (
int)cloud.size()).c_str());
47 ofs.open(filePath, std::ios::out | std::ios::binary);
50 header.SetScale(0.001, 0.001, 0.001);
55 liblas::Writer writer(ofs,
header);
57 for(
size_t i=0;
i<cloud.size(); ++
i)
60 point.SetCoordinates(cloud.at(
i).x, cloud.at(
i).y, cloud.at(
i).z);
61 if(!cameraIds.empty())
63 point.SetPointSourceID(cameraIds.at(
i));
66 writer.WritePoint(
point);
69 catch(liblas::configuration_error &
e)
71 UERROR(
"\"laz\" format not available, use \"las\" instead: %s",
e.what());
79 const pcl::PointCloud<pcl::PointXYZRGB> & cloud,
80 const std::vector<int> & cameraIds,
81 const std::vector<float> & intensities)
83 UASSERT_MSG(cameraIds.empty() || cameraIds.size() == cloud.size(),
84 uFormat(
"cameraIds=%d cloud=%d", (
int)cameraIds.size(), (
int)cloud.size()).c_str());
85 UASSERT_MSG(intensities.empty() || intensities.size() == cloud.size(),
86 uFormat(
"intensities=%d cloud=%d", (
int)intensities.size(), (
int)cloud.size()).c_str());
88 UASSERT_MSG(cameraIds.empty() || cameraIds.size() == cloud.size(),
89 uFormat(
"cameraIds=%d cloud=%d", (
int)cameraIds.size(), (
int)cloud.size()).c_str());
92 ofs.open(filePath, std::ios::out | std::ios::binary);
96 header.SetScale(0.001, 0.001, 0.001);
100 liblas::Writer writer(ofs,
header);
102 for(
size_t i=0;
i<cloud.size(); ++
i)
105 point.SetCoordinates(cloud.at(
i).x, cloud.at(
i).y, cloud.at(
i).z);
106 liblas::Color color(cloud.at(
i).r*65535/255, cloud.at(
i).g*65535/255, cloud.at(
i).b*65535/255);
107 point.SetColor(color);
108 if(!cameraIds.empty())
110 point.SetPointSourceID(cameraIds.at(
i));
112 if(!intensities.empty())
114 point.SetIntensity(intensities.at(
i));
117 writer.WritePoint(
point);
120 catch(liblas::configuration_error &
e)
122 UERROR(
"\"laz\" format not available, use \"las\" instead: %s",
e.what());
130 const pcl::PointCloud<pcl::PointXYZI> & cloud,
131 const std::vector<int> & cameraIds)
133 UASSERT_MSG(cameraIds.empty() || cameraIds.size() == cloud.size(),
134 uFormat(
"cameraIds=%d cloud=%d", (
int)cameraIds.size(), (
int)cloud.size()).c_str());
137 ofs.open(filePath, std::ios::out | std::ios::binary);
140 header.SetScale(0.001, 0.001, 0.001);
145 liblas::Writer writer(ofs,
header);
147 for(
size_t i=0;
i<cloud.size(); ++
i)
150 point.SetCoordinates(cloud.at(
i).x, cloud.at(
i).y, cloud.at(
i).z);
151 if(!cameraIds.empty())
153 point.SetPointSourceID(cameraIds.at(
i));
156 writer.WritePoint(
point);
159 catch(liblas::configuration_error &
e)
161 UERROR(
"\"laz\" format not available, use \"las\" instead: %s",
e.what());