25 const std::string &
path) {
37 "Read XYZI failed: unable to open file: {}",
filename);
48 double *points_ptr =
points.GetDataPtr<
double>();
49 double *intensities_ptr = intensities.GetDataPtr<
double>();
53 const char *line_buffer;
54 while ((line_buffer = file.
ReadLine())) {
55 if (sscanf(line_buffer,
"%lf %lf %lf %lf", &x, &y, &z, &I) == 4) {
56 points_ptr[3 * i + 0] = x;
57 points_ptr[3 * i + 1] = y;
58 points_ptr[3 * i + 2] = z;
59 intensities_ptr[i] = I;
61 if (++i % 1000 == 0) {
70 }
catch (
const std::exception &e) {
89 "Write XYZI failed: unable to open file: {}",
filename);
95 if (!
points.GetShape().IsCompatible(
96 {cloudViewer::utility::nullopt, 3})) {
98 "Write XYZI failed: Shape of points is {}, but it should "
107 "Write XYZI failed: Points ({}) and intensities ({}) have "
108 "different lengths.",
114 for (
int i = 0; i <
points.GetShape(0); i++) {
115 if (fprintf(file.
GetFILE(),
"%.10f %.10f %.10f %.10f\n",
116 points[i][0].Item<
double>(),
117 points[i][1].Item<
double>(),
118 points[i][2].Item<
double>(),
119 intensities[i][0].
Item<
double>()) < 0) {
121 "Write XYZI failed: unable to write file: {}",
131 }
catch (
const std::exception &e) {
cmdLineReadable * params[]
SizeVector GetShape() const
A point cloud contains a list of 3D points.
void SetPoints(const core::Tensor &value)
bool HasPointAttr(const std::string &key) const
core::Tensor & GetPoints()
const TensorMap & GetPointAttr() const
Getter for point_attr_ TensorMap. Used in Pybind.
PointCloud & Clear() override
Clear all data in the point cloud.
void SetPointAttr(const std::string &key, const core::Tensor &value)
void SetTotal(int64_t total)
bool Update(int64_t count)
bool Open(const std::string &filename, const std::string &mode)
Open a file.
int64_t CurPos()
Returns current position in the file (ftell).
FILE * GetFILE()
Returns the underlying C FILE pointer.
int64_t GetFileSize()
Returns the file size in bytes.
int64_t GetNumLines()
Returns the number of lines in the file.
static const std::string path
cloudViewer::io::FileGeometry ReadFileGeometryTypeXYZI(const std::string &path)
bool WritePointCloudToXYZI(const std::string &filename, const geometry::PointCloud &pointcloud, const cloudViewer::io::WritePointCloudOption ¶ms)
bool ReadPointCloudFromXYZI(const std::string &filename, geometry::PointCloud &pointcloud, const cloudViewer::io::ReadPointCloudOption ¶ms)
Generic file read and write utility for python interface.
Optional parameters to ReadPointCloud.
Optional parameters to WritePointCloud.