27 #include "../common/MatrixUtils.h"
34 #include <boost/numeric/ublas/matrix.hpp>
46 static std::string name(
"Projective" );
57 const double& pt1Y,
double& pt2X,
double& pt2Y )
const
59 assert( isValid( params ) );
87 const double& pt2Y,
double& pt1X,
double& pt1Y )
const
89 assert( isValid( params ) );
148 const unsigned int tiepointsSize = params.
m_tiePoints.size();
149 if( tiepointsSize < getMinRequiredTiePoints() )
return false;
152 boost::numeric::ublas::matrix< double > L_DM( 2*tiepointsSize, 1 );
153 boost::numeric::ublas::matrix< double > A_DM( 2*tiepointsSize, 8 );
156 boost::numeric::ublas::matrix< double > L_IM( 2*tiepointsSize, 1 );
157 boost::numeric::ublas::matrix< double > A_IM( 2*tiepointsSize, 8 );
159 unsigned int index1 = 0;
160 unsigned int index2 = 0;
162 for (
unsigned int blockOffset = 0 ; (blockOffset < tiepointsSize) ;
165 index1 = blockOffset*2;
171 L_DM( index1, 0) = u_v.
x;
172 L_DM( index2, 0) = u_v.
y;
174 A_DM( index1, 0 ) = x_y.
x ;
175 A_DM( index1, 1 ) = x_y.
y ;
176 A_DM( index1, 2 ) = 1 ;
177 A_DM( index1, 3 ) = 0 ;
178 A_DM( index1, 4 ) = 0 ;
179 A_DM( index1, 5 ) = 0 ;
180 A_DM( index1, 6 ) = - x_y.
x * u_v.
x;
181 A_DM( index1, 7 ) = - x_y.
y * u_v.
x;
183 A_DM( index2, 0 ) = 0;
184 A_DM( index2, 1 ) = 0;
185 A_DM( index2, 2 ) = 0;
186 A_DM( index2, 3 ) = x_y.
x ;
187 A_DM( index2, 4 ) = x_y.
y ;
188 A_DM( index2, 5 ) = 1 ;
189 A_DM( index2, 6 ) = - x_y.
x * u_v.
y;
190 A_DM( index2, 7 ) = - x_y.
y * u_v.
y;
192 L_IM( index1, 0) = x_y.
x;
193 L_IM( index2, 0) = x_y.
y;
195 A_IM( index1, 0 ) = u_v.
x ;
196 A_IM( index1, 1 ) = u_v.
y ;
197 A_IM( index1, 2 ) = 1 ;
198 A_IM( index1, 3 ) = 0 ;
199 A_IM( index1, 4 ) = 0 ;
200 A_IM( index1, 5 ) = 0 ;
201 A_IM( index1, 6 ) = - u_v.
x * x_y.
x;
202 A_IM( index1, 7 ) = - u_v.
y * x_y.
x;
204 A_IM( index2, 0 ) = 0;
205 A_IM( index2, 1 ) = 0;
206 A_IM( index2, 2 ) = 0;
207 A_IM( index2, 3 ) = u_v.
x ;
208 A_IM( index2, 4 ) = u_v.
y ;
209 A_IM( index2, 5 ) = 1 ;
210 A_IM( index2, 6 ) = - u_v.
x * x_y.
y;
211 A_IM( index2, 7 ) = - u_v.
y * x_y.
y;
215 boost::numeric::ublas::matrix< double > A_DM_t( boost::numeric::ublas::trans( A_DM ) ) ;
216 boost::numeric::ublas::matrix< double > A_IM_t( boost::numeric::ublas::trans( A_IM ) ) ;
219 boost::numeric::ublas::matrix< double > N_DM( boost::numeric::ublas::prod( A_DM_t, A_DM ) );
220 boost::numeric::ublas::matrix< double > N_IM( boost::numeric::ublas::prod( A_IM_t, A_IM ) );
223 boost::numeric::ublas::matrix< double > U_DM( boost::numeric::ublas::prod( A_DM_t, L_DM ) );
224 boost::numeric::ublas::matrix< double > U_IM( boost::numeric::ublas::prod( A_IM_t, L_IM ) );
227 boost::numeric::ublas::matrix< double > N_DM_inv;
228 boost::numeric::ublas::matrix< double > N_IM_inv;
232 boost::numeric::ublas::matrix< double > X_DM(
233 boost::numeric::ublas::prod( N_DM_inv, U_DM ) );
247 boost::numeric::ublas::matrix< double > X_IM(
248 boost::numeric::ublas::prod( N_IM_inv, U_IM ) );
ProjectiveGT()
Default constructor.
std::vector< TiePoint > m_tiePoints
Tie points.
void directMap(const GTParameters ¶ms, const double &pt1X, const double &pt1Y, double &pt2X, double &pt2Y) const
Direct mapping (from pt1 space into pt2 space).
std::vector< double > m_directParameters
Transformation numeric direct parameters.
An utility struct for representing 2D coordinates.
2D Projective Geometric transformation.
const std::string & getName() const
Returns the current transformation name.
void inverseMap(const GTParameters ¶ms, const double &pt2X, const double &pt2Y, double &pt1X, double &pt1Y) const
Inverse mapping (from pt2 space into pt1 space).
GeometricTransformation * clone() const
Creat a clone copy of this instance.
2D Projective Geometric transformation.
bool computeParameters(GTParameters ¶ms) const
Calculate the transformation parameters following the new supplied tie-points.
bool GetInverseMatrix(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
Matrix inversion.
std::vector< double > m_inverseParameters
Transformation numeric inverse parameters.
2D Geometric transformation parameters.
unsigned int getMinRequiredTiePoints() const
Returns the minimum number of required tie-points for the current transformation. ...
~ProjectiveGT()
Destructor.