Templates -- Meow  1.1.4
A C++ template which is unable and also not allowed to compile to obj-file first.
meow::PhotoProjection< Scalar > Class Template Reference

A photo projection is a kind of transformation that project point/vector to a flat photo. More...

#include "Transformations.h"

Inheritance diagram for meow::PhotoProjection< Scalar >:
meow::Transformation< Scalar >

Public Member Functions

 PhotoProjection (size_t dimension)
 
 PhotoProjection (size_t dimension, Scalar const &f)
 
 PhotoProjection (PhotoProjection const &p)
 
PhotoProjectioncopyFrom (PhotoProjection const &b)
 
PhotoProjectionreferenceFrom (PhotoProjection const &b)
 
Scalar parameter (size_t i) const
 Same as focal() More...
 
Scalar parameter (size_t i, Scalar const &s)
 Same as focal(s) More...
 
Scalar focal () const
 Get the focal length. More...
 
Scalar focal (Scalar const &f)
 Set the focal length. More...
 
size_t dimension () const
 Get the dimension of this projection. More...
 
Matrix< Scalar > transformate (Matrix< Scalar > const &x) const
 Project the input vector(s) onto the plane. More...
 
Matrix< Scalar > jacobian (Matrix< Scalar > const &x) const
 Return the jacobian matrix (derivate by the input vector) of this projection. More...
 
Matrix< Scalar > jacobian (Matrix< Scalar > const &x, size_t i) const
 Return the jacobian matrix (derivate by the focus length) of this projection. More...
 
PhotoProjectionoperator= (PhotoProjection const &b)
 Same as copyFrom(b) More...
 
Matrix< Scalar > operator() (Matrix< Scalar > const &v) const
 Same as transformate(v) More...
 
- Public Member Functions inherited from meow::Transformation< Scalar >
virtual ~Transformation ()
 
size_t inputRows () const
 Return the number of rows of the input matrix. More...
 
size_t inputCols () const
 Return the number of columns of the input matrix. More...
 
size_t outputRows () const
 Return the number of rows of the output matrix. More...
 
size_t outputCols () const
 Return the number of columns of the output matrix. More...
 
size_t parameterSize () const
 Return the number of parameters. More...
 
virtual bool inversable () const
 Return whether this transformation is inversable or not. More...
 
virtual Matrix< Scalar > transformateInv (Matrix< Scalar > const &x) const
 Do the inverse transformation. More...
 
virtual Matrix< Scalar > jacobianInv (Matrix< Scalar > const &x) const
 Return the jacobian matrix of the inverse transformation. More...
 
virtual Matrix< Scalar > jacobianInv (Matrix< Scalar > const &x, size_t i) const
 Return the jacobian matrix of the inverse transformation. More...
 

Additional Inherited Members

- Protected Member Functions inherited from meow::Transformation< Scalar >
 Transformation (size_t inputRows, size_t inputCols, size_t outputRows, size_t outputCols, size_t psize)
 
 Transformation (Transformation const &b)
 
TransformationcopyFrom (Transformation const &b)
 Copy from the specified one. More...
 
TransformationreferenceFrom (Transformation const &b)
 reference from the specified one More...
 

Detailed Description

template<class Scalar>
class meow::PhotoProjection< Scalar >

A photo projection is a kind of transformation that project point/vector to a flat photo.

Assume:

  • The dimension of a photo projection is $ N $
  • The length of the input vector is $ L $
  • The focal length is $ f $

Then transformation is like below:

\[ \left[ \begin{array}{c} x_1 \\ x_2 \\ x_3 \\ . \\ . \\ . \\ x_N \\ \end{array} \right] \stackrel{transformate}{\rightarrow} \left[ \begin{array}{c} \frac{-x_1 \times f}{x_N} \\ \frac{-x_2 \times f}{x_N} \\ \frac{-x_3 \times f}{x_N} \\ . \\ . \\ . \\ -f \\ \end{array} \right] \\ \]

i.e. projecte the vector onto the plane $ x_N = -f $.

Author
cat_leopard

Definition at line 323 of file Transformations.h.

Constructor & Destructor Documentation

template<class Scalar>
meow::PhotoProjection< Scalar >::PhotoProjection ( size_t  dimension)
inline

Constructor, focal = 1

Definition at line 347 of file Transformations.h.

template<class Scalar>
meow::PhotoProjection< Scalar >::PhotoProjection ( size_t  dimension,
Scalar const &  f 
)
inline

Constructor

Definition at line 355 of file Transformations.h.

template<class Scalar>
meow::PhotoProjection< Scalar >::PhotoProjection ( PhotoProjection< Scalar > const &  p)
inline

Constructor, copy settings from another PhotoProjection.

Definition at line 363 of file Transformations.h.

Member Function Documentation

template<class Scalar>
PhotoProjection& meow::PhotoProjection< Scalar >::copyFrom ( PhotoProjection< Scalar > const &  b)
inline

Copy settings from another one

Parameters
[in]banother one
Returns
*this

Definition at line 372 of file Transformations.h.

template<class Scalar>
size_t meow::PhotoProjection< Scalar >::dimension ( ) const
inline

Get the dimension of this projection.

Definition at line 425 of file Transformations.h.

template<class Scalar>
Scalar meow::PhotoProjection< Scalar >::focal ( ) const
inline

Get the focal length.

Returns
Focal length

Definition at line 407 of file Transformations.h.

template<class Scalar>
Scalar meow::PhotoProjection< Scalar >::focal ( Scalar const &  f)
inline

Set the focal length.

Parameters
[in]fNew focal length
Returns
New focal length

Definition at line 417 of file Transformations.h.

template<class Scalar>
Matrix<Scalar> meow::PhotoProjection< Scalar >::jacobian ( Matrix< Scalar > const &  x) const
inlinevirtual

Return the jacobian matrix (derivate by the input vector) of this projection.

This method only allow a vector-like matrix be input. Assume:

  • The dimension of this projection is $ N $
  • The length of the input vector is $ L=\sqrt{x_1^2+x_2^2+...+x_N^2} $
  • The focal length of this projection is $ f $

Then the jacobian matrix is like below:

\[ f \times \left[ \begin{array}{ccccc} \frac{-1}{x_N} & 0 & 0 & ... & \frac{1}{x_N^2} \\ 0 & \frac{-1}{x_N} & 0 & ... & \frac{1}{x_N^2} \\ 0 & 0 & \frac{-1}{x_N} & ... & \frac{1}{x_N^2} \\ . & . & . & & . \\ . & . & . & & . \\ . & . & . & & . \\ 0 & 0 & 0 & ... & 0 \\ \end{array} \right] \]

Parameters
[in]xThe input matrix.
Returns
The output matrix.

Reimplemented from meow::Transformation< Scalar >.

Definition at line 485 of file Transformations.h.

template<class Scalar>
Matrix<Scalar> meow::PhotoProjection< Scalar >::jacobian ( Matrix< Scalar > const &  x,
size_t  i 
) const
inlinevirtual

Return the jacobian matrix (derivate by the focus length) of this projection.

This method only allow a vector-like matrix be input. Assume:

  • The dimension of this projection is $ N $
  • The length of the input vector is $ L=\sqrt{x_1^2+x_2^2+...+x_N^2} $
  • The focal length of this projection is $ f $

Then the jacobian matrix is like below:

\[ \left[ \begin{array}{c} \frac{-x_1}{x_N} \\ \frac{-x_2}{x_N} \\ \frac{-x_3}{x_N} \\ . \\ . \\ . \\ -1 \\ \end{array} \right] \]

Parameters
[in]xThe input matrix.
[in]iUseless parameter
Returns
The output matrix.

Reimplemented from meow::Transformation< Scalar >.

Definition at line 523 of file Transformations.h.

template<class Scalar>
Matrix<Scalar> meow::PhotoProjection< Scalar >::operator() ( Matrix< Scalar > const &  v) const
inline

Same as transformate(v)

Definition at line 541 of file Transformations.h.

template<class Scalar>
PhotoProjection& meow::PhotoProjection< Scalar >::operator= ( PhotoProjection< Scalar > const &  b)
inline

Same as copyFrom(b)

Definition at line 534 of file Transformations.h.

template<class Scalar>
Scalar meow::PhotoProjection< Scalar >::parameter ( size_t  i) const
inlinevirtual

Same as focal()

Implements meow::Transformation< Scalar >.

Definition at line 392 of file Transformations.h.

template<class Scalar>
Scalar meow::PhotoProjection< Scalar >::parameter ( size_t  i,
Scalar const &  s 
)
inlinevirtual

Same as focal(s)

Implements meow::Transformation< Scalar >.

Definition at line 399 of file Transformations.h.

template<class Scalar>
PhotoProjection& meow::PhotoProjection< Scalar >::referenceFrom ( PhotoProjection< Scalar > const &  b)
inline

Reference settings from another one

Parameters
[in]banother one
Returns
*this

Definition at line 383 of file Transformations.h.

template<class Scalar>
Matrix<Scalar> meow::PhotoProjection< Scalar >::transformate ( Matrix< Scalar > const &  x) const
inlinevirtual

Project the input vector(s) onto the plane.

The equation of the plane is $ x_N = -f $, where the $ N $ is the dimension of this projection and f is the focal length.
If the number of columns of the input matrix is larger than 1, this method will think that you want to transform multiple vector once and the number of columns of the output matrix will be the same of the number of columns of the input one.

Parameters
[in]xThe input matrix.
Returns
The output matrix.
Note
Take into account that too much safty checking will lead to inefficient, this method will not checking whether the dimension of the input vector/matrix is right. So be sure the data is valid before you call this method.

Implements meow::Transformation< Scalar >.

Definition at line 446 of file Transformations.h.


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