Open3D (C++ API)  0.16.0
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-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
31
32namespace open3d {
33
34namespace geometry {
35
36class TSDFVoxel : public Voxel {
37public:
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
44public:
45 float tsdf_ = 0;
46 float weight_ = 0;
47};
48
49} // namespace geometry
50
51namespace pipelines {
52namespace integration {
53
59public:
60 UniformTSDFVolume(double length,
61 int resolution,
62 double sdf_trunc,
63 TSDFVolumeColorType color_type,
64 const Eigen::Vector3d &origin = Eigen::Vector3d::Zero());
65 ~UniformTSDFVolume() override;
66
67public:
68 void Reset() override;
70 const camera::PinholeCameraIntrinsic &intrinsic,
71 const Eigen::Matrix4d &extrinsic) override;
72 std::shared_ptr<geometry::PointCloud> ExtractPointCloud() override;
73 std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh() override;
74
76 std::shared_ptr<geometry::PointCloud> ExtractVoxelPointCloud() const;
78 std::shared_ptr<geometry::VoxelGrid> ExtractVoxelGrid() const;
80 std::vector<Eigen::Vector2d> ExtractVolumeTSDF() const;
82 std::vector<Eigen::Vector3d> ExtractVolumeColor() const;
84 void InjectVolumeTSDF(const std::vector<Eigen::Vector2d> &sharedvoxels);
86 void InjectVolumeColor(const std::vector<Eigen::Vector3d> &sharedcolors);
87
92 const camera::PinholeCameraIntrinsic &intrinsic,
93 const Eigen::Matrix4d &extrinsic,
94 const geometry::Image &depth_to_camera_distance_multiplier);
95
96 inline int IndexOf(int x, int y, int z) const {
97 return x * resolution_ * resolution_ + y * resolution_ + z;
98 }
99
100 inline int IndexOf(const Eigen::Vector3i &xyz) const {
101 return IndexOf(xyz(0), xyz(1), xyz(2));
102 }
103
104public:
105 std::vector<geometry::TSDFVoxel> voxels_;
106 Eigen::Vector3d origin_;
108 double length_;
114
115private:
116 Eigen::Vector3d GetNormalAt(const Eigen::Vector3d &p);
117
118 double GetTSDFAt(const Eigen::Vector3d &p);
119};
120
121} // namespace integration
122} // namespace pipelines
123} // namespace open3d
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:202
math::float4 color
Definition: LineSetBuffers.cpp:64
Contains the pinhole camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:51
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:53
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:46
Definition: UniformTSDFVolume.h:36
TSDFVoxel(const Eigen::Vector3i &grid_index)
Definition: UniformTSDFVolume.h:39
float weight_
Definition: UniformTSDFVolume.h:46
TSDFVoxel()
Definition: UniformTSDFVolume.h:38
~TSDFVoxel()
Definition: UniformTSDFVolume.h:42
TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
Definition: UniformTSDFVolume.h:40
float tsdf_
Definition: UniformTSDFVolume.h:45
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:54
Base class of the Truncated Signed Distance Function (TSDF) volume.
Definition: TSDFVolume.h:61
UniformTSDFVolume implements the classic TSDF volume with uniform voxel grid (Curless and Levoy 1996)...
Definition: UniformTSDFVolume.h:58
int IndexOf(int x, int y, int z) const
Definition: UniformTSDFVolume.h:96
std::shared_ptr< geometry::VoxelGrid > ExtractVoxelGrid() const
Debug function to extract the voxel data VoxelGrid.
Definition: UniformTSDFVolume.cpp:273
std::shared_ptr< geometry::PointCloud > ExtractVoxelPointCloud() const
Debug function to extract the voxel data into a VoxelGrid.
Definition: UniformTSDFVolume.cpp:247
std::vector< geometry::TSDFVoxel > voxels_
Definition: UniformTSDFVolume.h:105
std::shared_ptr< geometry::TriangleMesh > ExtractTriangleMesh() override
Function to extract a triangle mesh, using the marching cubes algorithm. (https://en....
Definition: UniformTSDFVolume.cpp:161
int IndexOf(const Eigen::Vector3i &xyz) const
Definition: UniformTSDFVolume.h:100
std::shared_ptr< geometry::PointCloud > ExtractPointCloud() override
Function to extract a point cloud with normals.
Definition: UniformTSDFVolume.cpp:104
std::vector< Eigen::Vector2d > ExtractVolumeTSDF() const
Debug function to extract the volume TSDF data into a vector array.
Definition: UniformTSDFVolume.cpp:304
Eigen::Vector3d origin_
Definition: UniformTSDFVolume.h:106
void InjectVolumeTSDF(const std::vector< Eigen::Vector2d > &sharedvoxels)
Debug function to inject voxel TSDF data into the volume.
Definition: UniformTSDFVolume.cpp:350
double length_
Total length, where voxel_length = length / resolution.
Definition: UniformTSDFVolume.h:108
void InjectVolumeColor(const std::vector< Eigen::Vector3d > &sharedcolors)
Debug function to inject voxel Color data into the volume.
Definition: UniformTSDFVolume.cpp:370
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:60
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:389
std::vector< Eigen::Vector3d > ExtractVolumeColor() const
Debug function to extract the volume color data into a vector array.
Definition: UniformTSDFVolume.cpp:328
int voxel_num_
Number of voxels present.
Definition: UniformTSDFVolume.h:113
UniformTSDFVolume(double length, int resolution, double sdf_trunc, TSDFVolumeColorType color_type, const Eigen::Vector3d &origin=Eigen::Vector3d::Zero())
Definition: UniformTSDFVolume.cpp:42
void Reset() override
Function to reset the TSDFVolume.
Definition: UniformTSDFVolume.cpp:58
int resolution_
Definition: UniformTSDFVolume.h:111
~UniformTSDFVolume() override
Definition: UniformTSDFVolume.cpp:56
TSDFVolumeColorType
Definition: TSDFVolume.h:41
Definition: PinholeCameraIntrinsic.cpp:35