Image Component Library (ICL)
|
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 Mat3 & | getAInv () const |
returns the internally stored inverse source transform matrix More... | |
const Mat3 & | getB () const |
returns the internally stored inverse destination transform matrix More... | |
const Mat3 & | getC () const |
returns the internally stored combined transform matrix More... | |
std::vector< utils::Point32f > | getSrcQuad () const |
returns a copy of the internally held source quadrangle More... | |
std::vector< utils::Point32f > | getDstQuad () 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::Point32f > | map (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... | |
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
icl::math::Projective4PointTransform::Projective4PointTransform | ( | ) |
creates an empty ID-transform
icl::math::Projective4PointTransform::Projective4PointTransform | ( | const utils::Point32f | srcQuad[4], |
const utils::Point32f | dstQuad[4] | ||
) |
creates a Projective4PointTransform instance with given src and dst quadrangle
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)
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
|
inline |
returns the internally stored inverse source transform matrix
|
inline |
returns the internally stored inverse destination transform matrix
|
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)
std::vector<utils::Point32f> icl::math::Projective4PointTransform::getDstQuad | ( | ) | const |
returns a copy of the internally held destiation quadrangle
std::vector<utils::Point32f> icl::math::Projective4PointTransform::getSrcQuad | ( | ) | const |
returns a copy of the internally held source quadrangle
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.
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
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)
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
|
inline |
maps points in an iterator based fashion
|
inline |
maps a single point from the source quadrangle into the destination quadrangle
void icl::math::Projective4PointTransform::setDstQuad | ( | const utils::Point32f | dstQuad[4] | ) |
updates the destination quad (the other transforms are automatically updated)
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)
void icl::math::Projective4PointTransform::setSrcQuad | ( | const utils::Point32f | srcQuad[4] | ) |
updates the source quad (the other transforms are automatically updated)
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)
|
private |
internally held inverse source transform
|
private |
internally held destination transform
|
private |
internally held result-transform C = B * A_inv
|
private |
source and destination quadrangles
|
private |