Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.16.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VoxelBlockGrid.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018-2021 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <unordered_map>
30 
31 #include "open3d/core/Tensor.h"
34 
35 namespace open3d {
36 namespace t {
37 namespace geometry {
38 namespace kernel {
39 namespace voxel_grid {
40 
41 using index_t = int;
42 
43 void PointCloudTouch(std::shared_ptr<core::HashMap>& hashmap,
44  const core::Tensor& points,
45  core::Tensor& voxel_block_coords,
46  index_t voxel_grid_resolution,
47  float voxel_size,
48  float sdf_trunc);
49 
50 void DepthTouch(std::shared_ptr<core::HashMap>& hashmap,
51  const core::Tensor& depth,
52  const core::Tensor& intrinsic,
53  const core::Tensor& extrinsic,
54  core::Tensor& voxel_block_coords,
55  index_t voxel_grid_resolution,
56  float voxel_size,
57  float sdf_trunc,
58  float depth_scale,
59  float depth_max,
60  index_t stride);
61 
63  const core::Tensor& block_keys,
64  core::Tensor& voxel_coords,
65  core::Tensor& flattened_indices,
66  index_t block_resolution,
67  float voxel_size);
68 
69 void Integrate(const core::Tensor& depth,
70  const core::Tensor& color,
71  const core::Tensor& block_indices,
72  const core::Tensor& block_keys,
73  TensorMap& block_value_map,
74  const core::Tensor& depth_intrinsic,
75  const core::Tensor& color_intrinsic,
76  const core::Tensor& extrinsic,
77  index_t resolution,
78  float voxel_size,
79  float sdf_trunc,
80  float depth_scale,
81  float depth_max);
82 
83 void EstimateRange(const core::Tensor& block_keys,
84  core::Tensor& range_minmax_map,
85  const core::Tensor& intrinsics,
86  const core::Tensor& extrinsics,
87  int h,
88  int w,
89  int down_factor,
90  int64_t block_resolution,
91  float voxel_size,
92  float depth_min,
93  float depth_max,
94  core::Tensor& fragment_buffer);
95 
96 void RayCast(std::shared_ptr<core::HashMap>& hashmap,
97  const TensorMap& block_value_map,
98  const core::Tensor& range_map,
99  TensorMap& renderings_map,
100  const core::Tensor& intrinsic,
101  const core::Tensor& extrinsic,
102  index_t h,
103  index_t w,
104  index_t block_resolution,
105  float voxel_size,
106  float depth_scale,
107  float depth_min,
108  float depth_max,
109  float weight_threshold,
110  float trunc_voxel_multiplier,
111  int range_map_down_factor);
112 
113 void ExtractPointCloud(const core::Tensor& block_indices,
114  const core::Tensor& nb_block_indices,
115  const core::Tensor& nb_block_masks,
116  const core::Tensor& block_keys,
117  const TensorMap& block_value_map,
119  core::Tensor& normals,
120  core::Tensor& colors,
121  index_t block_resolution,
122  float voxel_size,
123  float weight_threshold,
124  index_t& valid_size);
125 
126 void ExtractTriangleMesh(const core::Tensor& block_indices,
127  const core::Tensor& inv_block_indices,
128  const core::Tensor& nb_block_indices,
129  const core::Tensor& nb_block_masks,
130  const core::Tensor& block_keys,
131  const TensorMap& block_value_map,
132  core::Tensor& vertices,
133  core::Tensor& triangles,
134  core::Tensor& vertex_normals,
135  core::Tensor& vertex_colors,
136  index_t block_resolution,
137  float voxel_size,
138  float weight_threshold,
139  index_t& vertex_count);
140 
142 void PointCloudTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
143  const core::Tensor& points,
144  core::Tensor& voxel_block_coords,
145  index_t voxel_grid_resolution,
146  float voxel_size,
147  float sdf_trunc);
148 
149 void DepthTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
150  const core::Tensor& depth,
151  const core::Tensor& intrinsic,
152  const core::Tensor& extrinsic,
153  core::Tensor& voxel_block_coords,
154  index_t voxel_grid_resolution,
155  float voxel_size,
156  float sdf_trunc,
157  float depth_scale,
158  float depth_max,
159  index_t stride);
160 
162  const core::Tensor& block_keys,
163  core::Tensor& voxel_coords,
164  core::Tensor& flattened_indices,
165  index_t block_resolution,
166  float voxel_size);
167 
168 template <typename input_depth_t,
169  typename input_color_t,
170  typename tsdf_t,
171  typename weight_t,
172  typename color_t>
173 void IntegrateCPU(const core::Tensor& depth,
174  const core::Tensor& color,
175  const core::Tensor& block_indices,
176  const core::Tensor& block_keys,
177  TensorMap& block_value_map,
178  const core::Tensor& depth_intrinsic,
179  const core::Tensor& color_intrinsic,
180  const core::Tensor& extrinsic,
181  index_t resolution,
182  float voxel_size,
183  float sdf_trunc,
184  float depth_scale,
185  float depth_max);
186 
187 void EstimateRangeCPU(const core::Tensor& block_keys,
188  core::Tensor& range_minmax_map,
189  const core::Tensor& intrinsics,
190  const core::Tensor& extrinsics,
191  int h,
192  int w,
193  int down_factor,
194  int64_t block_resolution,
195  float voxel_size,
196  float depth_min,
197  float depth_max,
198  core::Tensor& fragment_buffer);
199 
200 template <typename tsdf_t, typename weight_t, typename color_t>
201 void RayCastCPU(std::shared_ptr<core::HashMap>& hashmap,
202  const TensorMap& block_value_map,
203  const core::Tensor& range_map,
204  TensorMap& renderings_map,
205  const core::Tensor& intrinsic,
206  const core::Tensor& extrinsic,
207  index_t h,
208  index_t w,
209  index_t block_resolution,
210  float voxel_size,
211  float depth_scale,
212  float depth_min,
213  float depth_max,
214  float weight_threshold,
215  float trunc_voxel_multiplier,
216  int range_map_down_factor);
217 
218 template <typename tsdf_t, typename weight_t, typename color_t>
219 void ExtractPointCloudCPU(const core::Tensor& block_indices,
220  const core::Tensor& nb_block_indices,
221  const core::Tensor& nb_block_masks,
222  const core::Tensor& block_keys,
223  const TensorMap& block_value_map,
225  core::Tensor& normals,
226  core::Tensor& colors,
227  index_t block_resolution,
228  float voxel_size,
229  float weight_threshold,
230  index_t& valid_size);
231 
232 template <typename tsdf_t, typename weight_t, typename color_t>
233 void ExtractTriangleMeshCPU(const core::Tensor& block_indices,
234  const core::Tensor& inv_block_indices,
235  const core::Tensor& nb_block_indices,
236  const core::Tensor& nb_block_masks,
237  const core::Tensor& block_keys,
238  const TensorMap& block_value_map,
239  core::Tensor& vertices,
240  core::Tensor& triangles,
241  core::Tensor& vertex_normals,
242  core::Tensor& vertex_colors,
243  index_t block_resolution,
244  float voxel_size,
245  float weight_threshold,
246  index_t& vertex_count);
247 
248 #ifdef BUILD_CUDA_MODULE
249 void PointCloudTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
250  const core::Tensor& points,
251  core::Tensor& voxel_block_coords,
252  index_t voxel_grid_resolution,
253  float voxel_size,
254  float sdf_trunc);
255 
256 void DepthTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
257  const core::Tensor& depth,
258  const core::Tensor& intrinsic,
259  const core::Tensor& extrinsic,
260  core::Tensor& voxel_block_coords,
261  index_t voxel_grid_resolution,
262  float voxel_size,
263  float sdf_trunc,
264  float depth_scale,
265  float depth_max,
266  index_t stride);
267 
268 void GetVoxelCoordinatesAndFlattenedIndicesCUDA(const core::Tensor& buf_indices,
269  const core::Tensor& block_keys,
270  core::Tensor& voxel_coords,
271  core::Tensor& flattened_indices,
272  index_t block_resolution,
273  float voxel_size);
274 
275 template <typename input_depth_t,
276  typename input_color_t,
277  typename tsdf_t,
278  typename weight_t,
279  typename color_t>
280 void IntegrateCUDA(const core::Tensor& depth,
281  const core::Tensor& color,
282  const core::Tensor& block_indices,
283  const core::Tensor& block_keys,
284  TensorMap& block_value_map,
285  const core::Tensor& depth_intrinsic,
286  const core::Tensor& color_intrinsic,
287  const core::Tensor& extrinsic,
288  index_t resolution,
289  float voxel_size,
290  float sdf_trunc,
291  float depth_scale,
292  float depth_max);
293 
294 void EstimateRangeCUDA(const core::Tensor& block_keys,
295  core::Tensor& range_minmax_map,
296  const core::Tensor& intrinsics,
297  const core::Tensor& extrinsics,
298  int h,
299  int w,
300  int down_factor,
301  int64_t block_resolution,
302  float voxel_size,
303  float depth_min,
304  float depth_max,
305  core::Tensor& fragment_buffer);
306 
307 template <typename tsdf_t, typename weight_t, typename color_t>
308 void RayCastCUDA(std::shared_ptr<core::HashMap>& hashmap,
309  const TensorMap& block_value_map,
310  const core::Tensor& range_map,
311  TensorMap& renderings_map,
312  const core::Tensor& intrinsic,
313  const core::Tensor& extrinsic,
314  index_t h,
315  index_t w,
316  index_t block_resolution,
317  float voxel_size,
318  float depth_scale,
319  float depth_min,
320  float depth_max,
321  float weight_threshold,
322  float trunc_voxel_multiplier,
323  int range_map_down_factor);
324 
325 template <typename tsdf_t, typename weight_t, typename color_t>
326 void ExtractPointCloudCUDA(const core::Tensor& block_indices,
327  const core::Tensor& nb_block_indices,
328  const core::Tensor& nb_block_masks,
329  const core::Tensor& block_keys,
330  const TensorMap& block_value_map,
332  core::Tensor& normals,
333  core::Tensor& colors,
334  index_t block_resolution,
335  float voxel_size,
336  float weight_threshold,
337  index_t& valid_size);
338 
339 template <typename tsdf_t, typename weight_t, typename color_t>
340 void ExtractTriangleMeshCUDA(const core::Tensor& block_indices,
341  const core::Tensor& inv_block_indices,
342  const core::Tensor& nb_block_indices,
343  const core::Tensor& nb_block_masks,
344  const core::Tensor& block_keys,
345  const TensorMap& block_value_map,
346  core::Tensor& vertices,
347  core::Tensor& triangles,
348  core::Tensor& vertex_normals,
349  core::Tensor& vertex_colors,
350  index_t block_resolution,
351  float voxel_size,
352  float weight_threshold,
353  index_t& vertex_count);
354 
355 #endif
356 } // namespace voxel_grid
357 } // namespace kernel
358 } // namespace geometry
359 } // namespace t
360 } // namespace open3d
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:136
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:144
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:351
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:560
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:74
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:1316
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:212
int points
Definition: FilePCD.cpp:73
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:1059
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:168
math::float4 color
Definition: LineSetBuffers.cpp:64
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:57
int index_t
Definition: VoxelBlockGrid.h:41
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:60
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:489
size_t stride
Definition: TriangleMeshBuffers.cpp:184
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:43
Definition: PinholeCameraIntrinsic.cpp:35
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:84
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:301
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:320
Definition: TensorMap.h:50
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:245