|
Voxel grid storing the number of points per label in each voxel. More...
#include <VisionX/libraries/VoxelGrids/LabelDensity/VoxelGrid.h>
Public Member Functions | |
void | addPointCloud (const pcl::PointCloud< pcl::PointXYZL > &pointCloud, const Eigen::Matrix4f &pointCloudPose=Eigen::Matrix4f::Identity()) |
Add the point cloud. More... | |
void | addPointCloud (const pcl::PointCloud< pcl::PointXYZRGBL > &pointCloud, const Eigen::Matrix4f &pointCloudPose=Eigen::Matrix4f::Identity()) |
std::set< Label > | getUniqueLabels () const |
Get the set of unique labels. More... | |
void | readJson (const std::filesystem::path &file) |
void | readJson (std::istream &is) |
Read this voxel grid from JSON. More... | |
void | reduceNoise (std::size_t minNumPoints) |
Remove entries with number of points below minNumPoints . More... | |
void | toCsv (const std::filesystem::path &file, bool includeTotal=false) const |
void | toCsv (std::ostream &os, bool includeTotal=false) const |
Write the voxel data to a CSV file. More... | |
VoxelGrid () | |
Construct a voxel grid with 0 voxels of size 1.0. More... | |
template<typename OtherVoxelT > | |
VoxelGrid (const VoxelGrid< OtherVoxelT > &other) | |
Construct a voxel grid with the same structure as other. More... | |
VoxelGrid (const VoxelGrid< VoxelT > &other)=default | |
Ordinary copy constructor for voxel grid with same VoxelT. More... | |
VoxelGrid (const VoxelGridStructure &structure, const std::vector< VoxelGrid::VoxelT > &voxelData) | |
Construct a voxel grid with the given structure and data. More... | |
VoxelGrid (const VoxelGridStructure &structure, const VoxelT &value={}) | |
Construct a voxel grid with the given structure and voxels with given value. More... | |
void | writeJson (const std::filesystem::path &file) const |
void | writeJson (std::ostream &os) const |
Write this voxel grid to JSON. More... | |
Public Member Functions inherited from VoxelGrid< VoxelT > | |
std::vector< VoxelT >::iterator | begin () |
Get an iterator to the first voxel. More... | |
std::vector< VoxelT >::const_iterator | begin () const |
Get an iterator to the first voxel. More... | |
std::vector< VoxelT >::const_iterator | cbegin () const |
Get an iterator to the first voxel. More... | |
std::vector< VoxelT >::const_iterator | cend () const |
Get an iterator to the element following the last voxel. More... | |
void | checkIsInside (const Eigen::Vector3i &index) const |
Assert that the given index is a valid grid index. More... | |
std::vector< VoxelT >::iterator | end () |
Get an iterator to the element following the last voxel. More... | |
std::vector< VoxelT >::const_iterator | end () const |
Get an iterator to the element following the last voxel. More... | |
Eigen::Vector3f | getCenter () const |
Get the geometric center of the grid the world frame (which differs from the origin for even grid sizes). More... | |
Eigen::Matrix4f | getCenterPose () const |
Get the grid pose positioned at the grid center in the world frame. More... | |
Eigen::Vector3f | getExtents () const |
Get extent of the grid along each axis (encompassing the whole voxels). More... | |
Eigen::Vector3f | getExtentsOfCenters () const |
Get extent of the grid along each axis (encompassing only voxel centers). More... | |
Eigen::Vector3i | getGridSizes () const |
Get the grid size. More... | |
Eigen::Matrix32f | getLocalBoundingBox () const |
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns). More... | |
Eigen::Matrix32f | getLocalBoundingBoxOfCenters () const |
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns). More... | |
std::size_t | getNumVoxels () const |
Get the number of voxels in the grid. More... | |
Eigen::Quaternionf | getOrientation () const |
Get the grid orienation in the world frame. More... | |
Eigen::Vector3f | getOrigin () const |
Get the grid origin in the world frame (center of voxel [0 0 0]). More... | |
Eigen::Matrix4f | getPose () const |
Get the grid pose in the world frame. More... | |
VoxelGridStructure | getStructure () const |
Get the voxel grid structure. More... | |
VoxelT & | getVoxel (const Eigen::Vector3f &point, bool local=false) |
Get the voxel closest to the given point. More... | |
const VoxelT & | getVoxel (const Eigen::Vector3f &point, bool local=false) const |
VoxelT & | getVoxel (const Eigen::Vector3i &index) |
Get the voxel with the given grid index. More... | |
const VoxelT & | getVoxel (const Eigen::Vector3i &index) const |
VoxelT & | getVoxel (int x, int y, int z) |
Get the voxel with the given grid index. More... | |
const VoxelT & | getVoxel (int x, int y, int z) const |
VoxelT & | getVoxel (std::size_t index) |
Get the voxel with the given index. More... | |
const VoxelT & | getVoxel (std::size_t index) const |
Eigen::Vector3f | getVoxelCenter (const Eigen::Vector3i &index, bool local=false) const |
Get the center of the voxel with the given index. More... | |
Eigen::Vector3f | getVoxelCenter (int x, int y, int z, bool local=false) const |
Get the center of the voxel with the given index. More... | |
Eigen::Vector3f | getVoxelCenter (std::size_t index, bool local=false) const |
Get the center of the voxel with the given index. More... | |
std::size_t | getVoxelFlatIndex (const Eigen::Vector3f &point, bool local=false) const |
Get the flat index of the voxel closest to point . More... | |
std::size_t | getVoxelFlatIndex (const Eigen::Vector3i &index) const |
Get the flat index of the voxel with given grid index. More... | |
std::size_t | getVoxelFlatIndex (int x, int y, int z) const |
Get the flat index of the voxel with given grid index. More... | |
Eigen::Vector3i | getVoxelGridIndex (const Eigen::Vector3f &point, bool local=false) const |
Get the grid index of the voxel closest to point. More... | |
Eigen::Vector3i | getVoxelGridIndex (size_t index) const |
Get the grid index of the voxel with the given flat index. More... | |
Eigen::Vector3i | getVoxelGridIndexMax () const |
Get the maximal (along each axis) voxel grid index. More... | |
Eigen::Vector3i | getVoxelGridIndexMin () const |
Get the minimal (along each axis) voxel grid index. More... | |
const std::vector< VoxelT > & | getVoxels () const |
Get the voxels. More... | |
Eigen::Vector3f | getVoxelSizes () const |
Get the voxel size. More... | |
bool | isInside (const Eigen::Vector3f &point, bool local=false) const |
Indicate whether the given point is inside the voxel. More... | |
bool | isInside (const Eigen::Vector3i &index) const |
Indicate whether the given point is inside the voxel. More... | |
std::size_t | numVoxels () const |
Get the number of voxels in the grid. More... | |
VoxelT & | operator[] (const Eigen::Vector3i &index) |
Get the voxel with given grid index. More... | |
const VoxelT & | operator[] (const Eigen::Vector3i &index) const |
VoxelT & | operator[] (std::size_t index) |
Get the voxel with given flat index. More... | |
const VoxelT & | operator[] (std::size_t index) const |
void | reset (const VoxelT &value={}) |
Reset the voxel data by numVoxels() voxels with given value. More... | |
void | resetStructure (const VoxelGridStructure &structure) |
Set the voxel grid structure and reset voxel data. More... | |
void | setCenter (const Eigen::Vector3f &value) |
Set the geometric center of the grid the world frame (which differs from the origin for even grid sizes). More... | |
void | setCenterPose (const Eigen::Matrix4f &value) |
Set the grid pose so that the grid center is the position of the given pose under the given orientation. More... | |
void | setGridSizes (const Eigen::Vector3i &gridSizes) |
Set the grid size. This resets the grid data. More... | |
void | setGridSizes (float gridSizes) |
Set the grid size for a cubic grid. Resets the grid data. More... | |
void | setOrientation (const Eigen::Quaternionf &value) |
Set the grid orienation in the world frame. More... | |
void | setOrigin (const Eigen::Vector3f &value) |
Set the grid origin the world frame (center of voxel [0 0 0]). More... | |
void | setPose (const Eigen::Matrix4f &value) |
Get the grid pose in the world frame. More... | |
void | setVoxels (const std::vector< VoxelT > &voxels) |
Set the voxels. More... | |
void | setVoxelSizes (const Eigen::Vector3f &voxelSizes) |
Set the voxel size. The grid data is not updated. More... | |
void | setVoxelSizes (float voxelSize) |
Set the voxel size of cubic voxels. The grid data is not updated. More... | |
VoxelGrid () | |
Construct a voxel grid with 0 voxels of size 1.0. More... | |
VoxelGrid (const VoxelGrid< OtherVoxelT > &other) | |
Construct a voxel grid with the same structure as other. More... | |
VoxelGrid (const VoxelGrid< VoxelT > &other)=default | |
Ordinary copy constructor for voxel grid with same VoxelT. More... | |
VoxelGrid (const VoxelGridStructure &structure, const std::vector< VoxelGrid::VoxelT > &voxelData) | |
Construct a voxel grid with the given structure and data. More... | |
VoxelGrid (const VoxelGridStructure &structure, const VoxelT &value={}) | |
Construct a voxel grid with the given structure and voxels with given value. More... | |
Additional Inherited Members | |
Public Types inherited from VoxelGrid< VoxelT > | |
using | VoxelT = VoxelT |
The voxel type. More... | |
Protected Attributes inherited from VoxelGrid< VoxelT > | |
VoxelGridStructure | _struct |
The geometric structure. More... | |
std::vector< VoxelT > | _voxels |
The voxel data. More... | |
Voxel grid storing the number of points per label in each voxel.
Definition at line 69 of file VoxelGrid.h.
Construct a voxel grid with 0 voxels of size 1.0.
Definition at line 456 of file VoxelGrid.hpp.
Construct a voxel grid with the given structure and voxels with given value.
Definition at line 460 of file VoxelGrid.hpp.
Construct a voxel grid with the given structure and data.
The size of voxelData
must match the grid size of structure
.
error::InvalidVoxelDataSize | If the size does not match. |
Definition at line 465 of file VoxelGrid.hpp.
VoxelGrid | ( | typename OtherVoxelT | ) |
Construct a voxel grid with the same structure as other.
Definition at line 478 of file VoxelGrid.hpp.
|
default |
Ordinary copy constructor for voxel grid with same VoxelT.
void addPointCloud | ( | const pcl::PointCloud< pcl::PointXYZL > & | pointCloud, |
const Eigen::Matrix4f & | pointCloudPose = Eigen::Matrix4f::Identity() |
||
) |
Add the point cloud.
pointCloud | The point cloud. |
pointCloudPose | The point cloud pose (in the same frame as the grid's pose). |
Definition at line 128 of file VoxelGrid.cpp.
void addPointCloud | ( | const pcl::PointCloud< pcl::PointXYZRGBL > & | pointCloud, |
const Eigen::Matrix4f & | pointCloudPose = Eigen::Matrix4f::Identity() |
||
) |
Definition at line 135 of file VoxelGrid.cpp.
Get the set of unique labels.
Definition at line 143 of file VoxelGrid.cpp.
void readJson | ( | const std::filesystem::path & | file | ) |
void readJson | ( | std::istream & | is | ) |
Read this voxel grid from JSON.
Definition at line 247 of file VoxelGrid.cpp.
void reduceNoise | ( | std::size_t | minNumPoints | ) |
Remove entries with number of points below minNumPoints
.
Definition at line 156 of file VoxelGrid.cpp.
void toCsv | ( | const std::filesystem::path & | file, |
bool | includeTotal = false |
||
) | const |
void toCsv | ( | std::ostream & | os, |
bool | includeTotal = false |
||
) | const |
Write the voxel data to a CSV file.
(Structure is not stored.)
The first column, "index", specified the flat voxel index. The other columns represent the labels, and each row entry specifies the number of points with that label in the respective voxel.
If includeTotal
is true, a final column "total" is added, storing the voxel-wise total number of points.
Definition at line 273 of file VoxelGrid.cpp.
void writeJson | ( | const std::filesystem::path & | file | ) | const |
Definition at line 242 of file VoxelGrid.cpp.
void writeJson | ( | std::ostream & | os | ) | const |
Write this voxel grid to JSON.
Definition at line 237 of file VoxelGrid.cpp.