From 21a452f1b4785047ed2c65e604a66f99ae1d23ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= <124616582+f-dy@users.noreply.github.com> Date: Fri, 10 Mar 2023 10:20:36 -0800 Subject: [PATCH] scripts/exporter.py: export PLY compatible with PCL (#1572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * scripts/exporter.py: export PLY compatible with PCL Use the newer Open3D Tensor API to write pointclouds as float32, which are compatible with PCL (see https://github.com/isl-org/Open3D/issues/1633). fixes https://github.com/nerfstudio-project/nerfstudio/issues/1571 * exporter.py: pylint: disable=no-member fixes https://github.com/nerfstudio-project/nerfstudio/actions/runs/4377569585/jobs/7661246358#step:10:13 open3d.core.Dtype has been around since open3d 0.11.0 http://www.open3d.org/docs/0.11.0/python_api/open3d.core.Dtype.html --------- Co-authored-by: Frédéric Devernay --- scripts/exporter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/exporter.py b/scripts/exporter.py index a555de98c..cd18aa354 100644 --- a/scripts/exporter.py +++ b/scripts/exporter.py @@ -2,6 +2,8 @@ Script for exporting NeRF into other formats. """ +# pylint: disable=no-member + from __future__ import annotations import json @@ -94,7 +96,11 @@ class ExportPointCloud(Exporter): CONSOLE.print(f"[bold green]:white_check_mark: Generated {pcd}") CONSOLE.print("Saving Point Cloud...") - o3d.io.write_point_cloud(str(self.output_dir / "point_cloud.ply"), pcd) + tpcd = o3d.t.geometry.PointCloud.from_legacy(pcd) + # The legacy PLY writer converts colors to UInt8, + # let us do the same to save space. + tpcd.point.colors = (tpcd.point.colors * 255).to(o3d.core.Dtype.UInt8) + o3d.t.io.write_point_cloud(str(self.output_dir / "point_cloud.ply"), tpcd) print("\033[A\033[A") CONSOLE.print("[bold green]:white_check_mark: Saving Point Cloud")