ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
UniformTSDFVolume.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <VoxelGrid.h>
11 
13 
14 namespace cloudViewer {
15 
16 namespace geometry {
17 
18 class TSDFVoxel : public Voxel {
19 public:
20  TSDFVoxel() : Voxel() {}
21  TSDFVoxel(const Eigen::Vector3i &grid_index) : Voxel(grid_index) {}
22  TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
23  : Voxel(grid_index, color) {}
25 
26 public:
27  float tsdf_ = 0;
28  float weight_ = 0;
29 };
30 
31 } // namespace geometry
32 
33 namespace pipelines {
34 namespace integration {
35 
40 class UniformTSDFVolume : public TSDFVolume {
41 public:
43  int resolution,
44  double sdf_trunc,
45  TSDFVolumeColorType color_type,
46  const Eigen::Vector3d &origin = Eigen::Vector3d::Zero());
47  ~UniformTSDFVolume() override;
48 
49 public:
50  void Reset() override;
52  const camera::PinholeCameraIntrinsic &intrinsic,
53  const Eigen::Matrix4d &extrinsic) override;
54  std::shared_ptr<ccPointCloud> ExtractPointCloud() override;
55  std::shared_ptr<ccMesh> ExtractTriangleMesh() override;
56 
58  std::shared_ptr<ccPointCloud> ExtractVoxelPointCloud() const;
60  std::shared_ptr<geometry::VoxelGrid> ExtractVoxelGrid() const;
62  std::vector<Eigen::Vector2d> ExtractVolumeTSDF() const;
64  std::vector<Eigen::Vector3d> ExtractVolumeColor() const;
66  void InjectVolumeTSDF(const std::vector<Eigen::Vector2d> &sharedvoxels);
68  void InjectVolumeColor(const std::vector<Eigen::Vector3d> &sharedcolors);
69 
74  const camera::PinholeCameraIntrinsic &intrinsic,
75  const Eigen::Matrix4d &extrinsic,
76  const geometry::Image &depth_to_camera_distance_multiplier);
77 
78  inline int IndexOf(int x, int y, int z) const {
79  return x * resolution_ * resolution_ + y * resolution_ + z;
80  }
81 
82  inline int IndexOf(const Eigen::Vector3i &xyz) const {
83  return IndexOf(xyz(0), xyz(1), xyz(2));
84  }
85 
86 public:
87  std::vector<geometry::TSDFVoxel> voxels_;
88  Eigen::Vector3d origin_;
90  double length_;
96 
97 private:
98  Eigen::Vector3d GetNormalAt(const Eigen::Vector3d &p);
99 
100  double GetTSDFAt(const Eigen::Vector3d &p);
101 };
102 
103 } // namespace integration
104 } // namespace pipelines
105 } // namespace cloudViewer
std::shared_ptr< core::Tensor > image
math::float4 color
Contains the pinhole camera intrinsic parameters.
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:33
RGBDImage is for a pair of registered color and depth images,.
Definition: RGBDImage.h:27
TSDFVoxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
TSDFVoxel(const Eigen::Vector3i &grid_index)
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:38
Base class of the Truncated Signed Distance Function (TSDF) volume.
Definition: TSDFVolume.h:43
UniformTSDFVolume implements the classic TSDF volume with uniform voxel grid (Curless and Levoy 1996)...
std::shared_ptr< geometry::VoxelGrid > ExtractVoxelGrid() const
Debug function to extract the voxel data VoxelGrid.
void IntegrateWithDepthToCameraDistanceMultiplier(const geometry::RGBDImage &image, const camera::PinholeCameraIntrinsic &intrinsic, const Eigen::Matrix4d &extrinsic, const geometry::Image &depth_to_camera_distance_multiplier)
std::shared_ptr< ccMesh > ExtractTriangleMesh() override
Function to extract a triangle mesh, using the marching cubes algorithm. (https://en....
std::shared_ptr< ccPointCloud > ExtractVoxelPointCloud() const
Debug function to extract the voxel data into a VoxelGrid.
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.
std::shared_ptr< ccPointCloud > ExtractPointCloud() override
Function to extract a point cloud with normals.
std::vector< Eigen::Vector2d > ExtractVolumeTSDF() const
Debug function to extract the volume TSDF data into a vector array.
void InjectVolumeTSDF(const std::vector< Eigen::Vector2d > &sharedvoxels)
Debug function to inject voxel TSDF data into the volume.
std::vector< Eigen::Vector3d > ExtractVolumeColor() const
Debug function to extract the volume color data into a vector array.
double length_
Total length, where voxel_length = length / resolution.
void InjectVolumeColor(const std::vector< Eigen::Vector3d > &sharedcolors)
Debug function to inject voxel Color data into the volume.
UniformTSDFVolume(double length, int resolution, double sdf_trunc, TSDFVolumeColorType color_type, const Eigen::Vector3d &origin=Eigen::Vector3d::Zero())
void Reset() override
Function to reset the TSDFVolume.
int IndexOf(const Eigen::Vector3i &xyz) const
__host__ __device__ float length(float2 v)
Definition: cutil_math.h:1162
Generic file read and write utility for python interface.
Eigen::Matrix< Index, 3, 1 > Vector3i
Definition: knncpp.h:30