Point Cloud Library (PCL)  1.10.1-dev
pcl::VectorAverage< real, dimension > Class Template Reference

Calculates the weighted average and the covariance matrix. More...

`#include <pcl/common/vector_average.h>`

## Public Types

using VectorType = Eigen::Matrix< real, dimension, 1 >

using MatrixType = Eigen::Matrix< real, dimension, dimension >

## Public Member Functions

VectorAverage ()
Constructor - dimension gives the size of the vectors to work with. More...

void reset ()
Reset the object to work with a new data set. More...

const VectorTypegetMean () const
Get the mean of the added vectors. More...

const MatrixTypegetCovariance () const
Get the covariance matrix of the added vectors. More...

real getAccumulatedWeight () const
Get the summed up weight of all added vectors. More...

unsigned int getNoOfSamples ()
Get the number of added vectors. More...

void add (const VectorType &sample, real weight=1.0)
Add a new sample. More...

void doPCA (VectorType &eigen_values, VectorType &eigen_vector1, VectorType &eigen_vector2, VectorType &eigen_vector3) const
Do Principal component analysis. More...

void doPCA (VectorType &eigen_values) const
Do Principal component analysis. More...

void getEigenVector1 (VectorType &eigen_vector1) const
Get the eigenvector corresponding to the smallest eigenvalue. More...

template<>
void doPCA (Eigen::Matrix< float, 3, 1 > &eigen_values, Eigen::Matrix< float, 3, 1 > &eigen_vector1, Eigen::Matrix< float, 3, 1 > &eigen_vector2, Eigen::Matrix< float, 3, 1 > &eigen_vector3) const

template<>
void doPCA (Eigen::Matrix< float, 3, 1 > &eigen_values) const

template<>
void getEigenVector1 (Eigen::Matrix< float, 3, 1 > &eigen_vector1) const

template<>
void doPCA (Eigen::Matrix< double, 3, 1 > &eigen_values, Eigen::Matrix< double, 3, 1 > &eigen_vector1, Eigen::Matrix< double, 3, 1 > &eigen_vector2, Eigen::Matrix< double, 3, 1 > &eigen_vector3) const

template<>
void doPCA (Eigen::Matrix< double, 3, 1 > &eigen_values) const

template<>
void getEigenVector1 (Eigen::Matrix< double, 3, 1 > &eigen_vector1) const

## Protected Attributes

unsigned int noOfSamples_ = 0

real accumulatedWeight_ = 0

VectorType mean_ = VectorType::Identity ()

MatrixType covariance_ = MatrixType::Identity ()

## Detailed Description

### template<typename real, int dimension> class pcl::VectorAverage< real, dimension >

Calculates the weighted average and the covariance matrix.

A class to calculate the weighted average and the covariance matrix of a set of vectors with given weights. The original data is not saved. Mean and covariance are calculated iteratively.

Definition at line 54 of file vector_average.h.

## ◆ MatrixType

template<typename real , int dimension>
 using pcl::VectorAverage< real, dimension >::MatrixType = Eigen::Matrix

Definition at line 58 of file vector_average.h.

## ◆ VectorType

template<typename real , int dimension>
 using pcl::VectorAverage< real, dimension >::VectorType = Eigen::Matrix

Definition at line 57 of file vector_average.h.

## ◆ VectorAverage()

template<typename real , int dimension>
 pcl::VectorAverage< real, dimension >::VectorAverage ( )

Constructor - dimension gives the size of the vectors to work with.

Definition at line 44 of file vector_average.hpp.

## Member Function Documentation

template<typename real , int dimension>
 void pcl::VectorAverage< real, dimension >::add ( const VectorType & sample, real weight = `1.0` )
inline

## ◆ doPCA() [1/6]

template<typename real , int dimension>
 void pcl::VectorAverage< real, dimension >::doPCA ( VectorType & eigen_values, VectorType & eigen_vector1, VectorType & eigen_vector2, VectorType & eigen_vector3 ) const
inline

Do Principal component analysis.

Definition at line 80 of file vector_average.hpp.

## ◆ doPCA() [2/6]

template<typename real , int dimension>
 void pcl::VectorAverage< real, dimension >::doPCA ( VectorType & eigen_values ) const
inline

Do Principal component analysis.

Definition at line 104 of file vector_average.hpp.

## ◆ doPCA() [3/6]

template<>
 void pcl::VectorAverage< float, 3 >::doPCA ( Eigen::Matrix< float, 3, 1 > & eigen_values, Eigen::Matrix< float, 3, 1 > & eigen_vector1, Eigen::Matrix< float, 3, 1 > & eigen_vector2, Eigen::Matrix< float, 3, 1 > & eigen_vector3 ) const
inline

Definition at line 143 of file vector_average.hpp.

References pcl::eigen33().

## ◆ doPCA() [4/6]

template<>
 void pcl::VectorAverage< float, 3 >::doPCA ( Eigen::Matrix< float, 3, 1 > & eigen_values ) const
inline

Definition at line 154 of file vector_average.hpp.

References pcl::computeRoots().

## ◆ doPCA() [5/6]

template<>
 void pcl::VectorAverage< double, 3 >::doPCA ( Eigen::Matrix< double, 3, 1 > & eigen_values, Eigen::Matrix< double, 3, 1 > & eigen_vector1, Eigen::Matrix< double, 3, 1 > & eigen_vector2, Eigen::Matrix< double, 3, 1 > & eigen_vector3 ) const
inline

Definition at line 173 of file vector_average.hpp.

References pcl::eigen33().

## ◆ doPCA() [6/6]

template<>
 void pcl::VectorAverage< double, 3 >::doPCA ( Eigen::Matrix< double, 3, 1 > & eigen_values ) const
inline

Definition at line 184 of file vector_average.hpp.

References pcl::computeRoots().

## ◆ getAccumulatedWeight()

template<typename real , int dimension>
 real pcl::VectorAverage< real, dimension >::getAccumulatedWeight ( ) const
inline

Get the summed up weight of all added vectors.

Definition at line 78 of file vector_average.h.

## ◆ getCovariance()

template<typename real , int dimension>
 const MatrixType& pcl::VectorAverage< real, dimension >::getCovariance ( ) const
inline

Get the covariance matrix of the added vectors.

Definition at line 74 of file vector_average.h.

## ◆ getEigenVector1() [1/3]

template<typename real , int dimension>
 void pcl::VectorAverage< real, dimension >::getEigenVector1 ( VectorType & eigen_vector1 ) const
inline

Get the eigenvector corresponding to the smallest eigenvalue.

Definition at line 117 of file vector_average.hpp.

## ◆ getEigenVector1() [2/3]

template<>
 void pcl::VectorAverage< float, 3 >::getEigenVector1 ( Eigen::Matrix< float, 3, 1 > & eigen_vector1 ) const
inline

Definition at line 160 of file vector_average.hpp.

References pcl::eigen33().

## ◆ getEigenVector1() [3/3]

template<>
 void pcl::VectorAverage< double, 3 >::getEigenVector1 ( Eigen::Matrix< double, 3, 1 > & eigen_vector1 ) const
inline

Definition at line 190 of file vector_average.hpp.

References pcl::eigen33().

## ◆ getMean()

template<typename real , int dimension>
 const VectorType& pcl::VectorAverage< real, dimension >::getMean ( ) const
inline

Get the mean of the added vectors.

Definition at line 70 of file vector_average.h.

References pcl::VectorAverage< real, dimension >::mean_.

## ◆ getNoOfSamples()

template<typename real , int dimension>
 unsigned int pcl::VectorAverage< real, dimension >::getNoOfSamples ( )
inline

Get the number of added vectors.

Definition at line 82 of file vector_average.h.

## ◆ reset()

template<typename real , int dimension>
 void pcl::VectorAverage< real, dimension >::reset ( )
inline

Reset the object to work with a new data set.

Definition at line 50 of file vector_average.hpp.

## ◆ accumulatedWeight_

template<typename real , int dimension>
 real pcl::VectorAverage< real, dimension >::accumulatedWeight_ = 0
protected

Definition at line 110 of file vector_average.h.

## ◆ covariance_

template<typename real , int dimension>
 MatrixType pcl::VectorAverage< real, dimension >::covariance_ = MatrixType::Identity ()
protected

## ◆ mean_

template<typename real , int dimension>
 VectorType pcl::VectorAverage< real, dimension >::mean_ = VectorType::Identity ()
protected

Definition at line 111 of file vector_average.h.

Referenced by pcl::VectorAverage< real, dimension >::getMean().

## ◆ noOfSamples_

template<typename real , int dimension>
 unsigned int pcl::VectorAverage< real, dimension >::noOfSamples_ = 0
protected

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