10 #include <IJsonConvertibleIO.h>
12 #include <LineSetIO.h>
14 #include <PinholeCameraTrajectoryIO.h>
20 #include <unordered_map>
24 #include "io/PointCloudIO.h"
26 #include "io/TriangleMeshIO.h"
31 #ifdef BUILD_AZURE_KINECT
40 static const std::unordered_map<std::string, std::string>
42 {
"filename",
"Path to file."},
45 "Set to ``True`` to write in compressed format."},
47 "The format of the input file. When not specified or set as "
48 "``auto``, the format is inferred from file extension name."},
50 "If true, all points that include a NaN are removed from "
52 {
"remove_infinite_points",
53 "If true, all points that include an infinite value are "
54 "removed from the PointCloud."},
55 {
"quality",
"Quality of the output file."},
57 "Set to ``True`` to output in ascii format, otherwise binary "
58 "format will be used."},
59 {
"write_vertex_normals",
60 "Set to ``False`` to not write any vertex normals, even if "
61 "present on the mesh"},
62 {
"write_vertex_colors",
63 "Set to ``False`` to not write any vertex colors, even if "
64 "present on the mesh"},
65 {
"write_triangle_uvs",
66 "Set to ``False`` to not write any triangle uvs, even if "
67 "present on the mesh. For ``obj`` format, mtl file is saved "
68 "only when ``True`` is set"},
70 {
"config",
"AzureKinectSensor's config file."},
71 {
"pointcloud",
"The ``PointCloud`` object for I/O"},
72 {
"mesh",
"The ``TriangleMesh`` object for I/O"},
73 {
"line_set",
"The ``LineSet`` object for I/O"},
74 {
"image",
"The ``Image`` object for I/O"},
75 {
"voxel_grid",
"The ``VoxelGrid`` object for I/O"},
76 {
"octree",
"The ``Octree`` object for I/O"},
78 "The ``PinholeCameraTrajectory`` object for I/O"},
79 {
"intrinsic",
"The ``PinholeCameraIntrinsic`` object for I/O"},
81 "The ``PinholeCameraParameters`` object for I/O"},
82 {
"pose_graph",
"The ``PoseGraph`` object for I/O"},
83 {
"feature",
"The ``Feature`` object for I/O"},
85 "If set to true a progress bar is visualized in the console"},
89 py::native_enum<FileGeometry>(m_io,
"FileGeometry",
"enum.IntFlag",
99 "Returns the type of geometry of the file. This is a faster way of "
100 "determining the file type than attempting to read the file as a "
101 "point cloud, mesh, or line set in turn.");
107 bool print_progress) {
108 auto entity = std::make_shared<ccHObject>(
"group");
112 "Function to read entity from file",
"filename"_a,
113 "format"_a =
"auto",
"print_progress"_a =
false);
124 "Function to write entity to file",
"filename"_a,
"entity"_a,
125 "write_ascii"_a =
false,
"compressed"_a =
false,
126 "print_progress"_a =
false);
134 py::gil_scoped_release release;
139 "Function to read Image from file",
"filename"_a);
147 py::gil_scoped_release release;
150 "Function to write Image to file",
"filename"_a,
"image"_a,
159 bool print_progress) {
160 py::gil_scoped_release release;
166 "Function to read LineSet from file",
"filename"_a,
167 "format"_a =
"auto",
"print_progress"_a =
false);
175 py::gil_scoped_release release;
179 "Function to write LineSet to file",
"filename"_a,
"line_set"_a,
180 "write_ascii"_a =
false,
"compressed"_a =
false,
181 "print_progress"_a =
false);
189 bool remove_nan_points,
bool remove_infinite_points,
190 bool print_progress) {
191 py::gil_scoped_release release;
192 auto pcd = std::make_shared<ccPointCloud>();
194 {format, remove_nan_points,
195 remove_infinite_points, print_progress});
198 "Function to read PointCloud from file",
"filename"_a,
199 "format"_a =
"auto",
"remove_nan_points"_a =
false,
200 "remove_infinite_points"_a =
false,
"print_progress"_a =
false);
205 "read_point_cloud_from_bytes",
207 bool remove_nan_points,
bool remove_infinite_points,
208 bool print_progress) {
209 const char *dataptr = PYBIND11_BYTES_AS_STRING(
bytes.ptr());
211 auto buffer =
new unsigned char[
length];
213 std::memcpy(buffer, dataptr,
length);
214 py::gil_scoped_release release;
215 auto pcd = std::make_shared<ccPointCloud>();
218 {
format, remove_nan_points,
219 remove_infinite_points, print_progress});
223 "Function to read PointCloud from memory",
"bytes"_a,
224 "format"_a =
"auto",
"remove_nan_points"_a =
false,
225 "remove_infinite_points"_a =
false,
"print_progress"_a =
false);
233 bool print_progress) {
234 py::gil_scoped_release release;
237 {format, write_ascii, compressed, print_progress});
239 "Function to write PointCloud to file",
"filename"_a,
240 "pointcloud"_a,
"format"_a =
"auto",
"write_ascii"_a =
false,
241 "compressed"_a =
false,
"print_progress"_a =
false);
246 "write_point_cloud_to_bytes",
249 py::gil_scoped_release release;
251 unsigned char *buffer =
nullptr;
253 buffer, len, pointcloud,
255 py::gil_scoped_acquire acquire;
260 py::bytes(
reinterpret_cast<const char *
>(buffer), len);
264 "Function to write PointCloud to memory",
"pointcloud"_a,
265 "format"_a =
"auto",
"write_ascii"_a =
false,
266 "compressed"_a =
false,
"print_progress"_a =
false);
272 "read_triangle_mesh",
274 bool print_progress) {
275 py::gil_scoped_release release;
291 "Function to read TriangleMesh from file",
"filename"_a,
292 "enable_post_processing"_a =
false,
"print_progress"_a =
false);
297 "write_triangle_mesh",
300 bool write_vertex_colors,
bool write_triangle_uvs,
301 bool print_progress) {
302 py::gil_scoped_release release;
306 write_triangle_uvs, print_progress);
308 "Function to write TriangleMesh to file",
"filename"_a,
"mesh"_a,
309 "write_ascii"_a =
false,
"compressed"_a =
false,
310 "write_vertex_normals"_a =
true,
"write_vertex_colors"_a =
true,
311 "write_triangle_uvs"_a =
true,
"print_progress"_a =
false);
317 "read_triangle_model",
319 py::gil_scoped_release release;
326 "Function to read visualization.rendering.TriangleMeshModel from "
328 "filename"_a,
"print_progress"_a =
false);
336 bool print_progress) {
337 py::gil_scoped_release release;
342 "Function to read VoxelGrid from file",
"filename"_a,
343 "format"_a =
"auto",
"print_progress"_a =
false);
351 py::gil_scoped_release release;
355 "Function to write VoxelGrid to file",
"filename"_a,
"voxel_grid"_a,
356 "write_ascii"_a =
false,
"compressed"_a =
false,
357 "print_progress"_a =
false);
365 py::gil_scoped_release release;
370 "Function to read Octree from file",
"filename"_a,
371 "format"_a =
"auto");
378 py::gil_scoped_release release;
381 "Function to write Octree to file",
"filename"_a,
"octree"_a);
387 "read_pinhole_camera_intrinsic",
389 py::gil_scoped_release release;
394 "Function to read PinholeCameraIntrinsic from file",
"filename"_a);
399 "write_pinhole_camera_intrinsic",
402 py::gil_scoped_release release;
405 "Function to write PinholeCameraIntrinsic to file",
"filename"_a,
411 "read_pinhole_camera_parameters",
413 py::gil_scoped_release release;
418 "Function to read PinholeCameraParameters from file",
"filename"_a);
423 "write_pinhole_camera_parameters",
426 py::gil_scoped_release release;
429 "Function to write PinholeCameraParameters to file",
"filename"_a,
435 "read_pinhole_camera_trajectory",
437 py::gil_scoped_release release;
442 "Function to read PinholeCameraTrajectory from file",
"filename"_a);
447 "write_pinhole_camera_trajectory",
450 py::gil_scoped_release release;
454 "Function to write PinholeCameraTrajectory to file",
"filename"_a,
463 py::gil_scoped_release release;
468 "Function to read registration.Feature from file",
"filename"_a);
475 py::gil_scoped_release release;
478 "Function to write Feature to file",
"filename"_a,
"feature"_a);
485 py::gil_scoped_release release;
490 "Function to read PoseGraph from file",
"filename"_a);
498 py::gil_scoped_release release;
501 "Function to write PoseGraph to file",
"filename"_a,
506 #ifdef BUILD_AZURE_KINECT
508 "read_azure_kinect_sensor_config",
515 "Invalid sensor config {}, using default instead",
521 "Function to read Azure Kinect sensor config from file",
527 "write_azure_kinect_sensor_config",
531 "Function to write Azure Kinect sensor config to file",
532 "filename"_a,
"config"_a);
537 "read_azure_kinect_mkv_metadata",
544 "Invalid mkv metadata {}, using default instead",
550 "Function to read Azure Kinect metadata from file",
"filename"_a);
555 "write_azure_kinect_mkv_metadata",
559 "Function to write Azure Kinect metadata to file",
"filename"_a,
std::shared_ptr< core::Tensor > image
filament::Texture::InternalFormat format
Array of compressed 3D normals (single index)
Hierarchical CLOUDVIEWER Object.
NormsIndexesTableType * getTriNormsTable() const override
Returns per-triangle normals shared array.
void shrinkToFit()
Removes unused capacity.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Contains the pinhole camera intrinsic parameters.
Contains both intrinsic and extrinsic pinhole camera parameters.
The Image class stores image with customizable width, height, num of channels and bytes per channel.
LineSet define a sets of lines in 3D. A typical application is to display the point cloud corresponde...
VoxelGrid is a collection of voxels which are aligned in grid.
Data structure defining the pose graph.
Class to store featrues for registration.
__host__ __device__ float length(float2 v)
void FunctionDocInject(py::module &pybind_module, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
bool ReadPoseGraph(const std::string &filename, pipelines::registration::PoseGraph &pose_graph)
bool ReadFeature(const std::string &filename, utility::Feature &feature)
bool WriteIJsonConvertible(const std::string &filename, const cloudViewer::utility::IJsonConvertible &object)
bool WriteFeature(const std::string &filename, const utility::Feature &feature)
bool WriteTriangleMesh(const std::string &filename, const ccMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
bool WriteImage(const std::string &filename, const geometry::Image &image, int quality=kCloudViewerImageIODefaultQuality)
bool WriteOctree(const std::string &filename, const geometry::Octree &octree)
constexpr int kCloudViewerImageIODefaultQuality
static const std::unordered_map< std::string, std::string > map_shared_argument_docstrings
FileGeometry ReadFileGeometryType(const std::string &path)
bool ReadPointCloud(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
bool ReadPinholeCameraTrajectory(const std::string &filename, camera::PinholeCameraTrajectory &trajectory)
bool ReadImage(const std::string &filename, geometry::Image &image)
bool ReadTriangleModel(const std::string &filename, visualization::rendering::TriangleMeshModel &model, ReadTriangleModelOptions params)
bool WritePointCloud(const std::string &filename, const ccPointCloud &pointcloud, const WritePointCloudOption ¶ms)
bool WriteVoxelGrid(const std::string &filename, const geometry::VoxelGrid &voxelgrid, bool write_ascii=false, bool compressed=false, bool print_progress=false)
bool WritePinholeCameraTrajectory(const std::string &filename, const camera::PinholeCameraTrajectory &trajectory)
bool ReadEntity(const std::string &filename, ccHObject &obj, const std::string &format="auto", bool print_progress=false)
bool WriteLineSet(const std::string &filename, const geometry::LineSet &lineset, bool write_ascii=false, bool compressed=false, bool print_progress=false)
bool WriteIJsonConvertibleToJSON(const std::string &filename, const cloudViewer::utility::IJsonConvertible &object)
bool ReadLineSet(const std::string &filename, geometry::LineSet &lineset, const std::string &format="auto", bool print_progress=false)
bool ReadIJsonConvertibleFromJSON(const std::string &filename, cloudViewer::utility::IJsonConvertible &object)
bool ReadIJsonConvertible(const std::string &filename, cloudViewer::utility::IJsonConvertible &object)
bool WriteEntity(const std::string &filename, const ccHObject &obj, bool write_ascii=false, bool compressed=false, bool print_progress=false)
void pybind_class_io(py::module &m_io)
bool ReadVoxelGrid(const std::string &filename, geometry::VoxelGrid &voxelgrid, const std::string &format="auto", bool print_progress=false)
bool ReadTriangleMesh(const std::string &filename, ccMesh &mesh, ReadTriangleMeshOptions params)
bool WritePoseGraph(const std::string &filename, const pipelines::registration::PoseGraph &pose_graph)
bool ReadOctree(const std::string &filename, geometry::Octree &octree, const std::string &format="auto")
static const std::string path
Generic file read and write utility for python interface.
bool enable_post_processing
Enables post-processing on the mesh.