Image Component Library (ICL)
Public Member Functions | Private Attributes | List of all members
icl::math::Projective4PointTransform Class Reference

Utility class that provides functions to perspectively map 4 points of a source frame into 4 points of a destination frame. More...

#include <Projective4PointTransform.h>

Public Member Functions

 Projective4PointTransform ()
 creates an empty ID-transform More...
 
 Projective4PointTransform (const utils::Point32f srcQuad[4], const utils::Point32f dstQuad[4])
 creates a Projective4PointTransform instance with given src and dst quadrangle More...
 
 Projective4PointTransform (const std::vector< utils::Point32f > &srcQuad, const std::vector< utils::Point32f > dstQuad)
 creates a Projective4PointTransform instance with given src and dst quadrangle (vector version) More...
 
 Projective4PointTransform (const Mat3 &C)
 creates a Projective4PointTransform instance directly from a given 3by3 projective transform More...
 
void init (const utils::Point32f srcQuad[4], const utils::Point32f dstQuad[4])
 intializes the Projective4PointTransform from given source and destination quadrangle More...
 
void init (const utils::Rect32f &srcRect, const utils::Rect32f &dstRect=utils::Rect32f::null)
 intializes the Projective4PointTransform from given source and destination rectangles More...
 
void init (const utils::Rect &srcRect, const utils::Rect &dstRect=utils::Rect::null)
 intializes the Projective4PointTransform from given source and destination rectangles (int-version) More...
 
const Mat3getAInv () const
 returns the internally stored inverse source transform matrix More...
 
const Mat3getB () const
 returns the internally stored inverse destination transform matrix More...
 
const Mat3getC () const
 returns the internally stored combined transform matrix More...
 
std::vector< utils::Point32fgetSrcQuad () const
 returns a copy of the internally held source quadrangle More...
 
std::vector< utils::Point32fgetDstQuad () const
 returns a copy of the internally held destiation quadrangle More...
 
utils::Point32f mapPoint (const utils::Point32f &p) const
 maps a single point from the source quadrangle into the destination quadrangle More...
 
void setSrcQuad (const utils::Point32f srcQuad[4])
 updates the source quad (the other transforms are automatically updated) More...
 
void setDstQuad (const utils::Point32f dstQuad[4])
 updates the destination quad (the other transforms are automatically updated) More...
 
void setSrcQuad (const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c, const utils::Point32f &d)
 updates the source quad (the other transforms are automatically updated, point-version) More...
 
void setDstQuad (const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c, const utils::Point32f &d)
 updates the destination quad (the other transforms are automatically updated, point-version) More...
 
std::vector< utils::Point32fmap (const std::vector< utils::Point32f > &src)
 maps a whole set of points at once More...
 
template<class SrcForwardIterator , class DstForwardIterator >
void map (SrcForwardIterator begin, SrcForwardIterator end, DstForwardIterator dst)
 maps points in an iterator based fashion More...
 

Private Attributes

Mat3 m_Ainv
 internally held inverse source transform More...
 
Mat3 m_B
 internally held destination transform More...
 
Mat3 m_C
 internally held result-transform C = B * A_inv More...
 
utils::Point32f m_srcQuad [4]
 
utils::Point32f m_dstQuad [4]
 source and destination quadrangles More...
 

Detailed Description

Utility class that provides functions to perspectively map 4 points of a source frame into 4 points of a destination frame.

In contrast to a standard bilinear interpolation, a 4-point projective transform also implements perspective vanishing point effencts. The algorithm was explained well in

http://math.stackexchange.com/questions/296794/finding-the-transform-matrix-from-4-projected-points-with-javascript

Constructor & Destructor Documentation

◆ Projective4PointTransform() [1/4]

icl::math::Projective4PointTransform::Projective4PointTransform ( )

creates an empty ID-transform

◆ Projective4PointTransform() [2/4]

icl::math::Projective4PointTransform::Projective4PointTransform ( const utils::Point32f  srcQuad[4],
const utils::Point32f  dstQuad[4] 
)

creates a Projective4PointTransform instance with given src and dst quadrangle

◆ Projective4PointTransform() [3/4]

icl::math::Projective4PointTransform::Projective4PointTransform ( const std::vector< utils::Point32f > &  srcQuad,
const std::vector< utils::Point32f dstQuad 
)

creates a Projective4PointTransform instance with given src and dst quadrangle (vector version)

◆ Projective4PointTransform() [4/4]

icl::math::Projective4PointTransform::Projective4PointTransform ( const Mat3 C)

creates a Projective4PointTransform instance directly from a given 3by3 projective transform

In this case the intenally held source and destination quadrangles as well as the matrices Ainv and B will not be initialized

Member Function Documentation

◆ getAInv()

const Mat3& icl::math::Projective4PointTransform::getAInv ( ) const
inline

returns the internally stored inverse source transform matrix

◆ getB()

const Mat3& icl::math::Projective4PointTransform::getB ( ) const
inline

returns the internally stored inverse destination transform matrix

◆ getC()

const Mat3& icl::math::Projective4PointTransform::getC ( ) const
inline

returns the internally stored combined transform matrix

The actual point mapping of a point p = (x,y) is performed by homogenize( C * (x,y,1) ), where homogenize(x,y,k) = (x/k,y/k)

◆ getDstQuad()

std::vector<utils::Point32f> icl::math::Projective4PointTransform::getDstQuad ( ) const

returns a copy of the internally held destiation quadrangle

◆ getSrcQuad()

std::vector<utils::Point32f> icl::math::Projective4PointTransform::getSrcQuad ( ) const

returns a copy of the internally held source quadrangle

◆ init() [1/3]

void icl::math::Projective4PointTransform::init ( const utils::Point32f  srcQuad[4],
const utils::Point32f  dstQuad[4] 
)

intializes the Projective4PointTransform from given source and destination quadrangle

if either sourceQuad or destinationQuad is null, the internally held-quadrangles will be used instead. This allows this function to be used for updating the source or the destination quadrangle separately, if needed.

◆ init() [2/3]

void icl::math::Projective4PointTransform::init ( const utils::Rect32f srcRect,
const utils::Rect32f dstRect = utils::Rect32f::null 
)

intializes the Projective4PointTransform from given source and destination rectangles

For simplicity, also rectangular source and destination quadrangles can be used The default/null arguments Rect32f::null (for either srcRect or dstRect) are internally replaced with the current rectangles. By these means also srcRect or dstRect can also be updated separetely

◆ init() [3/3]

void icl::math::Projective4PointTransform::init ( const utils::Rect srcRect,
const utils::Rect dstRect = utils::Rect::null 
)

intializes the Projective4PointTransform from given source and destination rectangles (int-version)

See also
Projective4PointTransform::init(const utils::Rect32f &, const utils::Rect32f &)

◆ map() [1/2]

std::vector<utils::Point32f> icl::math::Projective4PointTransform::map ( const std::vector< utils::Point32f > &  src)

maps a whole set of points at once

Please note that this is not more efficient then mapping all manually in a loop

◆ map() [2/2]

template<class SrcForwardIterator , class DstForwardIterator >
void icl::math::Projective4PointTransform::map ( SrcForwardIterator  begin,
SrcForwardIterator  end,
DstForwardIterator  dst 
)
inline

maps points in an iterator based fashion

◆ mapPoint()

utils::Point32f icl::math::Projective4PointTransform::mapPoint ( const utils::Point32f p) const
inline

maps a single point from the source quadrangle into the destination quadrangle

◆ setDstQuad() [1/2]

void icl::math::Projective4PointTransform::setDstQuad ( const utils::Point32f  dstQuad[4])

updates the destination quad (the other transforms are automatically updated)

◆ setDstQuad() [2/2]

void icl::math::Projective4PointTransform::setDstQuad ( const utils::Point32f a,
const utils::Point32f b,
const utils::Point32f c,
const utils::Point32f d 
)

updates the destination quad (the other transforms are automatically updated, point-version)

◆ setSrcQuad() [1/2]

void icl::math::Projective4PointTransform::setSrcQuad ( const utils::Point32f  srcQuad[4])

updates the source quad (the other transforms are automatically updated)

◆ setSrcQuad() [2/2]

void icl::math::Projective4PointTransform::setSrcQuad ( const utils::Point32f a,
const utils::Point32f b,
const utils::Point32f c,
const utils::Point32f d 
)

updates the source quad (the other transforms are automatically updated, point-version)

Member Data Documentation

◆ m_Ainv

Mat3 icl::math::Projective4PointTransform::m_Ainv
private

internally held inverse source transform

◆ m_B

Mat3 icl::math::Projective4PointTransform::m_B
private

internally held destination transform

◆ m_C

Mat3 icl::math::Projective4PointTransform::m_C
private

internally held result-transform C = B * A_inv

◆ m_dstQuad

utils::Point32f icl::math::Projective4PointTransform::m_dstQuad[4]
private

source and destination quadrangles

◆ m_srcQuad

utils::Point32f icl::math::Projective4PointTransform::m_srcQuad[4]
private

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