40 #include <visp3/vision/vpPose.h>
42 #define DEBUG_LEVEL1 0
43 #define DEBUG_LEVEL2 0
54 calculTranslation (
vpMatrix &a,
vpMatrix &b,
unsigned int nl,
unsigned int nc1,
63 for (i=0 ; i < 3 ; i++)
65 for (j=0 ; j < nl ; j++)
66 ct[i][j] = b[j][i+nc3] ;
85 std::cout <<
"ctc " << std::endl << ctc ;
86 std::cout <<
"cta " << std::endl << cta ;
87 std::cout <<
"ctb " << std::endl << ctb ;
93 for (i=0 ; i < nc1 ; i++)
95 for (j=0 ; j < nc3 ; j++)
96 CTB[i][j] = ctb[i][j] ;
99 for (j=0 ; j < nc3 ; j++)
103 sv = cta*x1 + CTB*X2 ;
106 std::cout <<
"sv " << sv.
t() ;
113 std::cout <<
"x3 " << X3.
t() ;
116 for (i=0 ; i < nc1 ; i++)
147 std::cout <<
"begin (CLagrange.cc)Lagrange(...) " << std::endl;
168 std::cout <<
" BTB1 * BTB : " << std::endl << btb1*btb << std::endl;
169 std::cout <<
" BTB * BTB1 : " << std::endl << btb*btb1 << std::endl;
183 std::cout <<
" E :" << std::endl << e << std::endl;
203 if (x1[i] < x1[imin]) imin = i;
207 printf(
"SV(E) : %.15lf %.15lf %.15lf\n",x1[0],x1[1],x1[2]);
208 std::cout <<
" i_min " << imin << std::endl;
212 x1[i] = ata[i][imin];
218 std::cout <<
" X1 : " << x1.
t() << std::endl;
219 std::cout <<
" V : " << std::endl << ata << std::endl;
229 std::cout <<
"end (CLagrange.cc)Lagrange(...) " << std::endl;
250 std::cout <<
"begin vpPose::PoseLagrange(...) " << std::endl ;
258 unsigned int nl=
npt*2;
266 if (coplanar_plane_type == 1) {
267 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
290 b[k+1][5] = P.
get_y();
296 else if (coplanar_plane_type == 2) {
297 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
320 b[k+1][5] = P.
get_y();
328 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
351 b[k+1][5] = P.
get_y();
361 std::cout <<
"a " << a << std::endl ;
362 std::cout <<
"b " << b << std::endl ;
370 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a*X1 + b*X2).t() << std::endl ;
371 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl ;;
377 for (i=0;i<3;i++) X1[i] = -X1[i];
378 for (i=0;i<6;i++) X2[i] = -X2[i];
381 for (i=0;i<3;i++) {s += (X1[i]*X2[i]);}
382 for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);}
386 s = X2[0]*X2[0] + X2[1]*X2[1] + X2[2]*X2[2];
397 "Division by zero in Lagrange pose computation (planar plane case)")) ;
401 for (i=0;i<3;i++) {X2[i] *= s;}
404 calculTranslation (a, b, nl, 3, 3, X1, X2) ;
413 if (coplanar_plane_type == 1) {
414 cMo[0][0] = (X1[1]*X2[2])-(X1[2]*X2[1]);
415 cMo[1][0] = (X1[2]*X2[0])-(X1[0]*X2[2]);
416 cMo[2][0] = (X1[0]*X2[1])-(X1[1]*X2[0]);
426 else if (coplanar_plane_type == 2) {
427 cMo[0][1] = (X1[1]*X2[2])-(X1[2]*X2[1]);
428 cMo[1][1] = (X1[2]*X2[0])-(X1[0]*X2[2]);
429 cMo[2][1] = (X1[0]*X2[1])-(X1[1]*X2[0]);
440 cMo[0][2] = (X1[1]*X2[2])-(X1[2]*X2[1]);
441 cMo[1][2] = (X1[2]*X2[0])-(X1[0]*X2[2]);
442 cMo[2][2] = (X1[0]*X2[1])-(X1[1]*X2[0]);
458 std::cout <<
"end vpCalculPose::PoseLagrange(...) " << std::endl ;
469 std::cout <<
"begin CPose::PoseLagrange(...) " << std::endl ;
476 unsigned int nl=
npt*2;
484 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it)
517 b[k+1][8] = P.
get_y();
526 std::cout <<
"a " << a << std::endl ;
527 std::cout <<
"b " << b << std::endl ;
542 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a*X1 + b*X2).t() << std::endl ;
543 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl ;;
553 for (i=0;i<3;i++) {s += (X1[i]*X2[i]);}
554 for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);}
558 s = X2[0]*X2[0] + X2[1]*X2[1] + X2[2]*X2[2];
570 "Division by zero in Lagrange pose computation (non planar plane case)")) ;
574 for (i=0;i<3;i++) {X2[i] *= s;}
576 X2[3] = (X1[1]*X2[2])-(X1[2]*X2[1]);
577 X2[4] = (X1[2]*X2[0])-(X1[0]*X2[2]);
578 X2[5] = (X1[0]*X2[1])-(X1[1]*X2[0]);
580 calculTranslation (a, b, nl, 3, 6, X1, X2) ;
582 for (i=0 ; i<3 ; i++)
597 std::cout <<
"end vpCalculPose::PoseLagrange(...) " << std::endl ;
Implementation of a matrix and operations on matrices.
void poseLagrangePlan(vpHomogeneousMatrix &cMo, const int coplanar_plane_type=0)
Compute the pose of a planar object using Lagrange approach.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void poseLagrangeNonPlan(vpHomogeneousMatrix &cMo)
double get_oY() const
Get the point Y coordinate in the object frame.
error that can be emited by ViSP classes.
unsigned int getCols() const
Return the number of columns of the 2D array.
double get_y() const
Get the point y coordinate in the image plane.
std::list< vpPoint > listP
Array of point (use here class vpPoint)
Class that defines what is a point.
void svd(vpColVector &w, vpMatrix &v)
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 getRows() const
Return the number of rows of the 2D array.
unsigned int npt
Number of point used in pose computation.
double get_oX() const
Get the point X coordinate in the object frame.
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.