Open3D (C++ API)  0.12.0
PointCloudIO.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <string>
30 
32 
33 namespace open3d {
34 namespace io {
35 
38 std::shared_ptr<geometry::PointCloud> CreatePointCloudFromFile(
39  const std::string &filename,
40  const std::string &format = "auto",
41  bool print_progress = false);
42 
47  // Attention: when you update the defaults, update the docstrings in
48  // pybind/io/class_io.cpp
49  std::string format = "auto",
50  bool remove_nan_points = true,
51  bool remove_infinite_points = true,
52  bool print_progress = false,
53  std::function<bool(double)> update_progress = {})
54  : format(format),
59  ReadPointCloudOption(std::function<bool(double)> up)
61  update_progress = up;
62  };
65  std::string format;
77  std::function<bool(double)> update_progress;
78 };
79 
84 bool ReadPointCloud(const std::string &filename,
85  geometry::PointCloud &pointcloud,
86  const ReadPointCloudOption &params = {});
87 
91  enum class IsAscii : bool { Binary = false, Ascii = true };
92  enum class Compressed : bool { Uncompressed = false, Compressed = true };
94  // Attention: when you update the defaults, update the docstrings in
95  // pybind/io/class_io.cpp
96  IsAscii write_ascii = IsAscii::Binary,
97  Compressed compressed = Compressed::Uncompressed,
98  bool print_progress = false,
99  std::function<bool(double)> update_progress = {})
100  : write_ascii(write_ascii),
101  compressed(compressed),
104  // for compatibility
105  WritePointCloudOption(bool write_ascii,
106  bool compressed = false,
107  bool print_progress = false,
108  std::function<bool(double)> update_progress = {})
109  : write_ascii(IsAscii(write_ascii)),
110  compressed(Compressed(compressed)),
113  WritePointCloudOption(std::function<bool(double)> up)
115  update_progress = up;
116  };
131  std::function<bool(double)> update_progress;
132 };
133 
138 bool WritePointCloud(const std::string &filename,
139  const geometry::PointCloud &pointcloud,
140  const WritePointCloudOption &params = {});
141 
142 bool ReadPointCloudFromXYZ(const std::string &filename,
143  geometry::PointCloud &pointcloud,
144  const ReadPointCloudOption &params);
145 
146 bool WritePointCloudToXYZ(const std::string &filename,
147  const geometry::PointCloud &pointcloud,
148  const WritePointCloudOption &params);
149 
150 bool ReadPointCloudFromXYZN(const std::string &filename,
151  geometry::PointCloud &pointcloud,
152  const ReadPointCloudOption &params);
153 
154 bool WritePointCloudToXYZN(const std::string &filename,
155  const geometry::PointCloud &pointcloud,
156  const WritePointCloudOption &params);
157 
158 bool ReadPointCloudFromXYZRGB(const std::string &filename,
159  geometry::PointCloud &pointcloud,
160  const ReadPointCloudOption &params);
161 
162 bool WritePointCloudToXYZRGB(const std::string &filename,
163  const geometry::PointCloud &pointcloud,
164  const WritePointCloudOption &params);
165 
166 bool ReadPointCloudFromPLY(const std::string &filename,
167  geometry::PointCloud &pointcloud,
168  const ReadPointCloudOption &params);
169 
170 bool WritePointCloudToPLY(const std::string &filename,
171  const geometry::PointCloud &pointcloud,
172  const WritePointCloudOption &params);
173 
174 bool ReadPointCloudFromPCD(const std::string &filename,
175  geometry::PointCloud &pointcloud,
176  const ReadPointCloudOption &params);
177 
178 bool WritePointCloudToPCD(const std::string &filename,
179  const geometry::PointCloud &pointcloud,
180  const WritePointCloudOption &params);
181 
182 bool ReadPointCloudFromPTS(const std::string &filename,
183  geometry::PointCloud &pointcloud,
184  const ReadPointCloudOption &params);
185 
186 bool WritePointCloudToPTS(const std::string &filename,
187  const geometry::PointCloud &pointcloud,
188  const WritePointCloudOption &params);
189 
190 } // namespace io
191 } // namespace open3d
std::function< bool(double)> update_progress
Definition: PointCloudIO.h:131
bool WritePointCloudToPTS(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FilePTS.cpp:111
WritePointCloudOption(std::function< bool(double)> up)
Definition: PointCloudIO.h:113
bool WritePointCloud(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: PointCloudIO.cpp:127
bool ReadPointCloudFromXYZ(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FileXYZ.cpp:42
Optional parameters to ReadPointCloud.
Definition: PointCloudIO.h:45
std::shared_ptr< geometry::PointCloud > CreatePointCloudFromFile(const std::string &filename, const std::string &format, bool print_progress)
Definition: PointCloudIO.cpp:68
bool ReadPointCloudFromXYZN(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FileXYZN.cpp:42
A point cloud consists of point coordinates, and optionally point colors and point normals...
Definition: PointCloud.h:54
bool ReadPointCloudFromPLY(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FilePLY.cpp:396
ReadPointCloudOption(std::string format="auto", bool remove_nan_points=true, bool remove_infinite_points=true, bool print_progress=false, std::function< bool(double)> update_progress={})
Definition: PointCloudIO.h:46
bool WritePointCloudToPCD(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FilePCD.cpp:792
Compressed compressed
Definition: PointCloudIO.h:123
bool print_progress
Definition: PointCloudIO.h:73
IsAscii write_ascii
Definition: PointCloudIO.h:116
bool WritePointCloudToXYZN(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FileXYZN.cpp:78
bool WritePointCloudToXYZRGB(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FileXYZRGB.cpp:78
bool ReadPointCloudFromXYZRGB(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FileXYZRGB.cpp:42
std::string format
Definition: PointCloudIO.h:62
bool ReadPointCloud(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: PointCloudIO.cpp:77
bool WritePointCloudToPLY(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FilePLY.cpp:461
Optional parameters to WritePointCloud.
Definition: PointCloudIO.h:90
Definition: PinholeCameraIntrinsic.cpp:35
bool ReadPointCloudFromPTS(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FilePTS.cpp:43
bool print_progress
Definition: PointCloudIO.h:127
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:191
bool remove_infinite_points
Whether to remove all points that have +-inf.
Definition: PointCloudIO.h:69
bool remove_nan_points
Whether to remove all points that have nan.
Definition: PointCloudIO.h:67
std::function< bool(double)> update_progress
Definition: PointCloudIO.h:77
ReadPointCloudOption(std::function< bool(double)> up)
Definition: PointCloudIO.h:59
WritePointCloudOption(bool write_ascii, bool compressed=false, bool print_progress=false, std::function< bool(double)> update_progress={})
Definition: PointCloudIO.h:105
Compressed
Definition: PointCloudIO.h:92
bool WritePointCloudToXYZ(const std::string &filename, const geometry::PointCloud &pointcloud, const WritePointCloudOption &params)
Definition: FileXYZ.cpp:76
WritePointCloudOption(IsAscii write_ascii=IsAscii::Binary, Compressed compressed=Compressed::Uncompressed, bool print_progress=false, std::function< bool(double)> update_progress={})
Definition: PointCloudIO.h:93
bool ReadPointCloudFromPCD(const std::string &filename, geometry::PointCloud &pointcloud, const ReadPointCloudOption &params)
Definition: FilePCD.cpp:755
IsAscii
Definition: PointCloudIO.h:91