31 #include <unordered_map> 41 class PinholeCameraParameters;
61 Voxel(
const Eigen::Vector3i &grid_index) : grid_index_(grid_index) {}
66 Voxel(
const Eigen::Vector3i &grid_index,
const Eigen::Vector3d &
color)
67 : grid_index_(grid_index),
color_(color) {}
72 Eigen::Vector3i grid_index_ = Eigen::Vector3i(0, 0, 0);
74 Eigen::Vector3d
color_ = Eigen::Vector3d(0, 0, 0);
89 bool IsEmpty()
const override;
90 Eigen::Vector3d GetMinBound()
const override;
91 Eigen::Vector3d GetMaxBound()
const override;
92 Eigen::Vector3d GetCenter()
const override;
95 VoxelGrid &Transform(
const Eigen::Matrix4d &transformation)
override;
96 VoxelGrid &Translate(
const Eigen::Vector3d &translation,
97 bool relative =
true)
override;
99 const Eigen::Vector3d ¢er)
override;
100 VoxelGrid &Rotate(
const Eigen::Matrix3d &R,
101 const Eigen::Vector3d ¢er)
override;
113 Eigen::Vector3i GetVoxel(
const Eigen::Vector3d &point)
const;
117 auto it = voxels_.find(idx);
118 if (it != voxels_.end()) {
119 auto voxel = it->second;
120 return ((voxel.grid_index_.cast<
double>() +
121 Eigen::Vector3d(0.5, 0.5, 0.5)) *
125 return Eigen::Vector3d::Zero();
130 void AddVoxel(
const Voxel &voxel);
133 std::vector<Eigen::Vector3d> GetVoxelBoundingPoints(
134 const Eigen::Vector3i &index)
const;
138 std::vector<bool> CheckIfIncluded(
139 const std::vector<Eigen::Vector3d> &queries);
151 const Image &depth_map,
153 bool keep_voxels_outside_image);
165 const Image &silhouette_mask,
167 bool keep_voxels_outside_image);
172 void CreateFromOctree(
const Octree &octree);
177 std::shared_ptr<geometry::Octree> ToOctree(
const size_t &max_depth)
const;
188 static std::shared_ptr<VoxelGrid> CreateDense(
const Eigen::Vector3d &origin,
189 const Eigen::Vector3d &
color,
202 static std::shared_ptr<VoxelGrid> CreateFromPointCloud(
214 static std::shared_ptr<VoxelGrid> CreateFromPointCloudWithinBounds(
217 const Eigen::Vector3d &min_bound,
218 const Eigen::Vector3d &max_bound);
226 static std::shared_ptr<VoxelGrid> CreateFromTriangleMesh(
237 static std::shared_ptr<VoxelGrid> CreateFromTriangleMeshWithinBounds(
240 const Eigen::Vector3d &min_bound,
241 const Eigen::Vector3d &max_bound);
246 std::vector<Voxel> GetVoxels()
const;
250 double voxel_size_ = 0.0;
252 Eigen::Vector3d origin_ = Eigen::Vector3d::Zero();
254 std::unordered_map<Eigen::Vector3i,
269 void Add(
const Eigen::Vector3i &voxel_index) {
272 "Tried to aggregate ColorVoxel with different " 275 voxel_index_ = voxel_index;
278 void Add(
const Eigen::Vector3i &voxel_index,
const Eigen::Vector3d &
color) {
Eigen::Vector3d color_
Definition: PointCloud.cpp:242
The base geometry class.
Definition: Geometry.h:37
void Add(const Eigen::Vector3i &voxel_index)
Definition: VoxelGrid.h:269
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:149
void Add(const Eigen::Vector3i &voxel_index, const Eigen::Vector3d &color)
Definition: VoxelGrid.h:278
Voxel(const Eigen::Vector3i &grid_index)
Parameterized Constructor.
Definition: VoxelGrid.h:61
void LogWarning(const char *format, const Args &... args)
Definition: Console.h:181
Eigen::Vector3d color_
Definition: VoxelGrid.h:297
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:44
Eigen::Vector3i voxel_index_
Definition: VoxelGrid.h:296
A point cloud consists of point coordinates, and optionally point colors and point normals...
Definition: PointCloud.h:54
Eigen::Vector3d GetVoxelCenterCoordinate(const Eigen::Vector3i &idx) const
Function that returns the 3d coordinates of the queried voxel center.
Definition: VoxelGrid.h:116
bool HasVoxels() const
Returns true if the voxel grid contains voxels.
Definition: VoxelGrid.h:107
VoxelGrid()
Default Constructor.
Definition: VoxelGrid.h:83
int num_of_points_
Definition: PointCloud.cpp:239
~VoxelGrid() override
Definition: VoxelGrid.h:86
math::float4 color
Definition: LineSetBuffers.cpp:63
AvgColorVoxel()
Definition: VoxelGrid.h:266
The base geometry class for 3D geometries.
Definition: Geometry3D.h:46
Class to aggregate color values from different votes in one voxel Computes the average color value in...
Definition: VoxelGrid.h:264
~Voxel()
Definition: VoxelGrid.h:68
bool HasColors() const
Returns true if the voxel grid contains voxel colors.
Definition: VoxelGrid.h:109
Contains both intrinsic and extrinsic pinhole camera parameters.
Definition: PinholeCameraParameters.h:40
std::unordered_map< Eigen::Vector3i, Voxel, utility::hash_eigen< Eigen::Vector3i > > voxels_
Voxels contained in voxel grid.
Definition: VoxelGrid.h:257
Definition: PinholeCameraIntrinsic.cpp:35
VoxelGrid is a collection of voxels which are aligned in grid.
Definition: VoxelGrid.h:80
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
Tensor operator+(T scalar_lhs, const Tensor &rhs)
Definition: Tensor.h:1105
int height
Definition: FilePCD.cpp:72
Eigen::Vector3d GetAverageColor() const
Definition: VoxelGrid.h:286
Octree datastructure.
Definition: Octree.h:181
int num_of_points_
Definition: VoxelGrid.h:295
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:54
Eigen::Vector3i GetVoxelIndex() const
Definition: VoxelGrid.h:284
Voxel()
Default Constructor.
Definition: VoxelGrid.h:57
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:54
Voxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
Parameterized Constructor.
Definition: VoxelGrid.h:66
The Image class stores image with customizable width, height, num of channels and bytes per channel...
Definition: Image.h:53
int width
Definition: FilePCD.cpp:71