Open3D (C++ API)  0.17.0
VoxelBlockGrid.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <unordered_map>
11 
12 #include "open3d/core/Tensor.h"
15 
16 namespace open3d {
17 namespace t {
18 namespace geometry {
19 namespace kernel {
20 namespace voxel_grid {
21 
22 using index_t = int;
23 
24 void PointCloudTouch(std::shared_ptr<core::HashMap>& hashmap,
25  const core::Tensor& points,
26  core::Tensor& voxel_block_coords,
27  index_t voxel_grid_resolution,
28  float voxel_size,
29  float sdf_trunc);
30 
31 void DepthTouch(std::shared_ptr<core::HashMap>& hashmap,
32  const core::Tensor& depth,
33  const core::Tensor& intrinsic,
34  const core::Tensor& extrinsic,
35  core::Tensor& voxel_block_coords,
36  index_t voxel_grid_resolution,
37  float voxel_size,
38  float sdf_trunc,
39  float depth_scale,
40  float depth_max,
41  index_t stride);
42 
44  const core::Tensor& block_keys,
45  core::Tensor& voxel_coords,
46  core::Tensor& flattened_indices,
47  index_t block_resolution,
48  float voxel_size);
49 
50 void Integrate(const core::Tensor& depth,
51  const core::Tensor& color,
52  const core::Tensor& block_indices,
53  const core::Tensor& block_keys,
54  TensorMap& block_value_map,
55  const core::Tensor& depth_intrinsic,
56  const core::Tensor& color_intrinsic,
57  const core::Tensor& extrinsic,
58  index_t resolution,
59  float voxel_size,
60  float sdf_trunc,
61  float depth_scale,
62  float depth_max);
63 
64 void EstimateRange(const core::Tensor& block_keys,
65  core::Tensor& range_minmax_map,
66  const core::Tensor& intrinsics,
67  const core::Tensor& extrinsics,
68  int h,
69  int w,
70  int down_factor,
71  int64_t block_resolution,
72  float voxel_size,
73  float depth_min,
74  float depth_max,
75  core::Tensor& fragment_buffer);
76 
77 void RayCast(std::shared_ptr<core::HashMap>& hashmap,
78  const TensorMap& block_value_map,
79  const core::Tensor& range_map,
80  TensorMap& renderings_map,
81  const core::Tensor& intrinsic,
82  const core::Tensor& extrinsic,
83  index_t h,
84  index_t w,
85  index_t block_resolution,
86  float voxel_size,
87  float depth_scale,
88  float depth_min,
89  float depth_max,
90  float weight_threshold,
91  float trunc_voxel_multiplier,
92  int range_map_down_factor);
93 
94 void ExtractPointCloud(const core::Tensor& block_indices,
95  const core::Tensor& nb_block_indices,
96  const core::Tensor& nb_block_masks,
97  const core::Tensor& block_keys,
98  const TensorMap& block_value_map,
100  core::Tensor& normals,
101  core::Tensor& colors,
102  index_t block_resolution,
103  float voxel_size,
104  float weight_threshold,
105  index_t& valid_size);
106 
107 void ExtractTriangleMesh(const core::Tensor& block_indices,
108  const core::Tensor& inv_block_indices,
109  const core::Tensor& nb_block_indices,
110  const core::Tensor& nb_block_masks,
111  const core::Tensor& block_keys,
112  const TensorMap& block_value_map,
113  core::Tensor& vertices,
114  core::Tensor& triangles,
115  core::Tensor& vertex_normals,
116  core::Tensor& vertex_colors,
117  index_t block_resolution,
118  float voxel_size,
119  float weight_threshold,
120  index_t& vertex_count);
121 
123 void PointCloudTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
124  const core::Tensor& points,
125  core::Tensor& voxel_block_coords,
126  index_t voxel_grid_resolution,
127  float voxel_size,
128  float sdf_trunc);
129 
130 void DepthTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
131  const core::Tensor& depth,
132  const core::Tensor& intrinsic,
133  const core::Tensor& extrinsic,
134  core::Tensor& voxel_block_coords,
135  index_t voxel_grid_resolution,
136  float voxel_size,
137  float sdf_trunc,
138  float depth_scale,
139  float depth_max,
140  index_t stride);
141 
143  const core::Tensor& block_keys,
144  core::Tensor& voxel_coords,
145  core::Tensor& flattened_indices,
146  index_t block_resolution,
147  float voxel_size);
148 
149 template <typename input_depth_t,
150  typename input_color_t,
151  typename tsdf_t,
152  typename weight_t,
153  typename color_t>
154 void IntegrateCPU(const core::Tensor& depth,
155  const core::Tensor& color,
156  const core::Tensor& block_indices,
157  const core::Tensor& block_keys,
158  TensorMap& block_value_map,
159  const core::Tensor& depth_intrinsic,
160  const core::Tensor& color_intrinsic,
161  const core::Tensor& extrinsic,
162  index_t resolution,
163  float voxel_size,
164  float sdf_trunc,
165  float depth_scale,
166  float depth_max);
167 
168 void EstimateRangeCPU(const core::Tensor& block_keys,
169  core::Tensor& range_minmax_map,
170  const core::Tensor& intrinsics,
171  const core::Tensor& extrinsics,
172  int h,
173  int w,
174  int down_factor,
175  int64_t block_resolution,
176  float voxel_size,
177  float depth_min,
178  float depth_max,
179  core::Tensor& fragment_buffer);
180 
181 template <typename tsdf_t, typename weight_t, typename color_t>
182 void RayCastCPU(std::shared_ptr<core::HashMap>& hashmap,
183  const TensorMap& block_value_map,
184  const core::Tensor& range_map,
185  TensorMap& renderings_map,
186  const core::Tensor& intrinsic,
187  const core::Tensor& extrinsic,
188  index_t h,
189  index_t w,
190  index_t block_resolution,
191  float voxel_size,
192  float depth_scale,
193  float depth_min,
194  float depth_max,
195  float weight_threshold,
196  float trunc_voxel_multiplier,
197  int range_map_down_factor);
198 
199 template <typename tsdf_t, typename weight_t, typename color_t>
200 void ExtractPointCloudCPU(const core::Tensor& block_indices,
201  const core::Tensor& nb_block_indices,
202  const core::Tensor& nb_block_masks,
203  const core::Tensor& block_keys,
204  const TensorMap& block_value_map,
206  core::Tensor& normals,
207  core::Tensor& colors,
208  index_t block_resolution,
209  float voxel_size,
210  float weight_threshold,
211  index_t& valid_size);
212 
213 template <typename tsdf_t, typename weight_t, typename color_t>
214 void ExtractTriangleMeshCPU(const core::Tensor& block_indices,
215  const core::Tensor& inv_block_indices,
216  const core::Tensor& nb_block_indices,
217  const core::Tensor& nb_block_masks,
218  const core::Tensor& block_keys,
219  const TensorMap& block_value_map,
220  core::Tensor& vertices,
221  core::Tensor& triangles,
222  core::Tensor& vertex_normals,
223  core::Tensor& vertex_colors,
224  index_t block_resolution,
225  float voxel_size,
226  float weight_threshold,
227  index_t& vertex_count);
228 
229 #ifdef BUILD_CUDA_MODULE
230 void PointCloudTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
231  const core::Tensor& points,
232  core::Tensor& voxel_block_coords,
233  index_t voxel_grid_resolution,
234  float voxel_size,
235  float sdf_trunc);
236 
237 void DepthTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
238  const core::Tensor& depth,
239  const core::Tensor& intrinsic,
240  const core::Tensor& extrinsic,
241  core::Tensor& voxel_block_coords,
242  index_t voxel_grid_resolution,
243  float voxel_size,
244  float sdf_trunc,
245  float depth_scale,
246  float depth_max,
247  index_t stride);
248 
249 void GetVoxelCoordinatesAndFlattenedIndicesCUDA(const core::Tensor& buf_indices,
250  const core::Tensor& block_keys,
251  core::Tensor& voxel_coords,
252  core::Tensor& flattened_indices,
253  index_t block_resolution,
254  float voxel_size);
255 
256 template <typename input_depth_t,
257  typename input_color_t,
258  typename tsdf_t,
259  typename weight_t,
260  typename color_t>
261 void IntegrateCUDA(const core::Tensor& depth,
262  const core::Tensor& color,
263  const core::Tensor& block_indices,
264  const core::Tensor& block_keys,
265  TensorMap& block_value_map,
266  const core::Tensor& depth_intrinsic,
267  const core::Tensor& color_intrinsic,
268  const core::Tensor& extrinsic,
269  index_t resolution,
270  float voxel_size,
271  float sdf_trunc,
272  float depth_scale,
273  float depth_max);
274 
275 void EstimateRangeCUDA(const core::Tensor& block_keys,
276  core::Tensor& range_minmax_map,
277  const core::Tensor& intrinsics,
278  const core::Tensor& extrinsics,
279  int h,
280  int w,
281  int down_factor,
282  int64_t block_resolution,
283  float voxel_size,
284  float depth_min,
285  float depth_max,
286  core::Tensor& fragment_buffer);
287 
288 template <typename tsdf_t, typename weight_t, typename color_t>
289 void RayCastCUDA(std::shared_ptr<core::HashMap>& hashmap,
290  const TensorMap& block_value_map,
291  const core::Tensor& range_map,
292  TensorMap& renderings_map,
293  const core::Tensor& intrinsic,
294  const core::Tensor& extrinsic,
295  index_t h,
296  index_t w,
297  index_t block_resolution,
298  float voxel_size,
299  float depth_scale,
300  float depth_min,
301  float depth_max,
302  float weight_threshold,
303  float trunc_voxel_multiplier,
304  int range_map_down_factor);
305 
306 template <typename tsdf_t, typename weight_t, typename color_t>
307 void ExtractPointCloudCUDA(const core::Tensor& block_indices,
308  const core::Tensor& nb_block_indices,
309  const core::Tensor& nb_block_masks,
310  const core::Tensor& block_keys,
311  const TensorMap& block_value_map,
313  core::Tensor& normals,
314  core::Tensor& colors,
315  index_t block_resolution,
316  float voxel_size,
317  float weight_threshold,
318  index_t& valid_size);
319 
320 template <typename tsdf_t, typename weight_t, typename color_t>
321 void ExtractTriangleMeshCUDA(const core::Tensor& block_indices,
322  const core::Tensor& inv_block_indices,
323  const core::Tensor& nb_block_indices,
324  const core::Tensor& nb_block_masks,
325  const core::Tensor& block_keys,
326  const TensorMap& block_value_map,
327  core::Tensor& vertices,
328  core::Tensor& triangles,
329  core::Tensor& vertex_normals,
330  core::Tensor& vertex_colors,
331  index_t block_resolution,
332  float voxel_size,
333  float weight_threshold,
334  index_t& vertex_count);
335 
336 #endif
337 } // namespace voxel_grid
338 } // namespace kernel
339 } // namespace geometry
340 } // namespace t
341 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
size_t stride
Definition: TriangleMeshBuffers.cpp:165
Definition: Tensor.h:32
Definition: TensorMap.h:31
int points
Definition: FilePCD.cpp:54
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:474
void ExtractPointCloudCPU(const core::Tensor &block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const TensorMap &block_value_map, core::Tensor &points, core::Tensor &normals, core::Tensor &colors, index_t block_resolution, float voxel_size, float weight_threshold, index_t &valid_size)
Definition: VoxelBlockGridImpl.h:1040
void PointCloudTouch(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &points, core::Tensor &voxel_block_coords, index_t voxel_grid_resolution, float voxel_size, float sdf_trunc)
Definition: VoxelBlockGrid.cpp:24
void GetVoxelCoordinatesAndFlattenedIndicesCPU(const core::Tensor &buf_indices, const core::Tensor &block_keys, core::Tensor &voxel_coords, core::Tensor &flattened_indices, index_t block_resolution, float voxel_size)
Definition: VoxelBlockGridImpl.h:38
void Integrate(const core::Tensor &depth, const core::Tensor &color, const core::Tensor &block_indices, const core::Tensor &block_keys, TensorMap &block_value_map, const core::Tensor &depth_intrinsic, const core::Tensor &color_intrinsic, const core::Tensor &extrinsic, index_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: VoxelBlockGrid.cpp:125
void ExtractTriangleMesh(const core::Tensor &block_indices, const core::Tensor &inv_block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const TensorMap &block_value_map, core::Tensor &vertices, core::Tensor &triangles, core::Tensor &vertex_normals, core::Tensor &vertex_colors, index_t block_resolution, float voxel_size, float weight_threshold, int &vertex_count)
Definition: VoxelBlockGrid.cpp:332
void ExtractPointCloud(const core::Tensor &block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const TensorMap &block_value_map, core::Tensor &points, core::Tensor &normals, core::Tensor &colors, index_t block_resolution, float voxel_size, float weight_threshold, int &valid_size)
Definition: VoxelBlockGrid.cpp:282
void RayCast(std::shared_ptr< core::HashMap > &hashmap, const TensorMap &block_value_map, const core::Tensor &range_map, TensorMap &renderings_map, const core::Tensor &intrinsic, const core::Tensor &extrinsic, index_t h, index_t w, index_t block_resolution, float voxel_size, float depth_scale, float depth_min, float depth_max, float weight_threshold, float trunc_voxel_multiplier, int range_map_down_factor)
Definition: VoxelBlockGrid.cpp:226
void GetVoxelCoordinatesAndFlattenedIndices(const core::Tensor &buf_indices, const core::Tensor &block_keys, core::Tensor &voxel_coords, core::Tensor &flattened_indices, index_t block_resolution, float voxel_size)
Definition: VoxelBlockGrid.cpp:65
void EstimateRange(const core::Tensor &block_keys, core::Tensor &range_minmax_map, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int h, int w, int down_factor, int64_t block_resolution, float voxel_size, float depth_min, float depth_max, core::Tensor &fragment_buffer)
Definition: VoxelBlockGrid.cpp:193
void IntegrateCPU(const core::Tensor &depth, const core::Tensor &color, const core::Tensor &block_indices, const core::Tensor &block_keys, TensorMap &block_value_map, const core::Tensor &depth_intrinsic, const core::Tensor &color_intrinsic, const core::Tensor &extrinsic, index_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: VoxelBlockGridImpl.h:149
void PointCloudTouchCPU(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &points, core::Tensor &voxel_block_coords, index_t voxel_grid_resolution, float voxel_size, float sdf_trunc)
CPU.
Definition: VoxelBlockGridCPU.cpp:55
void ExtractTriangleMeshCPU(const core::Tensor &block_indices, const core::Tensor &inv_block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const TensorMap &block_value_map, core::Tensor &vertices, core::Tensor &triangles, core::Tensor &vertex_normals, core::Tensor &vertex_colors, index_t block_resolution, float voxel_size, float weight_threshold, index_t &vertex_count)
Definition: VoxelBlockGridImpl.h:1297
void DepthTouch(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &depth, const core::Tensor &intrinsic, const core::Tensor &extrinsic, core::Tensor &voxel_block_coords, index_t voxel_grid_resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max, index_t stride)
Definition: VoxelBlockGrid.cpp:41
void RayCastCPU(std::shared_ptr< core::HashMap > &hashmap, const TensorMap &block_value_map, const core::Tensor &range_map, TensorMap &renderings_map, const core::Tensor &intrinsic, const core::Tensor &extrinsic, index_t h, index_t w, index_t block_resolution, float voxel_size, float depth_scale, float depth_min, float depth_max, float weight_threshold, float trunc_voxel_multiplier, int range_map_down_factor)
Definition: VoxelBlockGridImpl.h:541
int index_t
Definition: VoxelBlockGrid.h:22
void EstimateRangeCPU(const core::Tensor &block_keys, core::Tensor &range_minmax_map, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int h, int w, int down_factor, int64_t block_resolution, float voxel_size, float depth_min, float depth_max, core::Tensor &fragment_buffer)
Definition: VoxelBlockGridImpl.h:301
void DepthTouchCPU(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &depth, const core::Tensor &intrinsic, const core::Tensor &extrinsic, core::Tensor &voxel_block_coords, index_t voxel_grid_resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max, index_t stride)
Definition: VoxelBlockGridCPU.cpp:117
Definition: PinholeCameraIntrinsic.cpp:16