50 #include <visp/vpHomography.h>
56 vpHomography::HartleyNormalization(
unsigned int n,
58 double *xn,
double *yn,
59 double &xg,
double &yg,
66 for (i =0 ; i < n ; i++)
90 if(std::fabs(distance) <= std::numeric_limits<double>::epsilon())
93 coef=sqrt(2.0)/distance;
106 vpHomography::HartleyDenormalization(
vpHomography &aHbn,
108 double xg1,
double yg1,
double coef1,
109 double xg2,
double yg2,
double coef2 )
123 T1[0][0]=T1[1][1]=coef1;
124 T1[0][2]=-coef1*xg1 ;
125 T1[1][2]=-coef1*yg1 ;
127 T2[0][0]=T2[1][1]=coef2;
128 T2[0][2]=-coef2*xg2 ;
129 T2[1][2]=-coef2*yg2 ;
132 T2T=T2.pseudoInverse(1e-16) ;
136 for (
unsigned int i=0 ; i < 3 ; i++)
137 for (
unsigned int j=0 ; j < 3 ; j++) aHb[i][j] = maHb[i][j] ;
155 double *xb,
double *yb,
156 double *xa,
double *ya ,
166 xbn =
new double [n];
167 ybn =
new double [n];
169 double xg1, yg1, coef1 ;
170 vpHomography::HartleyNormalization(n,
177 xan =
new double [n];
178 yan =
new double [n];
180 double xg2, yg2, coef2 ;
181 vpHomography::HartleyNormalization(n,
191 vpHomography::HartleyDenormalization(aHbn,aHb,xg1,yg1,coef1,xg2,yg2, coef2);
263 double *xb,
double *yb,
264 double *xa,
double *ya ,
271 vpTRACE(
"there must be at least 4 points in the both images\n") ;
299 A[2*i][6]=xb[i]*ya[i] ;
300 A[2*i][7]=yb[i]*ya[i];
310 A[2*i+1][6]=-xb[i]*xa[i];
311 A[2*i+1][7]=-yb[i]*xa[i];
317 for (
int i=0; i < 9; i ++) {
329 for(i = 0; i<9;i++) if(D[i]>1e-7) rank++;
332 vpTRACE(
" le rang est de : %d, shoud be 8", rank);
339 double smallestSv = 1e30 ;
340 unsigned int indexSmallestSv = 0 ;
341 for (i=0 ; i < 9 ; i++)
342 if ((D[i] < smallestSv) ){ smallestSv = D[i] ;indexSmallestSv = i ; }
345 h=V.
column(indexSmallestSv+1);
Definition of the vpMatrix class.
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
vpMatrix()
Basic constructor.
vpColVector column(const unsigned int j)
Column extraction.
This class aims to compute the homography wrt.two images.
void svd(vpColVector &w, vpMatrix &v)
static double sqr(double x)
static void DLT(unsigned int n, double *xb, double *yb, double *xa, double *ya, vpHomography &aHb)
Computes the homography matrix wrt. the data using the DLT (Direct Linear Transform) algorithm...
Class that provides a data structure for the column vectors as well as a set of operations on these v...
static void HartleyDLT(unsigned int n, double *xb, double *yb, double *xa, double *ya, vpHomography &aHb)
Computes the homography matrix using the DLT (Direct Linear Transform) algorithm on normalized data...