Open3D (C++ API)  0.17.0
Public Member Functions | Static Public Member Functions | Data Fields
open3d::geometry::VoxelGrid Class Reference

VoxelGrid is a collection of voxels which are aligned in grid. More...

#include <VoxelGrid.h>

Inheritance diagram for open3d::geometry::VoxelGrid:
open3d::geometry::Geometry3D open3d::geometry::Geometry

Public Member Functions

 VoxelGrid ()
 Default Constructor. More...
 
 VoxelGrid (const VoxelGrid &src_voxel_grid)
 Copy Constructor. More...
 
 ~VoxelGrid () override
 
VoxelGridClear () override
 Clear all elements in the geometry. More...
 
bool IsEmpty () const override
 Returns true iff the geometry is empty. More...
 
Eigen::Vector3d GetMinBound () const override
 Returns min bounds for geometry coordinates. More...
 
Eigen::Vector3d GetMaxBound () const override
 Returns max bounds for geometry coordinates. More...
 
Eigen::Vector3d GetCenter () const override
 Returns the center of the geometry coordinates. More...
 
AxisAlignedBoundingBox GetAxisAlignedBoundingBox () const override
 
OrientedBoundingBox GetOrientedBoundingBox (bool robust=false) const override
 
OrientedBoundingBox GetMinimalOrientedBoundingBox (bool robust=false) const override
 
VoxelGridTransform (const Eigen::Matrix4d &transformation) override
 Apply transformation (4x4 matrix) to the geometry coordinates. More...
 
VoxelGridTranslate (const Eigen::Vector3d &translation, bool relative=true) override
 Apply translation to the geometry coordinates. More...
 
VoxelGridScale (const double scale, const Eigen::Vector3d &center) override
 Apply scaling to the geometry coordinates. Given a scaling factor \(s\), and center \(c\), a given point \(p\) is transformed according to \(s (p - c) + c\). More...
 
VoxelGridRotate (const Eigen::Matrix3d &R, const Eigen::Vector3d &center) override
 Apply rotation to the geometry coordinates and normals. Given a rotation matrix \(R\), and center \(c\), a given point \(p\) is transformed according to \(R (p - c) + c\). More...
 
VoxelGridoperator+= (const VoxelGrid &voxelgrid)
 
VoxelGrid operator+ (const VoxelGrid &voxelgrid) const
 
bool HasVoxels () const
 Returns true if the voxel grid contains voxels. More...
 
bool HasColors () const
 Returns true if the voxel grid contains voxel colors. More...
 
Eigen::Vector3i GetVoxel (const Eigen::Vector3d &point) const
 Returns voxel index given query point. More...
 
Eigen::Vector3d GetVoxelCenterCoordinate (const Eigen::Vector3i &idx) const
 Function that returns the 3d coordinates of the queried voxel center. More...
 
void AddVoxel (const Voxel &voxel)
 Add a voxel with specified grid index and color. More...
 
std::vector< Eigen::Vector3d > GetVoxelBoundingPoints (const Eigen::Vector3i &index) const
 Return a vector of 3D coordinates that define the indexed voxel cube. More...
 
std::vector< bool > CheckIfIncluded (const std::vector< Eigen::Vector3d > &queries)
 
VoxelGridCarveDepthMap (const Image &depth_map, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
 
VoxelGridCarveSilhouette (const Image &silhouette_mask, const camera::PinholeCameraParameters &camera_parameter, bool keep_voxels_outside_image)
 
void CreateFromOctree (const Octree &octree)
 
std::shared_ptr< geometry::OctreeToOctree (const size_t &max_depth) const
 
std::vector< VoxelGetVoxels () const
 
- Public Member Functions inherited from open3d::geometry::Geometry3D
 ~Geometry3D () override
 
virtual Geometry3DRotate (const Eigen::Matrix3d &R)
 
- Public Member Functions inherited from open3d::geometry::Geometry
virtual ~Geometry ()
 
GeometryType GetGeometryType () const
 Returns one of registered geometry types. More...
 
int Dimension () const
 Returns whether the geometry is 2D or 3D. More...
 
std::string GetName () const
 
void SetName (const std::string &name)
 

Static Public Member Functions

static std::shared_ptr< VoxelGridCreateDense (const Eigen::Vector3d &origin, const Eigen::Vector3d &color, double voxel_size, double width, double height, double depth)
 
static std::shared_ptr< VoxelGridCreateFromPointCloud (const PointCloud &input, double voxel_size)
 
static std::shared_ptr< VoxelGridCreateFromPointCloudWithinBounds (const PointCloud &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
 
static std::shared_ptr< VoxelGridCreateFromTriangleMesh (const TriangleMesh &input, double voxel_size)
 
static std::shared_ptr< VoxelGridCreateFromTriangleMeshWithinBounds (const TriangleMesh &input, double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound)
 
- Static Public Member Functions inherited from open3d::geometry::Geometry3D
static Eigen::Matrix3d GetRotationMatrixFromXYZ (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from XYZ RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromYZX (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from YZX RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromZXY (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from ZXY RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromXZY (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from XZY RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromZYX (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from ZYX RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromYXZ (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from YXZ RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromAxisAngle (const Eigen::Vector3d &rotation)
 Get Rotation Matrix from AxisAngle RotationType. More...
 
static Eigen::Matrix3d GetRotationMatrixFromQuaternion (const Eigen::Vector4d &rotation)
 Get Rotation Matrix from Quaternion. More...
 

Data Fields

double voxel_size_ = 0.0
 Size of the voxel. More...
 
Eigen::Vector3d origin_ = Eigen::Vector3d::Zero()
 Coorindate of the origin point. More...
 
std::unordered_map< Eigen::Vector3i, Voxel, utility::hash_eigen< Eigen::Vector3i > > voxels_
 Voxels contained in voxel grid. More...
 

Additional Inherited Members

- Public Types inherited from open3d::geometry::Geometry
enum class  GeometryType {
  Unspecified = 0 , PointCloud = 1 , VoxelGrid = 2 , Octree = 3 ,
  LineSet = 4 , MeshBase = 5 , TriangleMesh = 6 , HalfEdgeTriangleMesh = 7 ,
  Image = 8 , RGBDImage = 9 , TetraMesh = 10 , OrientedBoundingBox = 11 ,
  AxisAlignedBoundingBox = 12
}
 Specifies possible geometry types. More...
 
- Protected Member Functions inherited from open3d::geometry::Geometry3D
 Geometry3D (GeometryType type)
 Parameterized Constructor. More...
 
Eigen::Vector3d ComputeMinBound (const std::vector< Eigen::Vector3d > &points) const
 Compute min bound of a list points. More...
 
Eigen::Vector3d ComputeMaxBound (const std::vector< Eigen::Vector3d > &points) const
 Compute max bound of a list points. More...
 
Eigen::Vector3d ComputeCenter (const std::vector< Eigen::Vector3d > &points) const
 Computer center of a list of points. More...
 
void ResizeAndPaintUniformColor (std::vector< Eigen::Vector3d > &colors, const size_t size, const Eigen::Vector3d &color) const
 Resizes the colors vector and paints a uniform color. More...
 
void TransformPoints (const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &points) const
 Transforms all points with the transformation matrix. More...
 
void TransformNormals (const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &normals) const
 Transforms the normals with the transformation matrix. More...
 
void TransformCovariances (const Eigen::Matrix4d &transformation, std::vector< Eigen::Matrix3d > &covariances) const
 Transforms all covariance matrices with the transformation. More...
 
void TranslatePoints (const Eigen::Vector3d &translation, std::vector< Eigen::Vector3d > &points, bool relative) const
 Apply translation to the geometry coordinates. More...
 
void ScalePoints (const double scale, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center) const
 Scale the coordinates of all points by the scaling factor scale. More...
 
void RotatePoints (const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center) const
 Rotate all points with the rotation matrix R. More...
 
void RotateNormals (const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &normals) const
 Rotate all normals with the rotation matrix R. More...
 
void RotateCovariances (const Eigen::Matrix3d &R, std::vector< Eigen::Matrix3d > &covariances) const
 Rotate all covariance matrices with the rotation matrix R. More...
 
- Protected Member Functions inherited from open3d::geometry::Geometry
 Geometry (GeometryType type, int dimension)
 Parameterized Constructor. More...
 

Detailed Description

VoxelGrid is a collection of voxels which are aligned in grid.

Constructor & Destructor Documentation

◆ VoxelGrid() [1/2]

open3d::geometry::VoxelGrid::VoxelGrid ( )
inline

Default Constructor.

◆ VoxelGrid() [2/2]

open3d::geometry::VoxelGrid::VoxelGrid ( const VoxelGrid src_voxel_grid)

Copy Constructor.

◆ ~VoxelGrid()

open3d::geometry::VoxelGrid::~VoxelGrid ( )
inlineoverride

Member Function Documentation

◆ AddVoxel()

void open3d::geometry::VoxelGrid::AddVoxel ( const Voxel voxel)

Add a voxel with specified grid index and color.

◆ CarveDepthMap()

VoxelGrid & open3d::geometry::VoxelGrid::CarveDepthMap ( const Image depth_map,
const camera::PinholeCameraParameters camera_parameter,
bool  keep_voxels_outside_image 
)

Remove all voxels from the VoxelGrid where none of the boundary points of the voxel projects to depth value that is smaller, or equal than the projected depth of the boundary point. If keep_voxels_outside_image is true then voxels are only carved if all boundary points project to a valid image location.

Parameters
depth_mapDepth map (Image) used for VoxelGrid carving.
camera_parameterInput Camera Parameters.
keep_voxels_outside_imageProject all voxels to a valid location.

◆ CarveSilhouette()

VoxelGrid & open3d::geometry::VoxelGrid::CarveSilhouette ( const Image silhouette_mask,
const camera::PinholeCameraParameters camera_parameter,
bool  keep_voxels_outside_image 
)

Remove all voxels from the VoxelGrid where none of the boundary points of the voxel projects to a valid mask pixel (pixel value > 0). If keep_voxels_outside_image is true then voxels are only carved if all boundary points project to a valid image location.

Parameters
silhouette_maskSilhouette mask (Image) used for VoxelGrid carving.
camera_parameterInput Camera Parameters.
keep_voxels_outside_imageProject all voxels to a valid location.

◆ CheckIfIncluded()

std::vector< bool > open3d::geometry::VoxelGrid::CheckIfIncluded ( const std::vector< Eigen::Vector3d > &  queries)

Element-wise check if a query in the list is included in the VoxelGrid Queries are double precision and are mapped to the closest voxel.

◆ Clear()

VoxelGrid & open3d::geometry::VoxelGrid::Clear ( )
overridevirtual

Clear all elements in the geometry.

Implements open3d::geometry::Geometry3D.

◆ CreateDense()

std::shared_ptr< VoxelGrid > open3d::geometry::VoxelGrid::CreateDense ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  color,
double  voxel_size,
double  width,
double  height,
double  depth 
)
static

Creates a voxel grid where every voxel is set (hence dense). This is a useful starting point for voxel carving.

Parameters
originCoordinate center of the VoxelGrid
colorVoxel color for all voxels of the VoxelGrid.
voxel_sizeVoxel size of of the VoxelGrid construction.
widthSpatial width extend of the VoxelGrid.
heightSpatial height extend of the VoxelGrid.
depthSpatial depth extend of the VoxelGrid.

◆ CreateFromOctree()

void open3d::geometry::VoxelGrid::CreateFromOctree ( const Octree octree)

Create VoxelGrid from Octree

Parameters
octreeThe input Octree.

◆ CreateFromPointCloud()

std::shared_ptr< VoxelGrid > open3d::geometry::VoxelGrid::CreateFromPointCloud ( const PointCloud input,
double  voxel_size 
)
static

Creates a VoxelGrid from a given PointCloud. The color value of a given voxel is the average color value of the points that fall into it (if the PointCloud has colors). The bounds of the created VoxelGrid are computed from the PointCloud.

Parameters
inputThe input PointCloud.
voxel_sizeVoxel size of of the VoxelGrid construction.

◆ CreateFromPointCloudWithinBounds()

std::shared_ptr< VoxelGrid > open3d::geometry::VoxelGrid::CreateFromPointCloudWithinBounds ( const PointCloud input,
double  voxel_size,
const Eigen::Vector3d &  min_bound,
const Eigen::Vector3d &  max_bound 
)
static

Creates a VoxelGrid from a given PointCloud. The color value of a given voxel is the average color value of the points that fall into it (if the PointCloud has colors). The bounds of the created VoxelGrid are defined by the given parameters.

Parameters
inputThe input PointCloud.
voxel_sizeVoxel size of of the VoxelGrid construction.
min_boundMinimum boundary point for the VoxelGrid to create.
max_boundMaximum boundary point for the VoxelGrid to create.

◆ CreateFromTriangleMesh()

std::shared_ptr< VoxelGrid > open3d::geometry::VoxelGrid::CreateFromTriangleMesh ( const TriangleMesh input,
double  voxel_size 
)
static

Creates a VoxelGrid from a given TriangleMesh. No color information is converted. The bounds of the created VoxelGrid are computed from the TriangleMesh.

Parameters
inputThe input TriangleMesh.
voxel_sizeVoxel size of of the VoxelGrid construction.

◆ CreateFromTriangleMeshWithinBounds()

std::shared_ptr< VoxelGrid > open3d::geometry::VoxelGrid::CreateFromTriangleMeshWithinBounds ( const TriangleMesh input,
double  voxel_size,
const Eigen::Vector3d &  min_bound,
const Eigen::Vector3d &  max_bound 
)
static

Creates a VoxelGrid from a given TriangleMesh. No color information is converted. The bounds of the created VoxelGrid are defined by the given parameters..

Parameters
inputThe input TriangleMesh.
voxel_sizeVoxel size of of the VoxelGrid construction.
min_boundMinimum boundary point for the VoxelGrid to create.
max_boundMaximum boundary point for the VoxelGrid to create.

◆ GetAxisAlignedBoundingBox()

AxisAlignedBoundingBox open3d::geometry::VoxelGrid::GetAxisAlignedBoundingBox ( ) const
overridevirtual

Creates the axis-aligned bounding box around the object. Further details in AxisAlignedBoundingBox::AxisAlignedBoundingBox()

Implements open3d::geometry::Geometry3D.

◆ GetCenter()

Eigen::Vector3d open3d::geometry::VoxelGrid::GetCenter ( ) const
overridevirtual

Returns the center of the geometry coordinates.

Implements open3d::geometry::Geometry3D.

◆ GetMaxBound()

Eigen::Vector3d open3d::geometry::VoxelGrid::GetMaxBound ( ) const
overridevirtual

Returns max bounds for geometry coordinates.

Implements open3d::geometry::Geometry3D.

◆ GetMinBound()

Eigen::Vector3d open3d::geometry::VoxelGrid::GetMinBound ( ) const
overridevirtual

Returns min bounds for geometry coordinates.

Implements open3d::geometry::Geometry3D.

◆ GetMinimalOrientedBoundingBox()

OrientedBoundingBox open3d::geometry::VoxelGrid::GetMinimalOrientedBoundingBox ( bool  robust = false) const
overridevirtual

Creates an oriented bounding box that is identical to the axis-aligned bounding from GetAxisAlignedBoundingBox().

Implements open3d::geometry::Geometry3D.

◆ GetOrientedBoundingBox()

OrientedBoundingBox open3d::geometry::VoxelGrid::GetOrientedBoundingBox ( bool  robust = false) const
overridevirtual

Creates an oriented bounding box that is identical to the axis-aligned bounding from GetAxisAlignedBoundingBox().

Implements open3d::geometry::Geometry3D.

◆ GetVoxel()

Eigen::Vector3i open3d::geometry::VoxelGrid::GetVoxel ( const Eigen::Vector3d &  point) const

Returns voxel index given query point.

◆ GetVoxelBoundingPoints()

std::vector< Eigen::Vector3d > open3d::geometry::VoxelGrid::GetVoxelBoundingPoints ( const Eigen::Vector3i &  index) const

Return a vector of 3D coordinates that define the indexed voxel cube.

◆ GetVoxelCenterCoordinate()

Eigen::Vector3d open3d::geometry::VoxelGrid::GetVoxelCenterCoordinate ( const Eigen::Vector3i &  idx) const
inline

Function that returns the 3d coordinates of the queried voxel center.

◆ GetVoxels()

std::vector< Voxel > open3d::geometry::VoxelGrid::GetVoxels ( ) const

Returns List of Voxel: Voxels contained in voxel grid. Changes to the voxels returned from this method are not reflected in the voxel grid.

◆ HasColors()

bool open3d::geometry::VoxelGrid::HasColors ( ) const
inline

Returns true if the voxel grid contains voxel colors.

◆ HasVoxels()

bool open3d::geometry::VoxelGrid::HasVoxels ( ) const
inline

Returns true if the voxel grid contains voxels.

◆ IsEmpty()

bool open3d::geometry::VoxelGrid::IsEmpty ( ) const
overridevirtual

Returns true iff the geometry is empty.

Implements open3d::geometry::Geometry3D.

◆ operator+()

VoxelGrid open3d::geometry::VoxelGrid::operator+ ( const VoxelGrid voxelgrid) const

◆ operator+=()

VoxelGrid & open3d::geometry::VoxelGrid::operator+= ( const VoxelGrid voxelgrid)

◆ Rotate()

VoxelGrid & open3d::geometry::VoxelGrid::Rotate ( const Eigen::Matrix3d &  R,
const Eigen::Vector3d &  center 
)
overridevirtual

Apply rotation to the geometry coordinates and normals. Given a rotation matrix \(R\), and center \(c\), a given point \(p\) is transformed according to \(R (p - c) + c\).

Parameters
RA 3x3 rotation matrix
centerRotation center that is used for the rotation.

Implements open3d::geometry::Geometry3D.

◆ Scale()

VoxelGrid & open3d::geometry::VoxelGrid::Scale ( const double  scale,
const Eigen::Vector3d &  center 
)
overridevirtual

Apply scaling to the geometry coordinates. Given a scaling factor \(s\), and center \(c\), a given point \(p\) is transformed according to \(s (p - c) + c\).

Parameters
scaleThe scale parameter that is multiplied to the points/vertices of the geometry.
centerScale center that is used to resize the geometry.

Implements open3d::geometry::Geometry3D.

◆ ToOctree()

std::shared_ptr< geometry::Octree > open3d::geometry::VoxelGrid::ToOctree ( const size_t &  max_depth) const

Convert to Octree.

Parameters
max_depthMaximum depth of the octree.

◆ Transform()

VoxelGrid & open3d::geometry::VoxelGrid::Transform ( const Eigen::Matrix4d &  transformation)
overridevirtual

Apply transformation (4x4 matrix) to the geometry coordinates.

Implements open3d::geometry::Geometry3D.

◆ Translate()

VoxelGrid & open3d::geometry::VoxelGrid::Translate ( const Eigen::Vector3d &  translation,
bool  relative = true 
)
overridevirtual

Apply translation to the geometry coordinates.

Parameters
translationA 3D vector to transform the geometry.
relativeIf true, the translation is directly applied to the geometry. Otherwise, the geometry center is moved to the translation.

Implements open3d::geometry::Geometry3D.

Field Documentation

◆ origin_

Eigen::Vector3d open3d::geometry::VoxelGrid::origin_ = Eigen::Vector3d::Zero()

Coorindate of the origin point.

◆ voxel_size_

double open3d::geometry::VoxelGrid::voxel_size_ = 0.0

Size of the voxel.

◆ voxels_

std::unordered_map<Eigen::Vector3i, Voxel, utility::hash_eigen<Eigen::Vector3i> > open3d::geometry::VoxelGrid::voxels_

Voxels contained in voxel grid.


The documentation for this class was generated from the following files: