40 #include <visp3/vision/vpPose.h> 42 #define DEBUG_LEVEL1 0 43 #define DEBUG_LEVEL2 0 52 static void calculTranslation(
vpMatrix &a,
vpMatrix &b,
unsigned int nl,
unsigned int nc1,
unsigned int nc3,
60 for (i = 0; i < 3; i++) {
61 for (j = 0; j < nl; j++)
62 ct[i][j] = b[j][i + nc3];
81 std::cout <<
"ctc " << std::endl << ctc;
82 std::cout <<
"cta " << std::endl << cta;
83 std::cout <<
"ctb " << std::endl << ctb;
89 for (i = 0; i < nc1; i++) {
90 for (j = 0; j < nc3; j++)
91 CTB[i][j] = ctb[i][j];
94 for (j = 0; j < nc3; j++)
98 sv = cta * x1 + CTB * X2;
101 std::cout <<
"sv " << sv.
t();
108 std::cout <<
"x3 " << X3.
t();
111 for (i = 0; i < nc1; i++)
135 std::cout <<
"begin (CLagrange.cc)Lagrange(...) " << std::endl;
139 unsigned int i, imin;
185 std::cout <<
" BTB1 * BTB : " << std::endl << btb1 * btb << std::endl;
186 std::cout <<
" BTB * BTB1 : " << std::endl << btb * btb1 << std::endl;
194 e = -(a.
t() * b) * r;
200 std::cout <<
" E :" << std::endl << e << std::endl;
218 for (i = 0; i < x1.
getRows(); i++)
219 if (x1[i] < x1[imin])
224 printf(
"SV(E) : %.15lf %.15lf %.15lf\n", x1[0], x1[1], x1[2]);
225 std::cout <<
" i_min " << imin << std::endl;
228 for (i = 0; i < x1.
getRows(); i++)
229 x1[i] = ata[i][imin];
235 std::cout <<
" X1 : " << x1.
t() << std::endl;
236 std::cout <<
" V : " << std::endl << ata << std::endl;
244 std::cout <<
"end (CLagrange.cc)Lagrange(...) " << std::endl;
264 std::cout <<
"begin vpPose::PoseLagrange(...) " << std::endl;
271 unsigned int nl =
npt * 2;
278 if (coplanar_plane_type == 1) {
279 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it) {
286 a[k + 1][1] = -P.
get_oY();
297 b[k + 1][1] = -P.
get_oZ();
301 b[k + 1][5] = P.
get_y();
306 }
else if (coplanar_plane_type == 2) {
307 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it) {
314 a[k + 1][1] = -P.
get_oX();
325 b[k + 1][1] = -P.
get_oZ();
329 b[k + 1][5] = P.
get_y();
336 for (std::list<vpPoint>::const_iterator it =
listP.begin(); it !=
listP.end(); ++it) {
343 a[k + 1][1] = -P.
get_oX();
354 b[k + 1][1] = -P.
get_oY();
358 b[k + 1][5] = P.
get_y();
368 std::cout <<
"a " << a << std::endl;
369 std::cout <<
"b " << b << std::endl;
373 lagrange(a, b, X1, X2);
377 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a * X1 + b * X2).t() << std::endl;
378 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl;
384 for (i = 0; i < 3; i++)
386 for (i = 0; i < 6; i++)
390 for (i = 0; i < 3; i++) {
391 s += (X1[i] * X2[i]);
393 for (i = 0; i < 3; i++) {
394 X2[i] -= (s * X1[i]);
399 s = X2[0] * X2[0] + X2[1] * X2[1] + X2[2] * X2[2];
412 "(planar plane case)"));
416 for (i = 0; i < 3; i++) {
420 calculTranslation(a, b, nl, 3, 3, X1, X2);
429 if (coplanar_plane_type == 1) {
430 cMo[0][0] = (X1[1] * X2[2]) - (X1[2] * X2[1]);
431 cMo[1][0] = (X1[2] * X2[0]) - (X1[0] * X2[2]);
432 cMo[2][0] = (X1[0] * X2[1]) - (X1[1] * X2[0]);
434 for (i = 0; i < 3; i++) {
437 cMo[i][3] = X2[i + 3];
440 }
else if (coplanar_plane_type == 2) {
441 cMo[0][1] = (X1[2] * X2[1]) - (X1[1] * X2[2]);
442 cMo[1][1] = (X1[0] * X2[2]) - (X1[2] * X2[0]);
443 cMo[2][1] = (X1[1] * X2[0]) - (X1[0] * X2[1]);
445 for (i = 0; i < 3; i++) {
448 cMo[i][3] = X2[i + 3];
451 cMo[0][2] = (X1[1] * X2[2]) - (X1[2] * X2[1]);
452 cMo[1][2] = (X1[2] * X2[0]) - (X1[0] * X2[2]);
453 cMo[2][2] = (X1[0] * X2[1]) - (X1[1] * X2[0]);
455 for (i = 0; i < 3; i++) {
458 cMo[i][3] = X2[i + 3];
466 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) {
497 a[k + 1][1] = -P.
get_oX();
513 b[k + 1][1] = -P.
get_oY();
517 b[k + 1][4] = -P.
get_oZ();
522 b[k + 1][8] = P.
get_y();
531 std::cout <<
"a " << a << std::endl;
532 std::cout <<
"b " << b << std::endl;
536 lagrange(a, b, X1, X2);
546 std::cout <<
"ax1+bx2 (devrait etre 0) " << (a * X1 + b * X2).t() << std::endl;
547 std::cout <<
"norme X1 " << X1.
sumSquare() << std::endl;
557 for (i = 0; i < 3; i++) {
558 s += (X1[i] * X2[i]);
560 for (i = 0; i < 3; i++) {
561 X2[i] -= (s * X1[i]);
566 s = X2[0] * X2[0] + X2[1] * X2[1] + X2[2] * X2[2];
580 "planar plane case)"));
584 for (i = 0; i < 3; i++) {
588 X2[3] = (X1[1] * X2[2]) - (X1[2] * X2[1]);
589 X2[4] = (X1[2] * X2[0]) - (X1[0] * X2[2]);
590 X2[5] = (X1[0] * X2[1]) - (X1[1] * X2[0]);
592 calculTranslation(a, b, nl, 3, 6, X1, X2);
594 for (i = 0; i < 3; i++) {
597 cMo[i][2] = X2[i + 3];
598 cMo[i][3] = X2[i + 6];
606 std::cout <<
"end vpCalculPose::PoseLagrange(...) " << std::endl;
void svd(vpColVector &w, vpMatrix &V)
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
double get_oY() const
Get the point Y coordinate in the object frame.
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)
vpMatrix inverseByLU() const
error that can be emited by ViSP classes.
unsigned int getRows() const
std::list< vpPoint > listP
Array of point (use here class vpPoint)
double get_oX() const
Get the point X coordinate in the object frame.
Class that defines what is a point.
unsigned int getCols() const
double get_oZ() const
Get the point Z coordinate in the object frame.
unsigned int npt
Number of point used in pose computation.
Implementation of column vector and the associated operations.
double get_x() const
Get the point x coordinate in the image plane.
double get_y() const
Get the point y coordinate in the image plane.