From a8416aa433620ad4af490fb835ee6431fac5d59b Mon Sep 17 00:00:00 2001 From: Jan Lebert Date: Mon, 22 Jan 2024 18:15:14 -0800 Subject: [PATCH] Add pathlib support for visualizer and DepthNoiseSimulator --- cpp/pybind/t/io/class_io.cpp | 4 ++- cpp/pybind/visualization/visualizer.cpp | 39 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/cpp/pybind/t/io/class_io.cpp b/cpp/pybind/t/io/class_io.cpp index 0c0087ce7fc..9ec88f08475 100644 --- a/cpp/pybind/t/io/class_io.cpp +++ b/cpp/pybind/t/io/class_io.cpp @@ -221,7 +221,9 @@ Example:: # Save noisy depth image (uint16) o3d.t.io.write_image("noisy_depth.png", im_dst) )"); - depth_noise_simulator.def(py::init(), + depth_noise_simulator.def(py::init([](const fs::path &fielname) { + return DepthNoiseSimulator(fielname.string()); + }), "noise_model_path"_a); depth_noise_simulator.def("simulate", &DepthNoiseSimulator::Simulate, "im_src"_a, "depth_scale"_a = 1000.0f, diff --git a/cpp/pybind/visualization/visualizer.cpp b/cpp/pybind/visualization/visualizer.cpp index dba049503f9..9370612d06c 100644 --- a/cpp/pybind/visualization/visualizer.cpp +++ b/cpp/pybind/visualization/visualizer.cpp @@ -104,20 +104,39 @@ void pybind_visualizer(py::module &m) { &Visualizer::CaptureScreenFloatBuffer, "Function to capture screen and store RGB in a float buffer", "do_render"_a = false) - .def("capture_screen_image", &Visualizer::CaptureScreenImage, - "Function to capture and save a screen image", "filename"_a, - "do_render"_a = false) + .def( + "capture_screen_image", + [](Visualizer &self, const fs::path &filename, + bool do_render) { + return self.CaptureScreenImage(filename.string(), + do_render); + }, + "Function to capture and save a screen image", "filename"_a, + "do_render"_a = false) .def("capture_depth_float_buffer", &Visualizer::CaptureDepthFloatBuffer, "Function to capture depth in a float buffer", "do_render"_a = false) - .def("capture_depth_image", &Visualizer::CaptureDepthImage, - "Function to capture and save a depth image", "filename"_a, - "do_render"_a = false, "depth_scale"_a = 1000.0) - .def("capture_depth_point_cloud", - &Visualizer::CaptureDepthPointCloud, - "Function to capture and save local point cloud", "filename"_a, - "do_render"_a = false, "convert_to_world_coordinate"_a = false) + .def( + "capture_depth_image", + [](Visualizer &self, const fs::path &filename, + bool do_render, double depth_scale) { + self.CaptureDepthImage(filename.string(), do_render, + depth_scale); + }, + "Function to capture and save a depth image", "filename"_a, + "do_render"_a = false, "depth_scale"_a = 1000.0) + .def( + "capture_depth_point_cloud", + [](Visualizer &self, const fs::path &filename, + bool do_render, bool convert_to_world_coordinate) { + self.CaptureDepthPointCloud( + filename.string(), do_render, + convert_to_world_coordinate); + }, + "Function to capture and save local point cloud", + "filename"_a, "do_render"_a = false, + "convert_to_world_coordinate"_a = false) .def("get_window_name", &Visualizer::GetWindowName) .def("get_view_status", &Visualizer::GetViewStatus, "Get the current view status as a json string of "