Open3D (C++ API)  0.11.0
ScalableTSDFVolume.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 
29 #include <memory>
30 #include <unordered_map>
31 
33 #include "open3d/utility/Helper.h"
34 
35 namespace open3d {
36 namespace pipelines {
37 namespace integration {
38 
39 class UniformTSDFVolume;
40 
60 public:
61  struct VolumeUnit {
62  public:
63  VolumeUnit() : volume_(NULL) {}
64 
65  public:
66  std::shared_ptr<UniformTSDFVolume> volume_;
67  Eigen::Vector3i index_;
68  };
69 
70 public:
71  ScalableTSDFVolume(double voxel_length,
72  double sdf_trunc,
73  TSDFVolumeColorType color_type,
74  int volume_unit_resolution = 16,
75  int depth_sampling_stride = 4);
76  ~ScalableTSDFVolume() override;
77 
78 public:
79  void Reset() override;
80  void Integrate(const geometry::RGBDImage &image,
81  const camera::PinholeCameraIntrinsic &intrinsic,
82  const Eigen::Matrix4d &extrinsic) override;
83  std::shared_ptr<geometry::PointCloud> ExtractPointCloud() override;
84  std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh() override;
86  std::shared_ptr<geometry::PointCloud> ExtractVoxelPointCloud();
87 
88 public:
92 
96  std::unordered_map<Eigen::Vector3i,
97  VolumeUnit,
100 
101 private:
102  Eigen::Vector3i LocateVolumeUnit(const Eigen::Vector3d &point) {
103  return Eigen::Vector3i((int)std::floor(point(0) / volume_unit_length_),
104  (int)std::floor(point(1) / volume_unit_length_),
105  (int)std::floor(point(2) / volume_unit_length_));
106  }
107 
108  std::shared_ptr<UniformTSDFVolume> OpenVolumeUnit(
109  const Eigen::Vector3i &index);
110 
111  Eigen::Vector3d GetNormalAt(const Eigen::Vector3d &p);
112 
113  double GetTSDFAt(const Eigen::Vector3d &p);
114 };
115 
116 } // namespace integration
117 } // namespace pipelines
118 } // namespace open3d
Eigen::Vector3i index_
Definition: ScalableTSDFVolume.h:67
double volume_unit_length_
Definition: ScalableTSDFVolume.h:90
Definition: ScalableTSDFVolume.h:59
ScalableTSDFVolume(double voxel_length, double sdf_trunc, TSDFVolumeColorType color_type, int volume_unit_resolution=16, int depth_sampling_stride=4)
Definition: ScalableTSDFVolume.cpp:40
Contains the pinhole camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:51
std::shared_ptr< geometry::PointCloud > ExtractVoxelPointCloud()
Debug function to extract the voxel data into a point cloud.
Definition: ScalableTSDFVolume.cpp:375
std::shared_ptr< UniformTSDFVolume > volume_
Definition: ScalableTSDFVolume.h:66
FN_SPECIFIERS MiniVec< float, N > floor(const MiniVec< float, N > &a)
Definition: MiniVec.h:80
Definition: Helper.h:86
std::shared_ptr< geometry::PointCloud > ExtractPointCloud() override
Function to extract a point cloud with normals.
Definition: ScalableTSDFVolume.cpp:122
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:46
TSDFVolumeColorType
Definition: TSDFVolume.h:41
std::unordered_map< Eigen::Vector3i, VolumeUnit, utility::hash_eigen< Eigen::Vector3i > > volume_units_
Definition: ScalableTSDFVolume.h:99
Definition: PinholeCameraIntrinsic.cpp:35
std::shared_ptr< geometry::TriangleMesh > ExtractTriangleMesh() override
Function to extract a triangle mesh, using the marching cubes algorithm. (https://en.wikipedia.org/wiki/Marching_cubes)
Definition: ScalableTSDFVolume.cpp:225
void Reset() override
Function to reset the TSDFVolume.
Definition: ScalableTSDFVolume.cpp:52
Base class of the Truncated Signed Distance Function (TSDF) volume.
Definition: TSDFVolume.h:61
~ScalableTSDFVolume() override
Definition: ScalableTSDFVolume.cpp:50
int volume_unit_resolution_
Definition: ScalableTSDFVolume.h:89
void Integrate(const geometry::RGBDImage &image, const camera::PinholeCameraIntrinsic &intrinsic, const Eigen::Matrix4d &extrinsic) override
Function to integrate an RGB-D image into the volume.
Definition: ScalableTSDFVolume.cpp:54
int depth_sampling_stride_
Definition: ScalableTSDFVolume.h:91