From 061142b5543382feba0f66da73ed23dad460205e Mon Sep 17 00:00:00 2001 From: Konstantysz Date: Thu, 4 Apr 2024 09:35:59 +0200 Subject: [PATCH 1/3] Utilize set_image_no_depth --- scripts/nerfcapture2nerf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/nerfcapture2nerf.py b/scripts/nerfcapture2nerf.py index 91204ba1a..16bfdf539 100644 --- a/scripts/nerfcapture2nerf.py +++ b/scripts/nerfcapture2nerf.py @@ -70,7 +70,10 @@ class NeRFCaptureFrame(idl.IdlStruct, typename="NeRFCaptureData.NeRFCaptureFrame # ================================================================================================== def set_frame(testbed, frame_idx: int, rgb: np.ndarray, depth: np.ndarray, depth_scale: float, X_WV: np.ndarray, fx: float, fy: float, cx: float, cy: float): - testbed.nerf.training.set_image(frame_idx = frame_idx, img=rgb, depth_img=depth, depth_scale=depth_scale*testbed.nerf.training.dataset.scale) + if depth != None: + testbed.nerf.training.set_image(frame_idx = frame_idx, img=rgb, depth_img=depth, depth_scale=depth_scale*testbed.nerf.training.dataset.scale) + else: + testbed.nerf.training.set_image_no_depth(frame_idx = frame_idx, img=rgb) testbed.nerf.training.set_camera_extrinsics(frame_idx=frame_idx, camera_to_world=X_WV) testbed.nerf.training.set_camera_intrinsics(frame_idx=frame_idx, fx=fx, fy=fy, cx=cx, cy=cy) From 6d56eb98acc7fff0173384041d3d42294da6de8e Mon Sep 17 00:00:00 2001 From: Konstantysz Date: Thu, 4 Apr 2024 09:37:49 +0200 Subject: [PATCH 2/3] Add set_image_no_depth declaration --- include/neural-graphics-primitives/testbed.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/neural-graphics-primitives/testbed.h b/include/neural-graphics-primitives/testbed.h index 83e224207..9942ab0ef 100644 --- a/include/neural-graphics-primitives/testbed.h +++ b/include/neural-graphics-primitives/testbed.h @@ -728,6 +728,7 @@ class Testbed { #ifdef NGP_PYTHON void set_image(int frame_idx, pybind11::array_t img, pybind11::array_t depth_img, float depth_scale); + void set_image_no_depth(int frame_idx, pybind11::array_t img); #endif void reset_camera_extrinsics(); From 4f384a5f017319e57ed4955502b00c00933760ae Mon Sep 17 00:00:00 2001 From: Konstantysz Date: Thu, 4 Apr 2024 09:39:10 +0200 Subject: [PATCH 3/3] Add set_image_no_depth definition --- src/python_api.cu | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/python_api.cu b/src/python_api.cu index da62ecca1..ad352562a 100644 --- a/src/python_api.cu +++ b/src/python_api.cu @@ -62,6 +62,24 @@ void Testbed::Nerf::Training::set_image(int frame_idx, pybind11::array_t dataset.set_training_image(frame_idx, {(int)img_buf.shape[1], (int)img_buf.shape[0]}, (const void*)img_buf.ptr, (const float*)depth_buf.ptr, depth_scale, false, EImageDataType::Float, EDepthDataType::Float); } +void Testbed::Nerf::Training::set_image_no_depth(int frame_idx, pybind11::array_t img) { + if (frame_idx < 0 || frame_idx >= dataset.n_images) { + throw std::runtime_error{"Invalid frame index"}; + } + + py::buffer_info img_buf = img.request(); + + if (img_buf.ndim != 3) { + throw std::runtime_error{"image should be (H,W,C) where C=4"}; + } + + if (img_buf.shape[2] != 4) { + throw std::runtime_error{"image should be (H,W,C) where C=4"}; + } + + dataset.set_training_image(frame_idx, {(int)img_buf.shape[1], (int)img_buf.shape[0]}, (const void*)img_buf.ptr, nullptr, -1.0, false, EImageDataType::Float, EDepthDataType::Float); +} + void Testbed::override_sdf_training_data(py::array_t points, py::array_t distances) { py::buffer_info points_buf = points.request(); py::buffer_info distances_buf = distances.request();