Point Cloud Library (PCL) 1.15.1
Loading...
Searching...
No Matches
pcl::PCA< PointT > Class Template Reference

Principal Component analysis (PCA) class. More...

#include <pcl/common/pca.h>

Inheritance diagram for pcl::PCA< PointT >:

Public Types

enum  FLAG { increase , preserve }
 Updating method flag. More...
using Base = pcl::PCLBase<PointT>
using PointCloud = typename Base::PointCloud
using PointCloudPtr = typename Base::PointCloudPtr
using PointCloudConstPtr = typename Base::PointCloudConstPtr
using PointIndicesPtr = typename Base::PointIndicesPtr
using PointIndicesConstPtr = typename Base::PointIndicesConstPtr
Public Types inherited from pcl::PCLBase< PointT >
using PointCloud = pcl::PointCloud<PointT>
using PointCloudPtr = typename PointCloud::Ptr
using PointCloudConstPtr = typename PointCloud::ConstPtr
using PointIndicesPtr = PointIndices::Ptr
using PointIndicesConstPtr = PointIndices::ConstPtr

Public Member Functions

 PCA (bool basis_only=false)
 Default Constructor.
 PCA (PCA const &pca)
 Copy Constructor.
PCAoperator= (PCA const &pca)
 Assignment operator.
void setInputCloud (const PointCloudConstPtr &cloud) override
 Provide a pointer to the input dataset.
void setIndices (const IndicesPtr &indices) override
 Provide a pointer to the vector of indices that represents the input data.
void setIndices (const IndicesConstPtr &indices) override
 Provide a pointer to the vector of indices that represents the input data.
void setIndices (const PointIndicesConstPtr &indices) override
 Provide a pointer to the vector of indices that represents the input data.
void setIndices (std::size_t row_start, std::size_t col_start, std::size_t nb_rows, std::size_t nb_cols) override
 Set the indices for the points laying within an interest region of the point cloud.
Eigen::Vector4f & getMean ()
 Mean accessor.
Eigen::Matrix3f & getEigenVectors ()
 Eigen Vectors accessor.
Eigen::Vector3f & getEigenValues ()
 Eigen Values accessor.
Eigen::MatrixXf & getCoefficients ()
 Coefficients accessor.
void update (const PointT &input, FLAG flag=preserve)
 update PCA with a new point
void project (const PointT &input, PointT &projection)
 Project point on the eigenspace.
void project (const PointCloud &input, PointCloud &projection)
 Project cloud on the eigenspace.
void reconstruct (const PointT &projection, PointT &input)
 Reconstruct point from its projection.
void reconstruct (const PointCloud &projection, PointCloud &input)
 Reconstruct cloud from its projection.
Public Member Functions inherited from pcl::PCLBase< PointT >
 PCLBase ()
 Empty constructor.
 PCLBase (const PCLBase &base)
 Copy constructor.
virtual ~PCLBase ()=default
 Destructor.
PointCloudConstPtr const getInputCloud () const
 Get a pointer to the input point cloud dataset.
IndicesPtr getIndices ()
 Get a pointer to the vector of indices used.
IndicesConstPtr const getIndices () const
 Get a pointer to the vector of indices used.
const PointT & operator[] (std::size_t pos) const
 Override PointCloud operator[] to shorten code.

Public Attributes

PointCloudConstPtr input_
 The input point cloud dataset.
IndicesPtr indices_
 A pointer to the vector of point indices to use.

Additional Inherited Members

Protected Member Functions inherited from pcl::PCLBase< PointT >
bool initCompute ()
 This method should get called before starting the actual computation.
bool deinitCompute ()
 This method should get called after finishing the actual computation.
Protected Attributes inherited from pcl::PCLBase< PointT >
PointCloudConstPtr input_
 The input point cloud dataset.
IndicesPtr indices_
 A pointer to the vector of point indices to use.
bool use_indices_
 Set to true if point indices are used.
bool fake_indices_
 If no set of indices are given, we construct a set of fake indices that mimic the input PointCloud.

Detailed Description

template<typename PointT>
class pcl::PCA< PointT >

Principal Component analysis (PCA) class.


Principal components are extracted by singular values decomposition on the covariance matrix of the centered input cloud. Available data after pca computation are:

  • The Mean of the input data
  • The Eigenvectors: Ordered set of vectors representing the resultant principal components and the eigenspace cartesian basis (right-handed coordinate system).
  • The Eigenvalues: Eigenvectors correspondent loadings ordered in descending order.

    Other methods allow projection in the eigenspace, reconstruction from eigenspace and update of the eigenspace with a new datum (according Matej Artec, Matjaz Jogan and Ales Leonardis: "Incremental PCA for On-line Visual Learning and Recognition").
Author
Nizar Sallem

Definition at line 61 of file pca.h.

Member Typedef Documentation

◆ Base

template<typename PointT>
using pcl::PCA< PointT >::Base = pcl::PCLBase<PointT>

Definition at line 64 of file pca.h.

◆ PointCloud

template<typename PointT>
using pcl::PCA< PointT >::PointCloud = typename Base::PointCloud

Definition at line 65 of file pca.h.

◆ PointCloudConstPtr

template<typename PointT>
using pcl::PCA< PointT >::PointCloudConstPtr = typename Base::PointCloudConstPtr

Definition at line 67 of file pca.h.

◆ PointCloudPtr

template<typename PointT>
using pcl::PCA< PointT >::PointCloudPtr = typename Base::PointCloudPtr

Definition at line 66 of file pca.h.

◆ PointIndicesConstPtr

template<typename PointT>
using pcl::PCA< PointT >::PointIndicesConstPtr = typename Base::PointIndicesConstPtr

Definition at line 69 of file pca.h.

◆ PointIndicesPtr

template<typename PointT>
using pcl::PCA< PointT >::PointIndicesPtr = typename Base::PointIndicesPtr

Definition at line 68 of file pca.h.

Member Enumeration Documentation

◆ FLAG

template<typename PointT>
enum pcl::PCA::FLAG

Updating method flag.

Enumerator
increase 

keep the new basis vectors if possible

preserve 

preserve subspace dimension

Definition at line 77 of file pca.h.

Constructor & Destructor Documentation

◆ PCA() [1/2]

template<typename PointT>
pcl::PCA< PointT >::PCA ( bool basis_only = false)
inline

Default Constructor.

Parameters
basis_onlyflag to compute only the PCA basis

Definition at line 88 of file pca.h.

Referenced by operator=(), and PCA().

◆ PCA() [2/2]

template<typename PointT>
pcl::PCA< PointT >::PCA ( PCA< PointT > const & pca)
inline

Copy Constructor.

Parameters
[in]pcaPCA object

Definition at line 96 of file pca.h.

References PCA().

Member Function Documentation

◆ getCoefficients()

template<typename PointT>
Eigen::MatrixXf & pcl::PCA< PointT >::getCoefficients ( )
inline

Coefficients accessor.

Exceptions
InitFailedException

Definition at line 221 of file pca.h.

References pcl::PCLBase< PointT >::initCompute().

◆ getEigenValues()

template<typename PointT>
Eigen::Vector3f & pcl::PCA< PointT >::getEigenValues ( )
inline

Eigen Values accessor.

Exceptions
InitFailedException

Definition at line 207 of file pca.h.

References pcl::PCLBase< PointT >::initCompute().

◆ getEigenVectors()

template<typename PointT>
Eigen::Matrix3f & pcl::PCA< PointT >::getEigenVectors ( )
inline

Eigen Vectors accessor.

Returns
Column ordered eigenvectors, representing the eigenspace cartesian basis (right-handed coordinate system).
Exceptions
InitFailedException

Definition at line 193 of file pca.h.

References pcl::PCLBase< PointT >::initCompute().

◆ getMean()

template<typename PointT>
Eigen::Vector4f & pcl::PCA< PointT >::getMean ( )
inline

Mean accessor.

Exceptions
InitFailedException

Definition at line 178 of file pca.h.

References pcl::PCLBase< PointT >::initCompute().

◆ operator=()

template<typename PointT>
PCA & pcl::PCA< PointT >::operator= ( PCA< PointT > const & pca)
inline

Assignment operator.

Parameters
[in]pcaPCA object

Definition at line 110 of file pca.h.

References PCA().

◆ project() [1/2]

template<typename PointT>
void pcl::PCA< PointT >::project ( const PointCloud & input,
PointCloud & projection )
inline

Project cloud on the eigenspace.

Parameters
[in]inputcloud from original dataset
[out]projectionthe cloud in eigen vectors space
Exceptions
InitFailedException

Definition at line 179 of file pca.hpp.

References project().

◆ project() [2/2]

template<typename PointT>
void pcl::PCA< PointT >::project ( const PointT & input,
PointT & projection )
inline

Project point on the eigenspace.

Parameters
[in]inputpoint from original dataset
[out]projectionthe point in eigen vectors space
Exceptions
InitFailedException

Definition at line 166 of file pca.hpp.

Referenced by project().

◆ reconstruct() [1/2]

template<typename PointT>
void pcl::PCA< PointT >::reconstruct ( const PointCloud & projection,
PointCloud & input )
inline

Reconstruct cloud from its projection.

Parameters
[in]projectioncloud from eigenvector space
[out]inputreconstructed cloud
Exceptions
InitFailedException

Definition at line 221 of file pca.hpp.

References reconstruct().

◆ reconstruct() [2/2]

template<typename PointT>
void pcl::PCA< PointT >::reconstruct ( const PointT & projection,
PointT & input )
inline

Reconstruct point from its projection.

Parameters
[in]projectionpoint from eigenvector space
[out]inputreconstructed point
Exceptions
InitFailedException

Definition at line 208 of file pca.hpp.

Referenced by reconstruct().

◆ setIndices() [1/4]

template<typename PointT>
void pcl::PCA< PointT >::setIndices ( const IndicesConstPtr & indices)
inlineoverridevirtual

Provide a pointer to the vector of indices that represents the input data.

Parameters
[in]indicesa pointer to the indices that represent the input data.

Reimplemented from pcl::PCLBase< PointT >.

Definition at line 143 of file pca.h.

References pcl::PCLBase< PointT >::setIndices().

◆ setIndices() [2/4]

template<typename PointT>
void pcl::PCA< PointT >::setIndices ( const IndicesPtr & indices)
inlineoverridevirtual

Provide a pointer to the vector of indices that represents the input data.

Parameters
[in]indicesa pointer to the indices that represent the input data.

Reimplemented from pcl::PCLBase< PointT >.

Definition at line 133 of file pca.h.

References pcl::PCLBase< PointT >::setIndices().

◆ setIndices() [3/4]

template<typename PointT>
void pcl::PCA< PointT >::setIndices ( const PointIndicesConstPtr & indices)
inlineoverridevirtual

Provide a pointer to the vector of indices that represents the input data.

Parameters
[in]indicesa pointer to the indices that represent the input data.

Reimplemented from pcl::PCLBase< PointT >.

Definition at line 153 of file pca.h.

References pcl::PCLBase< PointT >::setIndices().

◆ setIndices() [4/4]

template<typename PointT>
void pcl::PCA< PointT >::setIndices ( std::size_t row_start,
std::size_t col_start,
std::size_t nb_rows,
std::size_t nb_cols )
inlineoverridevirtual

Set the indices for the points laying within an interest region of the point cloud.

Note
you shouldn't call this method on unorganized point clouds!
Parameters
[in]row_startthe offset on rows
[in]col_startthe offset on columns
[in]nb_rowsthe number of rows to be considered row_start included
[in]nb_colsthe number of columns to be considered col_start included

Reimplemented from pcl::PCLBase< PointT >.

Definition at line 168 of file pca.h.

References pcl::PCLBase< PointT >::setIndices().

◆ setInputCloud()

template<typename PointT>
void pcl::PCA< PointT >::setInputCloud ( const PointCloudConstPtr & cloud)
inlineoverridevirtual

Provide a pointer to the input dataset.

Parameters
cloudthe const boost shared pointer to a PointCloud message

Reimplemented from pcl::PCLBase< PointT >.

Definition at line 123 of file pca.h.

References pcl::PCLBase< PointT >::setInputCloud().

◆ update()

template<typename PointT>
void pcl::PCA< PointT >::update ( const PointT & input,
FLAG flag = preserve )
inline

update PCA with a new point

Parameters
[in]inputinput point
[in]flagupdate flag
Exceptions
InitFailedException

Definition at line 96 of file pca.hpp.

References increase, and preserve.

Member Data Documentation

◆ indices_

template<typename PointT>
IndicesPtr pcl::PCLBase< PointT >::indices_

A pointer to the vector of point indices to use.

Definition at line 150 of file pcl_base.h.

◆ input_

template<typename PointT>
PointCloudConstPtr pcl::PCLBase< PointT >::input_

The input point cloud dataset.

Definition at line 147 of file pcl_base.h.


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