31 #include <unordered_map> 42 class PinholeCameraParameters;
62 Voxel(
const Eigen::Vector3i &grid_index) : grid_index_(grid_index) {}
67 Voxel(
const Eigen::Vector3i &grid_index,
const Eigen::Vector3d &
color)
68 : grid_index_(grid_index),
color_(color) {}
73 Eigen::Vector3i grid_index_ = Eigen::Vector3i(0, 0, 0);
75 Eigen::Vector3d
color_ = Eigen::Vector3d(0, 0, 0);
90 bool IsEmpty()
const override;
91 Eigen::Vector3d GetMinBound()
const override;
92 Eigen::Vector3d GetMaxBound()
const override;
93 Eigen::Vector3d GetCenter()
const override;
96 VoxelGrid &Transform(
const Eigen::Matrix4d &transformation)
override;
97 VoxelGrid &Translate(
const Eigen::Vector3d &translation,
98 bool relative =
true)
override;
100 const Eigen::Vector3d ¢er)
override;
101 VoxelGrid &Rotate(
const Eigen::Matrix3d &R,
102 const Eigen::Vector3d ¢er)
override;
114 Eigen::Vector3i GetVoxel(
const Eigen::Vector3d &point)
const;
118 auto it = voxels_.find(idx);
119 if (it != voxels_.end()) {
120 auto voxel = it->second;
121 return ((voxel.grid_index_.cast<
double>() +
122 Eigen::Vector3d(0.5, 0.5, 0.5)) *
126 return Eigen::Vector3d::Zero();
131 void AddVoxel(
const Voxel &voxel);
134 std::vector<Eigen::Vector3d> GetVoxelBoundingPoints(
135 const Eigen::Vector3i &index)
const;
139 std::vector<bool> CheckIfIncluded(
140 const std::vector<Eigen::Vector3d> &queries);
152 const Image &depth_map,
154 bool keep_voxels_outside_image);
166 const Image &silhouette_mask,
168 bool keep_voxels_outside_image);
173 void CreateFromOctree(
const Octree &octree);
178 std::shared_ptr<geometry::Octree> ToOctree(
const size_t &max_depth)
const;
188 static std::shared_ptr<VoxelGrid> CreateDense(
const Eigen::Vector3d &
origin,
201 static std::shared_ptr<VoxelGrid> CreateFromPointCloud(
213 static std::shared_ptr<VoxelGrid> CreateFromPointCloudWithinBounds(
216 const Eigen::Vector3d &min_bound,
217 const Eigen::Vector3d &max_bound);
225 static std::shared_ptr<VoxelGrid> CreateFromTriangleMesh(
236 static std::shared_ptr<VoxelGrid> CreateFromTriangleMeshWithinBounds(
239 const Eigen::Vector3d &min_bound,
240 const Eigen::Vector3d &max_bound);
245 std::vector<Voxel> GetVoxels()
const;
249 double voxel_size_ = 0.0;
251 Eigen::Vector3d origin_ = Eigen::Vector3d::Zero();
253 std::unordered_map<Eigen::Vector3i,
271 "Tried to aggregate ColorVoxel with different "
The base geometry class.
Definition: Geometry.h:37
void Add(const Eigen::Vector3i &voxel_index)
Definition: VoxelGrid.h:268
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:164
void Add(const Eigen::Vector3i &voxel_index, const Eigen::Vector3d &color)
Definition: VoxelGrid.h:277
Voxel(const Eigen::Vector3i &grid_index)
Parameterized Constructor.
Definition: VoxelGrid.h:62
void LogWarning(const char *format, const Args &... args)
Definition: Console.h:179
Eigen::Vector3d color_
Definition: VoxelGrid.h:296
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:44
Eigen::Vector3i voxel_index_
Definition: VoxelGrid.h:295
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:117
long voxel_index
Definition: FilePLY.cpp:287
bool HasVoxels() const
Returns true if the voxel grid contains voxels.
Definition: VoxelGrid.h:108
VoxelGrid()
Default Constructor.
Definition: VoxelGrid.h:84
int num_of_points_
Definition: PointCloud.cpp:237
~VoxelGrid() override
Definition: VoxelGrid.h:87
math::float4 color
Definition: LineSetBuffers.cpp:46
double voxel_size
Definition: FilePLY.cpp:286
Tensor operator+(T scalar_lhs, const Tensor &rhs)
Definition: Tensor.h:876
AvgColorVoxel()
Definition: VoxelGrid.h:265
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:263
~Voxel()
Definition: VoxelGrid.h:69
bool HasColors() const
Returns true if the voxel grid contains voxel colors.
Definition: VoxelGrid.h:110
Contains both intrinsic and extrinsic pinhole camera parameters.
Definition: PinholeCameraParameters.h:40
Eigen::Vector3d origin
Definition: FilePLY.cpp:285
Definition: Open3DViewer.h:29
VoxelGrid is a collection of voxels which are aligned in grid.
Definition: VoxelGrid.h:81
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
int height
Definition: FilePCD.cpp:70
Eigen::Vector3d GetAverageColor() const
Definition: VoxelGrid.h:285
Octree datastructure.
Definition: Octree.h:181
Eigen::Vector3d color_
Definition: PointCloud.cpp:240
int num_of_points_
Definition: VoxelGrid.h:294
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:55
Eigen::Vector3i GetVoxelIndex() const
Definition: VoxelGrid.h:283
Voxel()
Default Constructor.
Definition: VoxelGrid.h:58
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:67
The Image class stores image with customizable width, height, num of channels and bytes per channel...
Definition: Image.h:53
std::unordered_map< Eigen::Vector3i, Voxel, utility::hash_eigen::hash< Eigen::Vector3i > > voxels_
Voxels contained in voxel grid.
Definition: VoxelGrid.h:256
int width
Definition: FilePCD.cpp:69