Open3D (C++ API)
UniformTSDFVolume.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 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 
31 
32 namespace open3d {
33 
34 namespace geometry {
35 
36 class TSDFVoxel : public Voxel {
37 public:
38  TSDFVoxel() : Voxel() {}
39  TSDFVoxel(const Eigen::Vector3i &grid_index) : Voxel(grid_index) {}
40  TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
41  : Voxel(grid_index, color) {}
43 
44 public:
45  float tsdf_ = 0;
46  float weight_ = 0;
47 };
48 
49 } // namespace geometry
50 
51 namespace integration {
52 
57 class UniformTSDFVolume : public TSDFVolume {
58 public:
59  UniformTSDFVolume(double length,
60  int resolution,
61  double sdf_trunc,
62  TSDFVolumeColorType color_type,
63  const Eigen::Vector3d &origin = Eigen::Vector3d::Zero());
64  ~UniformTSDFVolume() override;
65 
66 public:
67  void Reset() override;
68  void Integrate(const geometry::RGBDImage &image,
69  const camera::PinholeCameraIntrinsic &intrinsic,
70  const Eigen::Matrix4d &extrinsic) override;
71  std::shared_ptr<geometry::PointCloud> ExtractPointCloud() override;
72  std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh() override;
73 
75  std::shared_ptr<geometry::PointCloud> ExtractVoxelPointCloud() const;
77  std::shared_ptr<geometry::VoxelGrid> ExtractVoxelGrid() const;
78 
81  void IntegrateWithDepthToCameraDistanceMultiplier(
82  const geometry::RGBDImage &image,
83  const camera::PinholeCameraIntrinsic &intrinsic,
84  const Eigen::Matrix4d &extrinsic,
85  const geometry::Image &depth_to_camera_distance_multiplier);
86 
87  inline int IndexOf(int x, int y, int z) const {
88  return x * resolution_ * resolution_ + y * resolution_ + z;
89  }
90 
91  inline int IndexOf(const Eigen::Vector3i &xyz) const {
92  return IndexOf(xyz(0), xyz(1), xyz(2));
93  }
94 
95 public:
96  std::vector<geometry::TSDFVoxel> voxels_;
97  Eigen::Vector3d origin_;
99  double length_;
105 
106 private:
107  Eigen::Vector3d GetNormalAt(const Eigen::Vector3d &p);
108 
109  double GetTSDFAt(const Eigen::Vector3d &p);
110 };
111 
112 } // namespace integration
113 } // namespace open3d
int IndexOf(const Eigen::Vector3i &xyz) const
Definition: UniformTSDFVolume.h:91
TSDFVolumeColorType
Definition: TSDFVolume.h:40
~TSDFVoxel()
Definition: UniformTSDFVolume.h:42
Definition: UniformTSDFVolume.h:36
std::vector< geometry::TSDFVoxel > voxels_
Definition: UniformTSDFVolume.h:96
Contains the pinhole camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:51
int resolution_
Definition: UniformTSDFVolume.h:102
Base class of the Truncated Signed Distance Function (TSDF) volume.
Definition: TSDFVolume.h:60
math::float4 color
Definition: LineSetBuffers.cpp:46
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:46
UniformTSDFVolume implements the classic TSDF volume with uniform voxel grid (Curless and Levoy 1996)...
Definition: UniformTSDFVolume.h:57
int voxel_num_
Number of voxels present.
Definition: UniformTSDFVolume.h:104
Eigen::Vector3d origin
Definition: FilePLY.cpp:285
Definition: Open3DViewer.h:29
TSDFVoxel()
Definition: UniformTSDFVolume.h:38
double length_
Total length, where voxel_length = length / resolution.
Definition: UniformTSDFVolume.h:99
Eigen::Vector3d origin_
Definition: UniformTSDFVolume.h:97
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:55
float weight_
Definition: UniformTSDFVolume.h:46
The Image class stores image with customizable width, height, num of channels and bytes per channel...
Definition: Image.h:53
float tsdf_
Definition: UniformTSDFVolume.h:45
TSDFVoxel(const Eigen::Vector3i &grid_index)
Definition: UniformTSDFVolume.h:39
int IndexOf(int x, int y, int z) const
Definition: UniformTSDFVolume.h:87
TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
Definition: UniformTSDFVolume.h:40