44 #include <visp/vpPose.h>
46 #define DEBUG_LEVEL1 0
47 #define DEBUG_LEVEL2 0
58 calculTranslation (
vpMatrix &a,
vpMatrix &b,
unsigned int nl,
unsigned int nc1,
67 for (i=0 ; i < 3 ; i++)
69 for (j=0 ; j < nl ; j++)
70 ct[i][j] = b[j][i+nc3] ;
89 std::cout <<
"ctc " << std::endl << ctc ;
90 std::cout <<
"cta " << std::endl << cta ;
91 std::cout <<
"ctb " << std::endl << ctb ;
97 for (i=0 ; i < nc1 ; i++)
99 for (j=0 ; j < nc3 ; j++)
100 CTB[i][j] = ctb[i][j] ;
103 for (j=0 ; j < nc3 ; j++)
107 sv = cta*x1 + CTB*X2 ;
110 std::cout <<
"sv " << sv.
t() ;
117 std::cout <<
"x3 " << X3.
t() ;
120 for (i=0 ; i < nc1 ; i++)
151 std::cout <<
"begin (CLagrange.cc)Lagrange(...) " << std::endl;
172 std::cout <<
" BTB1 * BTB : " << std::endl << btb1*btb << std::endl;
173 std::cout <<
" BTB * BTB1 : " << std::endl << btb*btb1 << std::endl;
187 std::cout <<
" E :" << std::endl << e << std::endl;
207 if (x1[i] < x1[imin]) imin = i;
211 printf(
"SV(E) : %.15lf %.15lf %.15lf\n",x1[0],x1[1],x1[2]);
212 std::cout <<
" i_min " << imin << std::endl;
216 x1[i] = ata[i][imin];
222 std::cout <<
" X1 : " << x1.
t() << std::endl;
223 std::cout <<
" V : " << std::endl << ata << std::endl;
233 std::cout <<
"end (CLagrange.cc)Lagrange(...) " << std::endl;
254 std::cout <<
"begin vpPose::PoseLagrange(...) " << std::endl ;
262 unsigned int nl=
npt*2;
270 if (coplanar_plane_type == 1) {
271 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
294 b[k+1][5] = P.
get_y();
300 else if (coplanar_plane_type == 2) {
301 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
324 b[k+1][5] = P.
get_y();
332 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
355 b[k+1][5] = P.
get_y();
365 std::cout <<
"a " << a << std::endl ;
366 std::cout <<
"b " << b << std::endl ;
374 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a*X1 + b*X2).t() << std::endl ;
375 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl ;;
381 for (i=0;i<3;i++) X1[i] = -X1[i];
382 for (i=0;i<6;i++) X2[i] = -X2[i];
385 for (i=0;i<3;i++) {s += (X1[i]*X2[i]);}
386 for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);}
389 for (i=0;i<3;i++) {s += (X2[i]*X2[i]);}
393 std::cout <<
"Points that produce an error: " << std::endl;
394 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
396 std::cout <<
"P: " << (*it).get_x() <<
" " << (*it).get_y() <<
" "
397 << (*it).get_oX() <<
" " << (*it).get_oY() <<
" " << (*it).get_oZ() << std::endl;
401 "division by zero ")) ;
405 for (i=0;i<3;i++) {X2[i] *= s;}
408 calculTranslation (a, b, nl, 3, 3, X1, X2) ;
417 if (coplanar_plane_type == 1) {
418 cMo[0][0] = (X1[1]*X2[2])-(X1[2]*X2[1]);
419 cMo[1][0] = (X1[2]*X2[0])-(X1[0]*X2[2]);
420 cMo[2][0] = (X1[0]*X2[1])-(X1[1]*X2[0]);
430 else if (coplanar_plane_type == 2) {
431 cMo[0][1] = (X1[1]*X2[2])-(X1[2]*X2[1]);
432 cMo[1][1] = (X1[2]*X2[0])-(X1[0]*X2[2]);
433 cMo[2][1] = (X1[0]*X2[1])-(X1[1]*X2[0]);
444 cMo[0][2] = (X1[1]*X2[2])-(X1[2]*X2[1]);
445 cMo[1][2] = (X1[2]*X2[0])-(X1[0]*X2[2]);
446 cMo[2][2] = (X1[0]*X2[1])-(X1[1]*X2[0]);
464 std::cout <<
"end vpCalculPose::PoseLagrange(...) " << std::endl ;
475 std::cout <<
"begin CPose::PoseLagrange(...) " << std::endl ;
482 unsigned int nl=
npt*2;
490 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
523 b[k+1][8] = P.
get_y();
532 std::cout <<
"a " << a << std::endl ;
533 std::cout <<
"b " << b << std::endl ;
548 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a*X1 + b*X2).t() << std::endl ;
549 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl ;;
559 for (i=0;i<3;i++) {s += (X1[i]*X2[i]);}
560 for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);}
563 for (i=0;i<3;i++) {s += (X2[i]*X2[i]);}
567 std::cout <<
"Points that produce an error: " << std::endl;
568 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
570 std::cout <<
"P: " << (*it).get_x() <<
" " << (*it).get_y() <<
" "
571 << (*it).get_oX() <<
" " << (*it).get_oY() <<
" " << (*it).get_oZ() << std::endl;
575 "division by zero ")) ;
580 for (i=0;i<3;i++) {X2[i] *= s;}
582 X2[3] = (X1[1]*X2[2])-(X1[2]*X2[1]);
583 X2[4] = (X1[2]*X2[0])-(X1[0]*X2[2]);
584 X2[5] = (X1[0]*X2[1])-(X1[1]*X2[0]);
586 calculTranslation (a, b, nl, 3, 6, X1, X2) ;
589 for (i=0 ; i<3 ; i++)
605 std::cout <<
"end vpCalculPose::PoseLagrange(...) " << std::endl ;
Definition of the vpMatrix class.
void poseLagrangePlan(vpHomogeneousMatrix &cMo, const int coplanar_plane_type=0)
compute the pose using Lagrange approach (planar object)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void poseLagrangeNonPlan(vpHomogeneousMatrix &cMo)
compute the pose using Lagrange approach (non planar object)
double get_oY() const
Get the point Y coordinate in the object frame.
error that can be emited by ViSP classes.
double get_y() const
Get the point y coordinate in the image plane.
double sumSquare() const
return sum of the Aij^2 (for all i, for all j)
std::list< vpPoint > listP
array of point (use here class vpPoint)
Class that defines what is a point.
void svd(vpColVector &w, vpMatrix &v)
vpRowVector t() const
transpose of Vector
double get_oZ() const
Get the point Z coordinate in the object frame.
double get_x() const
Get the point x coordinate in the image plane.
unsigned int npt
number of point used in pose computation
double get_oX() const
Get the point X coordinate in the object frame.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpMatrix inverseByLU() const
unsigned int getCols() const
Return the number of columns of the matrix.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
unsigned int getRows() const
Return the number of rows of the matrix.