12 #include <unordered_map>
22 class PinholeCameraParameters;
47 Voxel(
const Eigen::Vector3i &grid_index,
const Eigen::Vector3d &
color)
55 Eigen::Vector3d
color_ = Eigen::Vector3d(0, 0, 0);
73 Eigen::Vector3d
GetCenter()
const override;
82 bool robust =
false)
const override;
87 bool robust =
false)
const override;
91 bool relative =
true)
override;
93 const Eigen::Vector3d ¢er)
override;
95 const Eigen::Vector3d ¢er)
override;
107 Eigen::Vector3i
GetVoxel(
const Eigen::Vector3d &point)
const;
113 auto voxel = it->second;
114 return ((voxel.grid_index_.cast<
double>() +
115 Eigen::Vector3d(0.5, 0.5, 0.5)) *
119 return Eigen::Vector3d::Zero();
131 const Eigen::Vector3i &index)
const;
136 const std::vector<Eigen::Vector3d> &queries);
148 const Image &depth_map,
150 bool keep_voxels_outside_image);
162 const Image &silhouette_mask,
164 bool keep_voxels_outside_image);
174 std::shared_ptr<geometry::Octree>
ToOctree(
const size_t &max_depth)
const;
185 static std::shared_ptr<VoxelGrid>
CreateDense(
const Eigen::Vector3d &origin,
186 const Eigen::Vector3d &
color,
214 const Eigen::Vector3d &min_bound,
215 const Eigen::Vector3d &max_bound);
237 const Eigen::Vector3d &min_bound,
238 const Eigen::Vector3d &max_bound);
249 Eigen::Vector3d
origin_ = Eigen::Vector3d::Zero();
251 std::unordered_map<Eigen::Vector3i,
266 void Add(
const Eigen::Vector3i &voxel_index) {
269 "Tried to aggregate ColorVoxel with different "
275 void Add(
const Eigen::Vector3i &voxel_index,
const Eigen::Vector3d &
color) {
math::float4 color
Definition: LineSetBuffers.cpp:45
#define LogWarning(...)
Definition: Logging.h:63
Contains both intrinsic and extrinsic pinhole camera parameters.
Definition: PinholeCameraParameters.h:21
Class to aggregate color values from different votes in one voxel Computes the average color value in...
Definition: VoxelGrid.h:261
AvgColorVoxel()
Definition: VoxelGrid.h:263
void Add(const Eigen::Vector3i &voxel_index, const Eigen::Vector3d &color)
Definition: VoxelGrid.h:275
Eigen::Vector3d color_
Definition: VoxelGrid.h:294
void Add(const Eigen::Vector3i &voxel_index)
Definition: VoxelGrid.h:266
Eigen::Vector3i GetVoxelIndex() const
Definition: VoxelGrid.h:281
int num_of_points_
Definition: VoxelGrid.h:292
Eigen::Vector3i voxel_index_
Definition: VoxelGrid.h:293
Eigen::Vector3d GetAverageColor() const
Definition: VoxelGrid.h:283
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
Definition: BoundingVolume.h:160
The base geometry class for 3D geometries.
Definition: Geometry3D.h:28
The base geometry class.
Definition: Geometry.h:18
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:23
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:34
Octree datastructure.
Definition: Octree.h:244
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:25
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition: PointCloud.h:36
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:35
VoxelGrid is a collection of voxels which are aligned in grid.
Definition: VoxelGrid.h:61
static std::shared_ptr< VoxelGrid > CreateFromTriangleMesh(const TriangleMesh &input, double voxel_size)
Definition: VoxelGridFactory.cpp:157
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const override
Definition: VoxelGrid.cpp:81
void CreateFromOctree(const Octree &octree)
Definition: VoxelGrid.cpp:215
VoxelGrid & CarveSilhouette(const Image &silhouette_mask, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
Definition: VoxelGrid.cpp:305
VoxelGrid operator+(const VoxelGrid &voxelgrid) const
Definition: VoxelGrid.cpp:171
std::vector< Eigen::Vector3d > GetVoxelBoundingPoints(const Eigen::Vector3i &index) const
Return a vector of 3D coordinates that define the indexed voxel cube.
Definition: VoxelGrid.cpp:180
VoxelGrid()
Default Constructor.
Definition: VoxelGrid.h:64
VoxelGrid & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
Definition: VoxelGrid.cpp:114
OrientedBoundingBox GetOrientedBoundingBox(bool robust=false) const override
Definition: VoxelGrid.cpp:88
std::unordered_map< Eigen::Vector3i, Voxel, utility::hash_eigen< Eigen::Vector3i > > voxels_
Voxels contained in voxel grid.
Definition: VoxelGrid.h:254
bool IsEmpty() const override
Returns true iff the geometry is empty.
Definition: VoxelGrid.cpp:36
Eigen::Vector3d GetVoxelCenterCoordinate(const Eigen::Vector3i &idx) const
Function that returns the 3d coordinates of the queried voxel center.
Definition: VoxelGrid.h:110
Eigen::Vector3d origin_
Coordinate of the origin point.
Definition: VoxelGrid.h:249
VoxelGrid & Clear() override
Clear all elements in the geometry.
Definition: VoxelGrid.cpp:29
static std::shared_ptr< VoxelGrid > CreateFromPointCloudWithinBounds(const PointCloud &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
Definition: VoxelGridFactory.cpp:44
VoxelGrid & CarveDepthMap(const Image &depth_map, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
Definition: VoxelGrid.cpp:261
VoxelGrid & Scale(const double scale, const Eigen::Vector3d ¢er) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
Definition: VoxelGrid.cpp:109
Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
Definition: VoxelGrid.cpp:38
bool HasVoxels() const
Returns true if the voxel grid contains voxels.
Definition: VoxelGrid.h:101
std::vector< bool > CheckIfIncluded(const std::vector< Eigen::Vector3d > &queries)
Definition: VoxelGrid.cpp:202
VoxelGrid & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: VoxelGrid.cpp:98
bool HasColors() const
Returns true if the voxel grid contains voxel colors.
Definition: VoxelGrid.h:103
Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
Definition: VoxelGrid.cpp:51
static std::shared_ptr< VoxelGrid > CreateFromTriangleMeshWithinBounds(const TriangleMesh &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
Definition: VoxelGridFactory.cpp:99
Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
Definition: VoxelGrid.cpp:65
void AddVoxel(const Voxel &voxel)
Add a voxel with specified grid index and color.
Definition: VoxelGrid.cpp:196
VoxelGrid & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
Definition: VoxelGrid.cpp:103
std::vector< Voxel > GetVoxels() const
Definition: VoxelGrid.cpp:349
double voxel_size_
Size of the voxel.
Definition: VoxelGrid.h:247
static std::shared_ptr< VoxelGrid > CreateDense(const Eigen::Vector3d &origin, const Eigen::Vector3d &color, double voxel_size, double width, double height, double depth)
Definition: VoxelGridFactory.cpp:21
void RemoveVoxel(const Eigen::Vector3i &idx)
Remove a voxel with specified grid index.
Definition: VoxelGrid.cpp:200
VoxelGrid & operator+=(const VoxelGrid &voxelgrid)
Definition: VoxelGrid.cpp:120
static std::shared_ptr< VoxelGrid > CreateFromPointCloud(const PointCloud &input, double voxel_size)
Definition: VoxelGridFactory.cpp:90
Eigen::Vector3i GetVoxel(const Eigen::Vector3d &point) const
Returns voxel index given query point.
Definition: VoxelGrid.cpp:175
OrientedBoundingBox GetMinimalOrientedBoundingBox(bool robust=false) const override
Definition: VoxelGrid.cpp:93
std::shared_ptr< geometry::Octree > ToOctree(const size_t &max_depth) const
Definition: VoxelGrid.cpp:254
~VoxelGrid() override
Definition: VoxelGrid.h:67
Base Voxel class, containing grid id and color.
Definition: VoxelGrid.h:35
~Voxel()
Definition: VoxelGrid.h:49
Eigen::Vector3i grid_index_
Grid coordinate index of the voxel.
Definition: VoxelGrid.h:53
Voxel(const Eigen::Vector3i &grid_index, const Eigen::Vector3d &color)
Parameterized Constructor.
Definition: VoxelGrid.h:47
Eigen::Vector3d color_
Color of the voxel.
Definition: VoxelGrid.h:55
Voxel(const Eigen::Vector3i &grid_index)
Parameterized Constructor.
Definition: VoxelGrid.h:42
Voxel()
Default Constructor.
Definition: VoxelGrid.h:38
Definition: PinholeCameraIntrinsic.cpp:16