8 #include "io/PointCloudIO.h"
24 #include <unordered_map>
28 static const std::unordered_map<
30 std::function<bool(
const std::string &,
32 const ReadPointCloudOption &)>>
46 static const std::unordered_map<
48 std::function<bool(
const unsigned char *,
56 static const std::unordered_map<
58 std::function<bool(
const std::string &,
74 static const std::unordered_map<
76 std::function<bool(
unsigned char *&,
87 bool print_progress) {
88 auto pointcloud = std::make_shared<ccPointCloud>(
"pointCloud");
94 const unsigned char *buffer,
97 bool print_progress) {
98 auto pointcloud = std::make_shared<ccPointCloud>();
100 {
format,
true,
true, print_progress});
119 "Read ccPointCloud failed: unknown file extension for "
127 if (
params.remove_nan_points ||
params.remove_infinite_points) {
129 params.remove_infinite_points);
136 const std::string &file_format,
137 bool remove_nan_points,
138 bool remove_infinite_points,
139 bool print_progress) {
140 std::string
format = file_format;
165 "Read ccPointCloud failed: unknown format for "
176 "Read ccPointCloud failed: unknown format for "
181 bool success = map_itr->second(buffer,
length, pointcloud,
params);
184 if (
params.remove_nan_points ||
params.remove_infinite_points) {
186 params.remove_infinite_points);
200 "Write ccPointCloud failed: unknown file extension {} "
214 const std::string &file_format ,
217 bool print_progress) {
221 std::string
format = file_format;
241 "Write ccPointCloud failed: unknown format for "
249 "Write ccPointCloud failed: unknown format {}.",
format);
253 bool success = map_itr->second(buffer,
length, pointcloud,
params);
filament::Texture::InternalFormat format
cmdLineReadable * params[]
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
ccPointCloud & RemoveNonFinitePoints(bool remove_nan=true, bool remove_infinite=true)
Remove all points fromt he point cloud that have a nan entry, or infinite entries.
unsigned size() const override
__host__ __device__ float length(float2 v)
Helper functions for the ml ops.
bool ReadPointCloudFromPLY(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool ReadPointCloudFromXYZN(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool WritePointCloudToPCD(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool AutoReadEntity(const std::string &filename, ccHObject &entity, const ReadPointCloudOption ¶ms)
static const std::unordered_map< std::string, std::function< bool(const std::string &, ccPointCloud &, const ReadPointCloudOption &)> > file_extension_to_pointcloud_read_function
bool WritePointCloudToPTS(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool ReadPointCloudFromPCD(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
static const std::unordered_map< std::string, std::function< bool(const std::string &, const ccPointCloud &, const WritePointCloudOption &)> > file_extension_to_pointcloud_write_function
bool ReadPointCloudFromXYZ(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool ReadPointCloud(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool ReadPointCloudFromXYZRGB(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool AutoWriteEntity(const std::string &filename, const ccHObject &entity, const WritePointCloudOption ¶ms)
bool WritePointCloud(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
static const std::unordered_map< std::string, std::function< bool(const unsigned char *, const size_t, ccPointCloud &, const ReadPointCloudOption &)> > in_memory_to_pointcloud_read_function
bool WritePointCloudToXYZ(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
static const std::unordered_map< std::string, std::function< bool(unsigned char *&, size_t &, const ccPointCloud &, const WritePointCloudOption &)> > in_memory_to_pointcloud_write_function
bool WritePointCloudToPLY(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool WritePointCloudToXYZN(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
std::shared_ptr< ccPointCloud > CreatePointCloudFromFile(const std::string &filename, const std::string &format, bool print_progress)
bool WritePointCloudToXYZRGB(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool WritePointCloudInMemoryToXYZ(unsigned char *&buffer, size_t &length, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool ReadPointCloudFromPTS(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
std::shared_ptr< ccPointCloud > CreatePointCloudFromMemory(const unsigned char *buffer, const size_t length, const std::string &format, bool print_progress)
bool ReadPointCloudInMemoryFromXYZ(const unsigned char *buffer, const size_t length, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
std::string GetFileExtensionInLowerCase(const std::string &filename)
std::string ToUpper(const std::string &s)
Convert string to the upper case.
Generic file read and write utility for python interface.
Optional parameters to ReadPointCloud.
bool remove_nan_points
Whether to remove all points that have nan.
std::function< bool(double)> update_progress
bool remove_infinite_points
Whether to remove all points that have +-inf.
Optional parameters to WritePointCloud.
std::function< bool(double)> update_progress
update_progress(double percent) functor for ConsoleProgressBar