Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TSDFVoxelGrid.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"
33 
34 namespace open3d {
35 namespace t {
36 namespace geometry {
37 namespace kernel {
38 namespace tsdf {
39 
40 void Touch(std::shared_ptr<core::HashMap>& hashmap,
41  const core::Tensor& points,
42  core::Tensor& voxel_block_coords,
43  int64_t voxel_grid_resolution,
44  float voxel_size,
45  float sdf_trunc);
46 
47 void Integrate(const core::Tensor& depth,
48  const core::Tensor& color,
49  const core::Tensor& block_indices,
50  const core::Tensor& block_keys,
51  core::Tensor& block_values,
52  const core::Tensor& intrinsics,
53  const core::Tensor& extrinsics,
54  int64_t resolution,
55  float voxel_size,
56  float sdf_trunc,
57  float depth_scale,
58  float depth_max);
59 
60 void EstimateRange(const core::Tensor& block_keys,
61  core::Tensor& range_minmax_map,
62  const core::Tensor& intrinsics,
63  const core::Tensor& extrinsics,
64  int h,
65  int w,
66  int down_factor,
67  int64_t block_resolution,
68  float voxel_size,
69  float depth_min,
70  float depth_max);
71 
72 void RayCast(std::shared_ptr<core::DeviceHashBackend>& hashmap,
73  const core::Tensor& block_values,
74  const core::Tensor& range_map,
75  core::Tensor& vertex_map,
76  core::Tensor& depth_map,
77  core::Tensor& color_map,
78  core::Tensor& normal_map,
79  const core::Tensor& intrinsics,
80  const core::Tensor& extrinsics,
81  int h,
82  int w,
83  int64_t block_resolution,
84  float voxel_size,
85  float sdf_trunc,
86  float depth_scale,
87  float depth_min,
88  float depth_max,
89  float weight_threshold);
90 
92  const core::Tensor& block_indices,
93  const core::Tensor& nb_block_indices,
94  const core::Tensor& nb_block_masks,
95  const core::Tensor& block_keys,
96  const core::Tensor& block_values,
98  utility::optional<std::reference_wrapper<core::Tensor>> normals,
99  utility::optional<std::reference_wrapper<core::Tensor>> colors,
100  int64_t block_resolution,
101  float voxel_size,
102  float weight_threshold,
103  int& valid_size);
104 
105 void ExtractSurfaceMesh(
106  const core::Tensor& block_indices,
107  const core::Tensor& inv_block_indices,
108  const core::Tensor& nb_block_indices,
109  const core::Tensor& nb_block_masks,
110  const core::Tensor& block_keys,
111  const core::Tensor& block_values,
112  core::Tensor& vertices,
113  core::Tensor& triangles,
114  utility::optional<std::reference_wrapper<core::Tensor>> vertex_normals,
115  utility::optional<std::reference_wrapper<core::Tensor>> vertex_colors,
116  int64_t block_resolution,
117  float voxel_size,
118  float weight_threshold,
119  int& vertex_count);
120 
121 void TouchCPU(std::shared_ptr<core::HashMap>& hashmap,
122  const core::Tensor& points,
123  core::Tensor& voxel_block_coords,
124  int64_t voxel_grid_resolution,
125  float voxel_size,
126  float sdf_trunc);
127 
128 void IntegrateCPU(const core::Tensor& depth,
129  const core::Tensor& color,
130  const core::Tensor& block_indices,
131  const core::Tensor& block_keys,
132  core::Tensor& block_values,
133  const core::Tensor& intrinsics,
134  const core::Tensor& extrinsics,
135  int64_t resolution,
136  float voxel_size,
137  float sdf_trunc,
138  float depth_scale,
139  float depth_max);
140 
141 void EstimateRangeCPU(const core::Tensor& block_keys,
142  core::Tensor& range_minmax_map,
143  const core::Tensor& intrinsics,
144  const core::Tensor& extrinsics,
145  int h,
146  int w,
147  int down_factor,
148  int64_t block_resolution,
149  float voxel_size,
150  float depth_min,
151  float depth_max);
152 
153 void RayCastCPU(std::shared_ptr<core::DeviceHashBackend>& hashmap,
154  const core::Tensor& block_values,
155  const core::Tensor& range_map,
156  core::Tensor& vertex_map,
157  core::Tensor& depth_map,
158  core::Tensor& color_map,
159  core::Tensor& normal_map,
160  const core::Tensor& intrinsics,
161  const core::Tensor& extrinsics,
162  int h,
163  int w,
164  int64_t block_resolution,
165  float voxel_size,
166  float sdf_trunc,
167  float depth_scale,
168  float depth_min,
169  float depth_max,
170  float weight_threshold);
171 
173  const core::Tensor& block_indices,
174  const core::Tensor& nb_block_indices,
175  const core::Tensor& nb_block_masks,
176  const core::Tensor& block_keys,
177  const core::Tensor& block_values,
179  utility::optional<std::reference_wrapper<core::Tensor>> normals,
180  utility::optional<std::reference_wrapper<core::Tensor>> colors,
181  int64_t block_resolution,
182  float voxel_size,
183  float weight_threshold,
184  int& valid_size);
185 
187  const core::Tensor& block_indices,
188  const core::Tensor& inv_block_indices,
189  const core::Tensor& nb_block_indices,
190  const core::Tensor& nb_block_masks,
191  const core::Tensor& block_keys,
192  const core::Tensor& block_values,
193  core::Tensor& vertices,
194  core::Tensor& triangles,
195  utility::optional<std::reference_wrapper<core::Tensor>> vertex_normals,
196  utility::optional<std::reference_wrapper<core::Tensor>> vertex_colors,
197  int64_t block_resolution,
198  float voxel_size,
199  float weight_threshold,
200  int& vertex_count);
201 
202 #ifdef BUILD_CUDA_MODULE
203 void TouchCUDA(std::shared_ptr<core::HashMap>& hashmap,
204  const core::Tensor& points,
205  core::Tensor& voxel_block_coords,
206  int64_t voxel_grid_resolution,
207  float voxel_size,
208  float sdf_trunc);
209 
210 void IntegrateCUDA(const core::Tensor& depth,
211  const core::Tensor& color,
212  const core::Tensor& block_indices,
213  const core::Tensor& block_keys,
214  core::Tensor& block_values,
215  const core::Tensor& intrinsics,
216  const core::Tensor& extrinsics,
217  int64_t resolution,
218  float voxel_size,
219  float sdf_trunc,
220  float depth_scale,
221  float depth_max);
222 
223 void EstimateRangeCUDA(const core::Tensor& block_keys,
224  core::Tensor& range_minmax_map,
225  const core::Tensor& intrinsics,
226  const core::Tensor& extrinsics,
227  int h,
228  int w,
229  int down_factor,
230  int64_t block_resolution,
231  float voxel_size,
232  float depth_min,
233  float depth_max);
234 
235 void RayCastCUDA(std::shared_ptr<core::DeviceHashBackend>& hashmap,
236  const core::Tensor& block_values,
237  const core::Tensor& range_map,
238  core::Tensor& vertex_map,
239  core::Tensor& depth_map,
240  core::Tensor& color_map,
241  core::Tensor& normal_map,
242  const core::Tensor& intrinsics,
243  const core::Tensor& extrinsics,
244  int h,
245  int w,
246  int64_t block_resolution,
247  float voxel_size,
248  float sdf_trunc,
249  float depth_scale,
250  float depth_min,
251  float depth_max,
252  float weight_threshold);
253 
254 void ExtractSurfacePointsCUDA(
255  const core::Tensor& block_indices,
256  const core::Tensor& nb_block_indices,
257  const core::Tensor& nb_block_masks,
258  const core::Tensor& block_keys,
259  const core::Tensor& block_values,
261  utility::optional<std::reference_wrapper<core::Tensor>> normals,
262  utility::optional<std::reference_wrapper<core::Tensor>> colors,
263  int64_t block_resolution,
264  float voxel_size,
265  float weight_threshold,
266  int& valid_size);
267 
268 void ExtractSurfaceMeshCUDA(
269  const core::Tensor& block_indices,
270  const core::Tensor& inv_block_indices,
271  const core::Tensor& nb_block_indices,
272  const core::Tensor& nb_block_masks,
273  const core::Tensor& block_keys,
274  const core::Tensor& block_values,
275  core::Tensor& vertices,
276  core::Tensor& triangles,
277  utility::optional<std::reference_wrapper<core::Tensor>> vertex_normals,
278  utility::optional<std::reference_wrapper<core::Tensor>> vertex_colors,
279  int64_t block_resolution,
280  float voxel_size,
281  float weight_threshold,
282  int& vertex_count);
283 #endif
284 } // namespace tsdf
285 } // namespace kernel
286 } // namespace geometry
287 } // namespace t
288 } // namespace open3d
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: TSDFVoxelGrid.cpp:119
void ExtractSurfaceMeshCPU(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 core::Tensor &block_values, core::Tensor &vertices, core::Tensor &triangles, utility::optional< std::reference_wrapper< core::Tensor >> vertex_normals, utility::optional< std::reference_wrapper< core::Tensor >> vertex_colors, int64_t block_resolution, float voxel_size, float weight_threshold, int &vertex_count)
Definition: TSDFVoxelGridImpl.h:507
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: TSDFVoxelGridImpl.h:940
int points
Definition: FilePCD.cpp:73
math::float4 color
Definition: LineSetBuffers.cpp:64
void ExtractSurfacePointsCPU(const core::Tensor &block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const core::Tensor &block_values, core::Tensor &points, utility::optional< std::reference_wrapper< core::Tensor >> normals, utility::optional< std::reference_wrapper< core::Tensor >> colors, int64_t block_resolution, float voxel_size, float weight_threshold, int &valid_size)
Definition: TSDFVoxelGridImpl.h:181
void ExtractSurfacePoints(const core::Tensor &block_indices, const core::Tensor &nb_block_indices, const core::Tensor &nb_block_masks, const core::Tensor &block_keys, const core::Tensor &block_values, core::Tensor &points, utility::optional< std::reference_wrapper< core::Tensor >> normals, utility::optional< std::reference_wrapper< core::Tensor >> colors, int64_t block_resolution, float voxel_size, float weight_threshold, int &valid_size)
Definition: TSDFVoxelGrid.cpp:196
Definition: PinholeCameraIntrinsic.cpp:35
void RayCast(std::shared_ptr< core::DeviceHashBackend > &hashmap, const core::Tensor &block_values, const core::Tensor &range_map, core::Tensor &vertex_map, core::Tensor &depth_map, core::Tensor &color_map, core::Tensor &normal_map, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int h, int w, int64_t block_resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_min, float depth_max, float weight_threshold)
Definition: TSDFVoxelGrid.cpp:153
void IntegrateCPU(const core::Tensor &depth, const core::Tensor &color, const core::Tensor &block_indices, const core::Tensor &block_keys, core::Tensor &block_values, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int64_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: TSDFVoxelGridImpl.h:55
void ExtractSurfaceMesh(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 core::Tensor &block_values, core::Tensor &vertices, core::Tensor &triangles, utility::optional< std::reference_wrapper< core::Tensor >> vertex_normals, utility::optional< std::reference_wrapper< core::Tensor >> vertex_colors, int64_t block_resolution, float voxel_size, float weight_threshold, int &vertex_count)
Definition: TSDFVoxelGrid.cpp:231
void Touch(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &points, core::Tensor &voxel_block_coords, int64_t voxel_grid_resolution, float voxel_size, float sdf_trunc)
Definition: TSDFVoxelGrid.cpp:41
void TouchCPU(std::shared_ptr< core::HashMap > &hashmap, const core::Tensor &points, core::Tensor &voxel_block_coords, int64_t voxel_grid_resolution, float voxel_size, float sdf_trunc)
Definition: TSDFVoxelGridCPU.cpp:71
void Integrate(const core::Tensor &depth, const core::Tensor &color, const core::Tensor &block_indices, const core::Tensor &block_keys, core::Tensor &block_values, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int64_t resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_max)
Definition: TSDFVoxelGrid.cpp:65
void RayCastCPU(std::shared_ptr< core::DeviceHashBackend > &hashmap, const core::Tensor &block_values, const core::Tensor &range_map, core::Tensor &vertex_map, core::Tensor &depth_map, core::Tensor &color_map, core::Tensor &normal_map, const core::Tensor &intrinsics, const core::Tensor &extrinsics, int h, int w, int64_t block_resolution, float voxel_size, float sdf_trunc, float depth_scale, float depth_min, float depth_max, float weight_threshold)
Definition: TSDFVoxelGridImpl.h:1151