Open3D (C++ API)  0.15.1
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
35namespace open3d {
36namespace t {
37namespace geometry {
38namespace kernel {
39namespace voxel_grid {
40
41using index_t = int;
42
43void 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
50void 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,
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
69void 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
83void 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
95void RayCast(std::shared_ptr<core::HashMap>& hashmap,
96 const TensorMap& block_value_map,
97 const core::Tensor& range_map,
98 TensorMap& renderings_map,
99 const core::Tensor& intrinsic,
100 const core::Tensor& extrinsic,
101 index_t h,
102 index_t w,
103 index_t block_resolution,
104 float voxel_size,
105 float depth_scale,
106 float depth_min,
107 float depth_max,
108 float weight_threshold,
109 float trunc_voxel_multiplier,
110 int range_map_down_factor);
111
112void ExtractPointCloud(const core::Tensor& 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,
118 core::Tensor& normals,
119 core::Tensor& colors,
120 index_t block_resolution,
121 float voxel_size,
122 float weight_threshold,
123 index_t& valid_size);
124
125void ExtractTriangleMesh(const core::Tensor& block_indices,
126 const core::Tensor& inv_block_indices,
127 const core::Tensor& nb_block_indices,
128 const core::Tensor& nb_block_masks,
129 const core::Tensor& block_keys,
130 const TensorMap& block_value_map,
131 core::Tensor& vertices,
132 core::Tensor& triangles,
133 core::Tensor& vertex_normals,
134 core::Tensor& vertex_colors,
135 index_t block_resolution,
136 float voxel_size,
137 float weight_threshold,
138 index_t& vertex_count);
139
141void PointCloudTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
142 const core::Tensor& points,
143 core::Tensor& voxel_block_coords,
144 index_t voxel_grid_resolution,
145 float voxel_size,
146 float sdf_trunc);
147
148void DepthTouchCPU(std::shared_ptr<core::HashMap>& hashmap,
149 const core::Tensor& depth,
150 const core::Tensor& intrinsic,
151 const core::Tensor& extrinsic,
152 core::Tensor& voxel_block_coords,
153 index_t voxel_grid_resolution,
154 float voxel_size,
155 float sdf_trunc,
156 float depth_scale,
157 float depth_max,
159
161 const core::Tensor& block_keys,
162 core::Tensor& voxel_coords,
163 core::Tensor& flattened_indices,
164 index_t block_resolution,
165 float voxel_size);
166
167template <typename input_depth_t,
168 typename input_color_t,
169 typename tsdf_t,
170 typename weight_t,
171 typename color_t>
172void IntegrateCPU(const core::Tensor& depth,
173 const core::Tensor& color,
174 const core::Tensor& block_indices,
175 const core::Tensor& block_keys,
176 TensorMap& block_value_map,
177 const core::Tensor& depth_intrinsic,
178 const core::Tensor& color_intrinsic,
179 const core::Tensor& extrinsic,
180 index_t resolution,
181 float voxel_size,
182 float sdf_trunc,
183 float depth_scale,
184 float depth_max);
185
186void EstimateRangeCPU(const core::Tensor& block_keys,
187 core::Tensor& range_minmax_map,
188 const core::Tensor& intrinsics,
189 const core::Tensor& extrinsics,
190 int h,
191 int w,
192 int down_factor,
193 int64_t block_resolution,
194 float voxel_size,
195 float depth_min,
196 float depth_max);
197
198template <typename tsdf_t, typename weight_t, typename color_t>
199void RayCastCPU(std::shared_ptr<core::HashMap>& hashmap,
200 const TensorMap& block_value_map,
201 const core::Tensor& range_map,
202 TensorMap& renderings_map,
203 const core::Tensor& intrinsic,
204 const core::Tensor& extrinsic,
205 index_t h,
206 index_t w,
207 index_t block_resolution,
208 float voxel_size,
209 float depth_scale,
210 float depth_min,
211 float depth_max,
212 float weight_threshold,
213 float trunc_voxel_multiplier,
214 int range_map_down_factor);
215
216template <typename tsdf_t, typename weight_t, typename color_t>
217void ExtractPointCloudCPU(const core::Tensor& block_indices,
218 const core::Tensor& nb_block_indices,
219 const core::Tensor& nb_block_masks,
220 const core::Tensor& block_keys,
221 const TensorMap& block_value_map,
223 core::Tensor& normals,
224 core::Tensor& colors,
225 index_t block_resolution,
226 float voxel_size,
227 float weight_threshold,
228 index_t& valid_size);
229
230template <typename tsdf_t, typename weight_t, typename color_t>
231void ExtractTriangleMeshCPU(const core::Tensor& block_indices,
232 const core::Tensor& inv_block_indices,
233 const core::Tensor& nb_block_indices,
234 const core::Tensor& nb_block_masks,
235 const core::Tensor& block_keys,
236 const TensorMap& block_value_map,
237 core::Tensor& vertices,
238 core::Tensor& triangles,
239 core::Tensor& vertex_normals,
240 core::Tensor& vertex_colors,
241 index_t block_resolution,
242 float voxel_size,
243 float weight_threshold,
244 index_t& vertex_count);
245
246#ifdef BUILD_CUDA_MODULE
247void PointCloudTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
248 const core::Tensor& points,
249 core::Tensor& voxel_block_coords,
250 index_t voxel_grid_resolution,
251 float voxel_size,
252 float sdf_trunc);
253
254void DepthTouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
255 const core::Tensor& depth,
256 const core::Tensor& intrinsic,
257 const core::Tensor& extrinsic,
258 core::Tensor& voxel_block_coords,
259 index_t voxel_grid_resolution,
260 float voxel_size,
261 float sdf_trunc,
262 float depth_scale,
263 float depth_max,
265
266void GetVoxelCoordinatesAndFlattenedIndicesCUDA(const core::Tensor& buf_indices,
267 const core::Tensor& block_keys,
268 core::Tensor& voxel_coords,
269 core::Tensor& flattened_indices,
270 index_t block_resolution,
271 float voxel_size);
272
273template <typename input_depth_t,
274 typename input_color_t,
275 typename tsdf_t,
276 typename weight_t,
277 typename color_t>
278void IntegrateCUDA(const core::Tensor& depth,
279 const core::Tensor& color,
280 const core::Tensor& block_indices,
281 const core::Tensor& block_keys,
282 TensorMap& block_value_map,
283 const core::Tensor& depth_intrinsic,
284 const core::Tensor& color_intrinsic,
285 const core::Tensor& extrinsic,
286 index_t resolution,
287 float voxel_size,
288 float sdf_trunc,
289 float depth_scale,
290 float depth_max);
291
292void EstimateRangeCUDA(const core::Tensor& block_keys,
293 core::Tensor& range_minmax_map,
294 const core::Tensor& intrinsics,
295 const core::Tensor& extrinsics,
296 int h,
297 int w,
298 int down_factor,
299 int64_t block_resolution,
300 float voxel_size,
301 float depth_min,
302 float depth_max);
303
304template <typename tsdf_t, typename weight_t, typename color_t>
305void RayCastCUDA(std::shared_ptr<core::HashMap>& hashmap,
306 const TensorMap& block_value_map,
307 const core::Tensor& range_map,
308 TensorMap& renderings_map,
309 const core::Tensor& intrinsic,
310 const core::Tensor& extrinsic,
311 index_t h,
312 index_t w,
313 index_t block_resolution,
314 float voxel_size,
315 float depth_scale,
316 float depth_min,
317 float depth_max,
318 float weight_threshold,
319 float trunc_voxel_multiplier,
320 int range_map_down_factor);
321
322template <typename tsdf_t, typename weight_t, typename color_t>
323void ExtractPointCloudCUDA(const core::Tensor& block_indices,
324 const core::Tensor& nb_block_indices,
325 const core::Tensor& nb_block_masks,
326 const core::Tensor& block_keys,
327 const TensorMap& block_value_map,
329 core::Tensor& normals,
330 core::Tensor& colors,
331 index_t block_resolution,
332 float voxel_size,
333 float weight_threshold,
334 index_t& valid_size);
335
336template <typename tsdf_t, typename weight_t, typename color_t>
337void ExtractTriangleMeshCUDA(const core::Tensor& block_indices,
338 const core::Tensor& inv_block_indices,
339 const core::Tensor& nb_block_indices,
340 const core::Tensor& nb_block_masks,
341 const core::Tensor& block_keys,
342 const TensorMap& block_value_map,
343 core::Tensor& vertices,
344 core::Tensor& triangles,
345 core::Tensor& vertex_normals,
346 core::Tensor& vertex_colors,
347 index_t block_resolution,
348 float voxel_size,
349 float weight_threshold,
350 index_t& vertex_count);
351
352#endif
353} // namespace voxel_grid
354} // namespace kernel
355} // namespace geometry
356} // namespace t
357} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
size_t stride
Definition: TriangleMeshBuffers.cpp:184
Definition: Tensor.h:51
Definition: TensorMap.h:49
int points
Definition: FilePCD.cpp:73
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:493
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:1031
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
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
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:150
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:361
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:310
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)
Definition: VoxelBlockGrid.cpp:219
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:253
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 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
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)
Definition: VoxelBlockGridImpl.h:320
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:1288
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
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:532
int index_t
Definition: VoxelBlockGrid.h:41
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
Definition: PinholeCameraIntrinsic.cpp:35