Open3D (C++ API)  0.18.0+5c982c7
UniformTSDFVolume.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
12 
13 namespace open3d {
14 
15 namespace geometry {
16 
17 class TSDFVoxel : public Voxel {
18 public:
19  TSDFVoxel() : Voxel() {}
20  TSDFVoxel(const Eigen::Vector3i &grid_index) : Voxel(grid_index) {}
21  TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
22  : Voxel(grid_index, color) {}
24 
25 public:
26  float tsdf_ = 0;
27  float weight_ = 0;
28 };
29 
30 } // namespace geometry
31 
32 namespace pipelines {
33 namespace integration {
34 
39 class UniformTSDFVolume : public TSDFVolume {
40 public:
41  UniformTSDFVolume(double length,
42  int resolution,
43  double sdf_trunc,
44  TSDFVolumeColorType color_type,
45  const Eigen::Vector3d &origin = Eigen::Vector3d::Zero());
46  ~UniformTSDFVolume() override;
47 
48 public:
49  void Reset() override;
51  const camera::PinholeCameraIntrinsic &intrinsic,
52  const Eigen::Matrix4d &extrinsic) override;
53  std::shared_ptr<geometry::PointCloud> ExtractPointCloud() override;
54  std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh() override;
55 
57  std::shared_ptr<geometry::PointCloud> ExtractVoxelPointCloud() const;
59  std::shared_ptr<geometry::VoxelGrid> ExtractVoxelGrid() const;
61  std::vector<Eigen::Vector2d> ExtractVolumeTSDF() const;
63  std::vector<Eigen::Vector3d> ExtractVolumeColor() const;
65  void InjectVolumeTSDF(const std::vector<Eigen::Vector2d> &sharedvoxels);
67  void InjectVolumeColor(const std::vector<Eigen::Vector3d> &sharedcolors);
68 
73  const camera::PinholeCameraIntrinsic &intrinsic,
74  const Eigen::Matrix4d &extrinsic,
75  const geometry::Image &depth_to_camera_distance_multiplier);
76 
77  inline int IndexOf(int x, int y, int z) const {
78  return x * resolution_ * resolution_ + y * resolution_ + z;
79  }
80 
81  inline int IndexOf(const Eigen::Vector3i &xyz) const {
82  return IndexOf(xyz(0), xyz(1), xyz(2));
83  }
84 
85 public:
86  std::vector<geometry::TSDFVoxel> voxels_;
87  Eigen::Vector3d origin_;
89  double length_;
95 
96 private:
97  Eigen::Vector3d GetNormalAt(const Eigen::Vector3d &p);
98 
99  double GetTSDFAt(const Eigen::Vector3d &p);
100 };
101 
102 } // namespace integration
103 } // namespace pipelines
104 } // namespace open3d
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:183
math::float4 color
Definition: LineSetBuffers.cpp:45
Contains the pinhole camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:32
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:34
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:27
Definition: UniformTSDFVolume.h:17
TSDFVoxel(const Eigen::Vector3i &grid_index)
Definition: UniformTSDFVolume.h:20
float weight_
Definition: UniformTSDFVolume.h:27
TSDFVoxel()
Definition: UniformTSDFVolume.h:19
~TSDFVoxel()
Definition: UniformTSDFVolume.h:23
TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
Definition: UniformTSDFVolume.h:21
float tsdf_
Definition: UniformTSDFVolume.h:26
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:35
Base class of the Truncated Signed Distance Function (TSDF) volume.
Definition: TSDFVolume.h:42
UniformTSDFVolume implements the classic TSDF volume with uniform voxel grid (Curless and Levoy 1996)...
Definition: UniformTSDFVolume.h:39
int IndexOf(int x, int y, int z) const
Definition: UniformTSDFVolume.h:77
std::shared_ptr< geometry::VoxelGrid > ExtractVoxelGrid() const
Debug function to extract the voxel data VoxelGrid.
Definition: UniformTSDFVolume.cpp:254
std::shared_ptr< geometry::PointCloud > ExtractVoxelPointCloud() const
Debug function to extract the voxel data into a VoxelGrid.
Definition: UniformTSDFVolume.cpp:228
std::vector< geometry::TSDFVoxel > voxels_
Definition: UniformTSDFVolume.h:86
std::shared_ptr< geometry::TriangleMesh > ExtractTriangleMesh() override
Function to extract a triangle mesh, using the marching cubes algorithm. (https://en....
Definition: UniformTSDFVolume.cpp:142
int IndexOf(const Eigen::Vector3i &xyz) const
Definition: UniformTSDFVolume.h:81
std::shared_ptr< geometry::PointCloud > ExtractPointCloud() override
Function to extract a point cloud with normals.
Definition: UniformTSDFVolume.cpp:85
std::vector< Eigen::Vector2d > ExtractVolumeTSDF() const
Debug function to extract the volume TSDF data into a vector array.
Definition: UniformTSDFVolume.cpp:285
Eigen::Vector3d origin_
Definition: UniformTSDFVolume.h:87
void InjectVolumeTSDF(const std::vector< Eigen::Vector2d > &sharedvoxels)
Debug function to inject voxel TSDF data into the volume.
Definition: UniformTSDFVolume.cpp:331
double length_
Total length, where voxel_length = length / resolution.
Definition: UniformTSDFVolume.h:89
void InjectVolumeColor(const std::vector< Eigen::Vector3d > &sharedcolors)
Debug function to inject voxel Color data into the volume.
Definition: UniformTSDFVolume.cpp:351
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: UniformTSDFVolume.cpp:41
void IntegrateWithDepthToCameraDistanceMultiplier(const geometry::RGBDImage &image, const camera::PinholeCameraIntrinsic &intrinsic, const Eigen::Matrix4d &extrinsic, const geometry::Image &depth_to_camera_distance_multiplier)
Definition: UniformTSDFVolume.cpp:370
std::vector< Eigen::Vector3d > ExtractVolumeColor() const
Debug function to extract the volume color data into a vector array.
Definition: UniformTSDFVolume.cpp:309
int voxel_num_
Number of voxels present.
Definition: UniformTSDFVolume.h:94
UniformTSDFVolume(double length, int resolution, double sdf_trunc, TSDFVolumeColorType color_type, const Eigen::Vector3d &origin=Eigen::Vector3d::Zero())
Definition: UniformTSDFVolume.cpp:23
void Reset() override
Function to reset the TSDFVolume.
Definition: UniformTSDFVolume.cpp:39
int resolution_
Definition: UniformTSDFVolume.h:92
~UniformTSDFVolume() override
Definition: UniformTSDFVolume.cpp:37
TSDFVolumeColorType
Definition: TSDFVolume.h:22
Definition: PinholeCameraIntrinsic.cpp:16