CVB++ 14.0
SparsePointCloud Class Reference

A sparse Cartesian 3D point cloud object. More...

#include <cvb/sparse_point_cloud.hpp>

Inherits PointCloud.

Public Member Functions

DensePointCloudPtr ToDensePointCloud (size_t &numDroppedPoints, ConversionMode conversionMode=ConversionMode::Automatic) const
 Creates a dense point cloud from a sparse point cloud. More...
 
DensePointCloudPtr ToDensePointCloud (ConversionMode conversionMode=ConversionMode::Automatic) const
 Creates a dense point cloud from a sparse point cloud. More...
 
SparsePointCloudPtr PlaneCrop (const Plane3D &plane, const ValueRange< double > &range, CropRange cropRange) const
 Creates a new point cloud where points within or outside a range parallel to given plane are cropped. More...
 
SparsePointCloudPtr PlaneCrop (const Plane3D &plane, double threshold, CropDirection cropBelowAbove=CropDirection::Below) const
 Creates a new point cloud which only consists of the points below or above given plane. More...
 
template<class T >
SparseComponentsPointers3D< T > PointComponents () const
 Get the point components from the given point cloud. More...
 
template<class T >
bool TryPointComponents (SparseComponentsPointers3D< T > &components) const noexcept
 Tries to get the point components from the given point cloud. More...
 
- Public Member Functions inherited from PointCloud
PointCloudLayout Layout () const
 Get the layout of the available buffers/planes of the given point cloud. More...
 
class DataType DataType () const
 Gets the DataType of the x,y,z(,w) components of the given PointCloud. More...
 
std::size_t NumPoints () const
 Gets the number of x,y,z(,w) points in the given point cloud. More...
 
ComponentsPointers3D PointComponents () const
 Tries to get the point components from the given point cloud. More...
 
template<class T >
std::size_t Points (Point3D< T > *&points) const
 Gets the 3D points from the given point cloud. More...
 
template<class T >
std::size_t PointsH (Point3DH< T > *&pointsH) const
 Tries to get the 3D points from the given point cloud. More...
 
Cuboid CalculateBoundingBox () const
 Calculates the minimum and maximum extent of the point cloud. More...
 
Point3D< double > CalculateCenterOfGravity () const
 Calculates the center of gravity of the point cloud. More...
 
Matrix3D CalculateCovarianceMatrix () const
 Calculates the covariance matrix of the point cloud. More...
 
Plane3D FitPlane () const
 Fits a plane in the points of the point cloud without cropping it. More...
 
Plane3D FitPlane (const Cuboid &aoi) const
 Fits a plane in the points of the point cloud for a specified area of interest. More...
 
template<class T >
std::shared_ptr< T > Crop (const Cuboid &clipBox) const
 Creates a new point cloud which only consists of the points inside the clip box. More...
 
template<class T >
std::shared_ptr< T > FrustumCrop (const Cuboid &clipBox, Angle theta, Angle phi) const
 Creates a new point cloud which only consists of the points inside the clipBox, where the orientation of the two boundary planes Z=Zmin and Z=Zmax can be modified by angles theta and phi. More...
 
template<class T >
std::shared_ptr< T > PlaneCrop (const Plane3D &plane, const ValueRange< double > &range, CropRange cropRange) const
 Creates a new point cloud where points within or outside a range parallel to given plane are cropped. More...
 
template<class T >
std::shared_ptr< T > PlaneCrop (const Plane3D &plane, double threshold, CropDirection cropBelowAbove=CropDirection::Below) const
 Creates a new point cloud which only consists of the points below or above given plane. More...
 
PointCloudPtr Downsample (DownSampleMode mode, int value) const
 Creates a new point cloud which has several points being removed dependent on the down sample mode and value. More...
 
PointCloudPtr Duplicate () const
 Creates a new point cloud which is a copy this point cloud. More...
 
void Save (const String &fileName) const
 Saves the given point cloud to the file with the given FileName. More...
 
PointCloudPtr Convert (PointCloudFlags flags) const
 Creates a new point cloud, which is a copy from this point cloud, but with possibly different data type and number of components. More...
 
PointCloudPtr Scale (Factors3D factors) const
 Creates a new point cloud with all points being scaled by the given factors. More...
 
PointCloudPtr Transform (const AffineMatrix3D &transformation) const
 Creates a new point cloud with all points being transformed by the given transformation. More...
 
PointCloudPtr Transform (const Matrix3DH &transformation) const
 Creates a new point cloud with all points being transformed by the given transformation. More...
 
void Transform (const AffineMatrix3D &affineTransformation, PointCloud &pointCloud)
 Transforms all points in this point cloud by the given AffineTransformation and stores them in the given point cloud. More...
 
void Transform (const Cvb::Matrix3DH &transformation, PointCloud &pointCloud)
 Transforms all points in this point cloud by the given transformation and stores them in the given point cloud. More...
 
std::unique_ptr< Cvb::ImageRangeMap (ValueRange< double > xRange, ValueRange< double > yRange, Size2D< int > size, double background) const
 Creates a new range map image via linear projection in negative z-direction. More...
 
int PlaneCount () const noexcept
 Gets the number of planes enumerated by this object. More...
 
std::vector< PlanePtrPlanes () const
 Gets all available planes enumerated by this object. More...
 
PlanePtr Plane (int index) const
 Index based plane access. More...
 
size_t MemorySize (PointCloudFlags flags, Cvb::PointCloudFileFormat format) const
 Determines the amount of memory needed for ToMemory. More...
 
template<class Point >
size_t MemorySize (Cvb::PointCloudFileFormat format) const
 Determines the amount of memory needed for ToMemory. More...
 
void ToMemory (PointCloudFlags flags, Cvb::PointCloudFileFormat format, size_t size, void *buffer) const
 Saves the point cloud to the memory in the given format. More...
 
template<class Point >
void ToMemory (Cvb::PointCloudFileFormat format, size_t size, std::uint8_t *buffer) const
 Saves the point cloud to the memory in the given format. More...
 
void * Handle () const noexcept
 Returns C-API style handle to Node Object. More...
 

Static Public Member Functions

static SparsePointCloudPtr FromDensePointCloud (const DensePointCloud &densePointCloud)
 Creates a sparse point cloud from a dense point cloud with confidence plane. More...
 
static SparsePointCloudPtr FromComposite (CompositePtr object)
 Creates a sparse point cloud from a composite. More...
 
- Static Public Member Functions inherited from PointCloud
static PointCloudPtr FromHandle (HandleGuard< PointCloud > &&guard)
 Creates a point cloud from a classic API handle. More...
 
template<class T >
static std::shared_ptr< T > FromComposite (CompositePtr object)
 Creates a point cloud from a composite. More...
 
static PointCloudPtr FromMemory (void *buffer, size_t size, PointCloudFlags flags, Cvb::PointCloudFileFormat format)
 Creates a point cloud reading memory from buffer. More...
 
template<class Point >
static PointCloudPtr FromMemory (void *buffer, size_t size, Cvb::PointCloudFileFormat format)
 Creates a point cloud reading memory from buffer. More...
 

Additional Inherited Members

Detailed Description

A sparse Cartesian 3D point cloud object.

A sparse point cloud is logically seen an array of 3D points. There is no order or neighboring information between the single points.

It has less memory than a dense point cloud.

Conversion to a dense point cloud is difficult, as the grid thus neighbor information is missing.

See also
DensePointCloud

Member Function Documentation

◆ FromComposite()

static SparsePointCloudPtr FromComposite ( CompositePtr  object)
inlinestatic

Creates a sparse point cloud from a composite.

Parameters
[in]objectA composite to share.
Returns
A sparse point cloud pointer that shares resources with the composite.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromDensePointCloud()

CVB_BEGIN_INLINE_NS SparsePointCloudPtr FromDensePointCloud ( const DensePointCloud densePointCloud)
inlinestatic

Creates a sparse point cloud from a dense point cloud with confidence plane.

Non-confident points will be removed and the confidence plane is not kept. The new sparse point cloud has the same planes as the dense point cloud (except confidence).

Parameters
[in]densePointCloudDense point cloud create sparse point cloud from.
Returns
Converted sparse point cloud

◆ PlaneCrop() [1/2]

SparsePointCloudPtr PlaneCrop ( const Plane3D plane,
const ValueRange< double > &  range,
CropRange  cropRange 
) const
inline

Creates a new point cloud where points within or outside a range parallel to given plane are cropped.

The plane is defined by the hessian normal form:

Points are cropped within or outside a range parallel to the given plane. The range is defined by range. Note, that Range.Max and Range.Min are applied along normal direction.

In order to define a range around the plane, maximum and minimum range have to be positive and negative respectively.

Parameters
[in]planePoints parallel to this plane will be cropped.
[in]rangePoints within or outside this range will be cropped.
[in]cropRangeIndicates whether points should be cropped within or outside the range.
Returns
Cropped point cloud.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ PlaneCrop() [2/2]

SparsePointCloudPtr PlaneCrop ( const Plane3D plane,
double  threshold,
CropDirection  cropBelowAbove = CropDirection::Below 
) const
inline

Creates a new point cloud which only consists of the points below or above given plane.

The plane is defined by the hessian normal form:

Above plane means all points with z values greater than the plane are cropped. It makes no difference in which direction the given normal points. The normal is always converted, so that it points up (positive z value). Note, if Normal.Z equals 0, "below" and "above" is undefined and thus no cropping is done. Instead the input point cloud will be duplicated.

Parameters
[in]planePoints beyond this plane will be cropped.
[in]thresholdPoints below plane plus this value and points above plane minus this value are cropped respectively. This threshold should be set, if plane is calculated via FitPlane(). It ensures, that all points of plane plus noise are cropped. Therefore the threshold is added or substracted depending on whether it should be cropped above or below.
[in]cropBelowAboveIndicates if points should either be cropped below or above plane.
Returns
Cropped point cloud.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ PointComponents()

SparseComponentsPointers3D< T > PointComponents ( ) const
inline

Get the point components from the given point cloud.

Returns
A typed struct with pointers to the cloud's components.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ ToDensePointCloud() [1/2]

DensePointCloudPtr ToDensePointCloud ( ConversionMode  conversionMode = ConversionMode::Automatic) const
inline

Creates a dense point cloud from a sparse point cloud.

This function maps the points of a sparse point cloud into a newly created dense point cloud. First, a resolution is determined that minimizes the points lost by the conversion.

If multiple points map onto the same x,y position in the dense cloud, the one with the larger z value is retained. The output cloud always has a confidence plane, which is set to 0 if no point of the sparse cloud matched the location. It is set to 1 if a point of the sparse cloud could be mapped to that location.

If the sparse cloud has a w component, it is replicated as well.

Parameters
[in]conversionModeMode used in conversion to dense pointcloud. Currently Automatic is the only option.
Returns
Converted dense point cloud.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ ToDensePointCloud() [2/2]

DensePointCloudPtr ToDensePointCloud ( size_t &  numDroppedPoints,
ConversionMode  conversionMode = ConversionMode::Automatic 
) const
inline

Creates a dense point cloud from a sparse point cloud.

This function maps the points of a sparse point cloud into a newly created dense point cloud. First, a resolution is determined that minimizes the points lost by the conversion.

If multiple points map onto the same x,y position in the dense cloud, the one with the larger z value is retained. The output cloud always has a confidence plane, which is set to 0 if no point of the sparse cloud matched the location. It is set to 1 if a point of the sparse cloud could be mapped to that location.

If the sparse cloud has a w component, it is replicated as well.

Parameters
[out]numDroppedPointsThe number of source points that overlapped in x and y and thus got dropped.
[in]conversionModeMode used in conversion to dense point cloud. Currently Automatic is the only option.
Returns
Converted dense point cloud.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ TryPointComponents()

bool TryPointComponents ( SparseComponentsPointers3D< T > &  components) const
inlinenoexcept

Tries to get the point components from the given point cloud.

This method does not throw if the point type does not match the point cloud type.

Parameters
[out]componentsThe components pointers.
Returns
True if type matches the point cloud point type, false otherwise.
Exceptions
Doesnot throw any exception.