Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
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& intrinsics,
53  const core::Tensor& extrinsics,
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& intrinsics,
75  const core::Tensor& extrinsics,
76  index_t resolution,
77  float voxel_size,
78  float sdf_trunc,
79  float depth_scale,
80  float depth_max);
81 
82 void RayCast(std::shared_ptr<core::HashMap>& hashmap,
83  const TensorMap& block_value_map,
84  const core::Tensor& range_map,
85  TensorMap& renderings_map,
86  const core::Tensor& intrinsics,
87  const core::Tensor& extrinsics,
88  index_t h,
89  index_t w,
90  index_t block_resolution,
91  float voxel_size,
92  float sdf_trunc,
93  float depth_scale,
94  float depth_min,
95  float depth_max,
96  float weight_threshold);
97 
98 void ExtractPointCloud(const core::Tensor& block_indices,
99  const core::Tensor& nb_block_indices,
100  const core::Tensor& nb_block_masks,
101  const core::Tensor& block_keys,
102  const TensorMap& block_value_map,
104  core::Tensor& normals,
105  core::Tensor& colors,
106  index_t block_resolution,
107  float voxel_size,
108  float weight_threshold,
109  index_t& valid_size);
110 
111 void ExtractTriangleMesh(const core::Tensor& block_indices,
112  const core::Tensor& inv_block_indices,
113  const core::Tensor& nb_block_indices,
114  const core::Tensor& nb_block_masks,
115  const core::Tensor& block_keys,
116  const TensorMap& block_value_map,
117  core::Tensor& vertices,
118  core::Tensor& triangles,
119  core::Tensor& vertex_normals,
120  core::Tensor& vertex_colors,
121  index_t block_resolution,
122  float voxel_size,
123  float weight_threshold,
124  index_t& vertex_count);
125 
127 void PointCloudTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
128  const core::Tensor& points,
129  core::Tensor& voxel_block_coords,
130  index_t voxel_grid_resolution,
131  float voxel_size,
132  float sdf_trunc);
133 
134 void DepthTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
135  const core::Tensor& depth,
136  const core::Tensor& intrinsics,
137  const core::Tensor& extrinsics,
138  core::Tensor& voxel_block_coords,
139  index_t voxel_grid_resolution,
140  float voxel_size,
141  float sdf_trunc,
142  float depth_scale,
143  float depth_max,
144  index_t stride);
145 
147  const core::Tensor& block_keys,
148  core::Tensor& voxel_coords,
149  core::Tensor& flattened_indices,
150  index_t block_resolution,
151  float voxel_size);
152 
153 template <typename input_depth_t,
154  typename input_color_t,
155  typename tsdf_t,
156  typename weight_t,
157  typename color_t>
158 void IntegrateCPU(const core::Tensor& depth,
159  const core::Tensor& color,
160  const core::Tensor& block_indices,
161  const core::Tensor& block_keys,
162  TensorMap& block_value_map,
163  const core::Tensor& intrinsics,
164  const core::Tensor& extrinsics,
165  index_t resolution,
166  float voxel_size,
167  float sdf_trunc,
168  float depth_scale,
169  float depth_max);
170 
171 template <typename tsdf_t, typename weight_t, typename color_t>
172 void RayCastCPU(std::shared_ptr<core::HashMap>& hashmap,
173  const TensorMap& block_value_map,
174  const core::Tensor& range_map,
175  TensorMap& renderings_map,
176  const core::Tensor& intrinsics,
177  const core::Tensor& extrinsics,
178  index_t h,
179  index_t w,
180  index_t block_resolution,
181  float voxel_size,
182  float sdf_trunc,
183  float depth_scale,
184  float depth_min,
185  float depth_max,
186  float weight_threshold);
187 
188 template <typename tsdf_t, typename weight_t, typename color_t>
189 void ExtractPointCloudCPU(const core::Tensor& block_indices,
190  const core::Tensor& nb_block_indices,
191  const core::Tensor& nb_block_masks,
192  const core::Tensor& block_keys,
193  const TensorMap& block_value_map,
195  core::Tensor& normals,
196  core::Tensor& colors,
197  index_t block_resolution,
198  float voxel_size,
199  float weight_threshold,
200  index_t& valid_size);
201 
202 template <typename tsdf_t, typename weight_t, typename color_t>
203 void ExtractTriangleMeshCPU(const core::Tensor& block_indices,
204  const core::Tensor& inv_block_indices,
205  const core::Tensor& nb_block_indices,
206  const core::Tensor& nb_block_masks,
207  const core::Tensor& block_keys,
208  const TensorMap& block_value_map,
209  core::Tensor& vertices,
210  core::Tensor& triangles,
211  core::Tensor& vertex_normals,
212  core::Tensor& vertex_colors,
213  index_t block_resolution,
214  float voxel_size,
215  float weight_threshold,
216  index_t& vertex_count);
217 
218 #ifdef BUILD_CUDA_MODULE
219 void PointCloudTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
220  const core::Tensor& points,
221  core::Tensor& voxel_block_coords,
222  index_t voxel_grid_resolution,
223  float voxel_size,
224  float sdf_trunc);
225 
226 void DepthTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
227  const core::Tensor& depth,
228  const core::Tensor& intrinsics,
229  const core::Tensor& extrinsics,
230  core::Tensor& voxel_block_coords,
231  index_t voxel_grid_resolution,
232  float voxel_size,
233  float sdf_trunc,
234  float depth_scale,
235  float depth_max,
236  index_t stride);
237 
238 void GetVoxelCoordinatesAndFlattenedIndicesCUDA(const core::Tensor& buf_indices,
239  const core::Tensor& block_keys,
240  core::Tensor& voxel_coords,
241  core::Tensor& flattened_indices,
242  index_t block_resolution,
243  float voxel_size);
244 
245 template <typename input_depth_t,
246  typename input_color_t,
247  typename tsdf_t,
248  typename weight_t,
249  typename color_t>
250 void IntegrateCUDA(const core::Tensor& depth,
251  const core::Tensor& color,
252  const core::Tensor& block_indices,
253  const core::Tensor& block_keys,
254  TensorMap& block_value_map,
255  const core::Tensor& intrinsics,
256  const core::Tensor& extrinsics,
257  index_t resolution,
258  float voxel_size,
259  float sdf_trunc,
260  float depth_scale,
261  float depth_max);
262 
263 template <typename tsdf_t, typename weight_t, typename color_t>
264 void RayCastCUDA(std::shared_ptr<core::HashMap>& hashmap,
265  const TensorMap& block_value_map,
266  const core::Tensor& range_map,
267  TensorMap& renderings_map,
268  const core::Tensor& intrinsics,
269  const core::Tensor& extrinsics,
270  index_t h,
271  index_t w,
272  index_t block_resolution,
273  float voxel_size,
274  float sdf_trunc,
275  float depth_scale,
276  float depth_min,
277  float depth_max,
278  float weight_threshold);
279 
280 template <typename tsdf_t, typename weight_t, typename color_t>
281 void ExtractPointCloudCUDA(const core::Tensor& block_indices,
282  const core::Tensor& nb_block_indices,
283  const core::Tensor& nb_block_masks,
284  const core::Tensor& block_keys,
285  const TensorMap& block_value_map,
287  core::Tensor& normals,
288  core::Tensor& colors,
289  index_t block_resolution,
290  float voxel_size,
291  float weight_threshold,
292  index_t& valid_size);
293 
294 template <typename tsdf_t, typename weight_t, typename color_t>
295 void ExtractTriangleMeshCUDA(const core::Tensor& block_indices,
296  const core::Tensor& inv_block_indices,
297  const core::Tensor& nb_block_indices,
298  const core::Tensor& nb_block_masks,
299  const core::Tensor& block_keys,
300  const TensorMap& block_value_map,
301  core::Tensor& vertices,
302  core::Tensor& triangles,
303  core::Tensor& vertex_normals,
304  core::Tensor& vertex_colors,
305  index_t block_resolution,
306  float voxel_size,
307  float weight_threshold,
308  index_t& vertex_count);
309 
310 #endif
311 } // namespace voxel_grid
312 } // namespace kernel
313 } // namespace geometry
314 } // namespace t
315 } // namespace open3d
void RayCastCPU(std::shared_ptr< core::HashMap > &hashmap, const TensorMap &block_value_map, const core::Tensor &range_map, TensorMap &renderings_map, const core::Tensor &intrinsics, const core::Tensor &extrinsics, index_t h, index_t w, index_t block_resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_min, float depth_max, float weight_threshold)
Definition: VoxelBlockGridImpl.h:325
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 sdf_trunc, float depth_scale, float depth_min, float depth_max, float weight_threshold)
Definition: VoxelBlockGrid.cpp:209
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:314
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 &intrinsics, const core::Tensor &extrinsics, index_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: VoxelBlockGridImpl.h:168
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 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 &intrinsic, const core::Tensor &extrinsic, index_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: VoxelBlockGrid.cpp:143
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:1076
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:819
math::float4 color
Definition: LineSetBuffers.cpp:64
void DepthTouchCPU(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &depth, const core::Tensor &intrinsics, const core::Tensor &extrinsics, 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 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:62
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:479
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:88
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:263
Definition: TensorMap.h:49