ViSP  2.6.2
vpPoseDementhon.cpp
1 /****************************************************************************
2 *
3 * $Id: vpPoseDementhon.cpp 3530 2012-01-03 10:52:12Z fspindle $
4 *
5 * This file is part of the ViSP software.
6 * Copyright (C) 2005 - 2012 by INRIA. All rights reserved.
7 *
8 * This software is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * ("GPL") version 2 as published by the Free Software Foundation.
11 * See the file LICENSE.txt at the root directory of this source
12 * distribution for additional information about the GNU GPL.
13 *
14 * For using ViSP with software that can not be combined with the GNU
15 * GPL, please contact INRIA about acquiring a ViSP Professional
16 * Edition License.
17 *
18 * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19 *
20 * This software was developed at:
21 * INRIA Rennes - Bretagne Atlantique
22 * Campus Universitaire de Beaulieu
23 * 35042 Rennes Cedex
24 * France
25 * http://www.irisa.fr/lagadic
26 *
27 * If you have questions regarding the use of this file, please contact
28 * INRIA at visp@inria.fr
29 *
30 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32 *
33 *
34 * Description:
35 * Pose computation.
36 *
37 * Authors:
38 * Eric Marchand
39 * Francois Chaumette
40 *
41 *****************************************************************************/
42 
43 
44 
45 #include <visp/vpPose.h>
46 #include <visp/vpMath.h>
47 
48 #define DEBUG_LEVEL1 0
49 #define DEBUG_LEVEL2 0
50 #define DEBUG_LEVEL3 0
51 
52 /* FC
53 #ifndef DEG
54 #define DEG (180.0/M_PI)
55 #endif
56 */
57 
68 void
70 {
71  double normI = 0., normJ = 0.;
72  double Z0 = 0.;
73  double seuil=1.0;
74  double f=1.;
75 
76  // CPoint c3d[npt] ;
77 
78  if (c3d !=NULL) delete [] c3d ;
79  c3d = new vpPoint[npt] ;
80 
81  vpPoint p0 = listP.front() ;
82 
83  vpPoint P ;
84  int i=0;
85  for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it)
86  {
87  P = *it ;
88  c3d[i] = P ;
89  c3d[i].set_oX(P.get_oX()-p0.get_oX()) ;
90  c3d[i].set_oY(P.get_oY()-p0.get_oY()) ;
91  c3d[i].set_oZ(P.get_oZ()-p0.get_oZ()) ;
92  ++i;
93  }
94 
95  vpMatrix a ;
96  try{
97  a.resize(npt,3) ;
98  }
99  catch(...)
100  {
101  vpERROR_TRACE(" ") ;
102  throw ;
103  }
104 
105  for (unsigned int i=0 ; i < npt ; i++)
106  {
107  a[i][0]=c3d[i].get_oX();
108  a[i][1]=c3d[i].get_oY();
109  a[i][2]=c3d[i].get_oZ();
110  }
111 
112  //std::cout << a << std::endl ;
113  // calcul a^T a
114  vpMatrix ata ;
115  ata = a.t()*a ;
116 
117  // calcul (a^T a)^-1 par decomposition LU
118  vpMatrix ata1 ;
119  ata1 = ata.pseudoInverse(1e-6) ; //InverseByLU() ;
120 
121  vpMatrix b ;
122  b = (a*ata1).t() ;
123 
124 #if (DEBUG_LEVEL2)
125  {
126  std::cout << "a" << std::endl <<a<<std::endl ;
127  std::cout << "ata" << std::endl <<ata<<std::endl ;
128  std::cout << "ata1" << std::endl <<ata1<<std::endl ;
129  std::cout<< " ata*ata1" << std::endl << ata*ata1 ;
130  std::cout<< " b" << std::endl << (a*ata1).t() ;
131 
132  }
133 #endif
134 
135  // calcul de la premiere solution
136 
137  vpColVector eps(npt) ;
138  eps =0 ;
139 
140  int cpt = 0 ;
141  vpColVector I, J, k ;
142  try{
143  I.resize(3) ;
144  }
145  catch(...)
146  {
147  vpERROR_TRACE(" ") ;
148  throw ;
149  }
150  try{
151  J.resize(3) ;
152  }
153  catch(...)
154  {
155  vpERROR_TRACE(" ") ;
156  throw ;
157  }
158 
159  try {
160  k.resize(3) ;
161  }
162  catch(...)
163  {
164  vpERROR_TRACE(" ") ;
165  throw ;
166  }
167 
168  while(cpt < 20)
169  {
170  I = 0 ;
171  J = 0 ;
172 
173  vpColVector xprim(npt) ;
174  vpColVector yprim(npt) ;
175  for (unsigned int i=0;i<npt;i++)
176  {
177  xprim[i]=(1+ eps[i])*c3d[i].get_x() - c3d[0].get_x();
178  yprim[i]=(1+ eps[i])*c3d[i].get_y() - c3d[0].get_y();
179  }
180  I = b*xprim ;
181  J = b*yprim ;
182  normI = sqrt(I.sumSquare()) ;
183  normJ = sqrt(J.sumSquare()) ;
184  I = I/normI ;
185  J = J/normJ ;
186 
187  if (normI+normJ < 1e-10)
188  {
189  vpERROR_TRACE(" normI+normJ = 0, division par zero " ) ;
191  "division by zero ")) ;
192  }
193 
194  k = vpColVector::cross(I,J) ;
195  Z0=2*f/(normI+normJ);
196  cpt=cpt+1; seuil=0.0;
197  for (unsigned int i=0; i<npt; i++)
198  {
199  double epsi_1 = eps[i] ;
200  eps[i]=(c3d[i].get_oX()*k[0]+c3d[i].get_oY()*k[1]+c3d[i].get_oZ()*k[2])/Z0;
201  seuil+=fabs(eps[i]-epsi_1);
202  }
203  if (npt==0)
204  {
205  vpERROR_TRACE( " npt = 0, division par zero ");
207  "division by zero ")) ;
208  }
209  seuil/=npt;
210  }
211  k.normalize();
212  J = vpColVector::cross(k,I) ;
213  /*matrice de passage*/
214 
215  cMo[0][0]=I[0];
216  cMo[0][1]=I[1];
217  cMo[0][2]=I[2];
218  cMo[0][3]=c3d[0].get_x()*2/(normI+normJ);
219 
220  cMo[1][0]=J[0];
221  cMo[1][1]=J[1];
222  cMo[1][2]=J[2];
223  cMo[1][3]=c3d[0].get_y()*2/(normI+normJ);
224 
225  cMo[2][0]=k[0];
226  cMo[2][1]=k[1];
227  cMo[2][2]=k[2];
228  cMo[2][3]=Z0;
229 
230  cMo[0][3] -= (p0.get_oX()*cMo[0][0]+p0.get_oY()*cMo[0][1]+p0.get_oZ()*cMo[0][2]);
231  cMo[1][3] -= (p0.get_oX()*cMo[1][0]+p0.get_oY()*cMo[1][1]+p0.get_oZ()*cMo[1][2]);
232  cMo[2][3] -= (p0.get_oX()*cMo[2][0]+p0.get_oY()*cMo[2][1]+p0.get_oZ()*cMo[2][2]);
233 
234  delete [] c3d ; c3d = NULL ;
235 }
236 
237 
238 #define DMIN 0.01 /* distance min entre la cible et la camera */
239 #define EPS 0.0000001
240 #define EPS_DEM 0.001
241 
242 static void
243 calculRTheta(double s, double c, double &r, double &theta)
244 {
245  if ((fabs(c) > EPS_DEM) || (fabs(s) > EPS_DEM))
246  {
247  r = sqrt(sqrt(s*s+c*c));
248  theta = atan2(s,c)/2.0;
249  }
250  else
251  {
252  if (fabs(c) > fabs(s))
253  {
254  r = fabs(c);
255  if (c >= 0.0)
256  theta = M_PI/2;
257  else
258  theta = -M_PI/2;
259  }
260  else
261  {
262  r = fabs(s);
263  if (s >= 0.0)
264  theta = M_PI/4.0;
265  else
266  theta = -M_PI/4.0;
267  }
268  }
269 }
270 
271 static
272 void calculSolutionDementhon(double xi0, double yi0,
273  vpColVector &I, vpColVector &J,
274  vpHomogeneousMatrix &cMo )
275 {
276 
277 #if (DEBUG_LEVEL1)
278  std::cout << "begin (Dementhon.cc)CalculSolutionDementhon() " << std::endl;
279 #endif
280 
281  double normI, normJ, normk, Z0;
282  vpColVector k(3);
283 
284  // normalisation de I et J
285  normI = sqrt(I.sumSquare()) ;
286  normJ = sqrt(J.sumSquare()) ;
287 
288  I/=normI;
289  J/=normJ;
290 
291 
292  k = vpColVector::cross(I,J) ; // k = I^I
293 
294  Z0=2.0/(normI+normJ);
295 
296  normk = sqrt(k.sumSquare()) ;
297  k /= normk ;
298 
299  J = vpColVector::cross(k,I) ;
300 
301  //calcul de la matrice de passage
302  cMo[0][0]=I[0];
303  cMo[0][1]=I[1];
304  cMo[0][2]=I[2];
305  cMo[0][3]=xi0*Z0;
306 
307  cMo[1][0]=J[0];
308  cMo[1][1]=J[1];
309  cMo[1][2]=J[2];
310  cMo[1][3]=yi0*Z0;
311 
312  cMo[2][0]=k[0];
313  cMo[2][1]=k[1];
314  cMo[2][2]=k[2];
315  cMo[2][3]=Z0;
316 
317 
318 #if (DEBUG_LEVEL1)
319  std::cout << "end (Dementhon.cc)CalculSolutionDementhon() " << std::endl;
320 #endif
321 
322 }
323 
324 int
326  vpHomogeneousMatrix &cMo)
327 {
328 
329 #if (DEBUG_LEVEL1)
330  std::cout << "begin vpPose::CalculArbreDementhon() " << std::endl;
331 #endif
332 
333  unsigned int i, k;
334  int erreur = 0;
335  unsigned int cpt;
336  double s,c,si,co;
337  double smin,smin_old, s1,s2;
338  double r, theta;
339  vpHomogeneousMatrix cMo1,cMo2,cMo_old;
340 
341  unsigned int iter_max = 20;
342  vpMatrix eps(iter_max+1,npt) ;
343 
344 
345  // on test si tous les points sont devant la camera
346  for(i = 0; i < npt; i++)
347  {
348  double z ;
349  z = cMo[2][0]*c3d[i].get_oX()+cMo[2][1]*c3d[i].get_oY()+cMo[2][2]*c3d[i].get_oZ() + cMo[2][3];
350  if (z <= 0.0) erreur = -1;
351  }
352 
353  smin = sqrt(computeResidualDementhon(cMo)/npt) ;
354 
355  vpColVector xi(npt) ;
356  vpColVector yi(npt) ;
357 
358  if (erreur==0)
359  {
360  k=0;
361  for(i = 0; i < npt; i++)
362  {
363  xi[k] = c3d[i].get_x();
364  yi[k] = c3d[i].get_y();
365 
366  if (k != 0)
367  { // On ne prend pas le 1er point
368  eps[0][k] = (cMo[2][0]*c3d[i].get_oX() +
369  cMo[2][1]*c3d[i].get_oY() +
370  cMo[2][2]*c3d[i].get_oZ())/cMo[2][3];
371  }
372  k++;
373  }
374 
375 
376  vpColVector I0(3) ;
377  vpColVector J0(3) ;
378  vpColVector I(3) ;
379  vpColVector J(3) ;
380 
381  vpHomogeneousMatrix cMo_old ;
382  smin_old = 2*smin ;
383 
384  cpt = 0;
385  while ((cpt<20) && (smin_old > 0.01) && (smin <= smin_old))
386  {
387 #if (DEBUG_LEVEL2)
388  {
389  std::cout << "cpt " << cpt << std::endl ;
390  std::cout << "smin_old " << smin_old << std::endl ;
391  std::cout << "smin " << smin << std::endl ;
392  }
393 #endif
394 
395  smin_old = smin;
396  cMo_old = cMo;
397 
398  I0 = 0 ;
399  J0 = 0 ;
400 
401  for (i=1;i<npt;i++)
402  {
403  s = (1.0+eps[cpt][i])*xi[i] - xi[0];
404  I0[0] += b[0][i-1] * s;
405  I0[1] += b[1][i-1] * s;
406  I0[2] += b[2][i-1] * s;
407  s = (1.0+eps[cpt][i])*yi[i] - yi[0];
408  J0[0] += b[0][i-1] * s;
409  J0[1] += b[1][i-1] * s;
410  J0[2] += b[2][i-1] * s;
411  }
412 
413  s = -2.0*(vpColVector::dotProd(I0,J0));
414  c = J0.sumSquare() - I0.sumSquare() ;
415 
416  calculRTheta(s,c,r,theta);
417  co = cos(theta);
418  si = sin(theta);
419 
420  /* 1ere branche */
421  I = I0 + U*r*co ;
422  J = J0 + U*r*si ;
423 
424 #if (DEBUG_LEVEL3)
425  {
426  std::cout << "I " << I.t() ;
427  std::cout << "J " << J.t() ;
428  }
429 #endif
430 
431  calculSolutionDementhon(xi[0],yi[0],I,J,cMo1);
432  s1 = sqrt(computeResidualDementhon(cMo1)/npt) ;
433 #if (DEBUG_LEVEL3)
434  std::cout << "cMo1 "<< std::endl << cMo1 << std::endl ;
435 #endif
436 
437  /* 2eme branche */
438  I = I0 - U*r*co ;
439  J = J0 - U*r*si ;
440 #if (DEBUG_LEVEL3)
441  {
442  std::cout << "I " << I.t() ;
443  std::cout << "J " << J.t() ;
444  }
445 #endif
446 
447  calculSolutionDementhon(xi[0],yi[0],I,J,cMo2);
448  s2 = sqrt(computeResidualDementhon(cMo2)/npt) ;
449 #if (DEBUG_LEVEL3)
450  std::cout << "cMo2 "<< std::endl << cMo2 << std::endl ;
451 #endif
452 
453  cpt ++;
454  if (s1 <= s2)
455  {
456  smin = s1;
457  k = 0;
458  for(i = 0; i < npt; i++)
459  {
460  if (k != 0) { // On ne prend pas le 1er point
461  eps[cpt][k] = (cMo1[2][0]*c3d[i].get_oX() + cMo1[2][1]*c3d[i].get_oY()
462  + cMo1[2][2]*c3d[i].get_oZ())/cMo1[2][3];
463  }
464  k++;
465  }
466  cMo = cMo1 ;
467  }
468  else
469  {
470  smin = s2;
471  k = 0;
472  for(i = 0; i < npt; i++)
473  {
474  if (k != 0) { // On ne prend pas le 1er point
475  eps[cpt][k] = (cMo2[2][0]*c3d[i].get_oX() + cMo2[2][1]*c3d[i].get_oY()
476  + cMo2[2][2]*c3d[i].get_oZ())/cMo2[2][3];
477  }
478  k++;
479  }
480  cMo = cMo2 ;
481  }
482 
483  if (smin > smin_old)
484  {
485 #if (DEBUG_LEVEL2)
486  std::cout << "Divergence " << std::endl ;
487 #endif
488 
489  cMo = cMo_old ;
490  }
491 #if (DEBUG_LEVEL2)
492  {
493  std::cout << "s1 = " << s1 << std::endl ;
494  std::cout << "s2 = " << s2 << std::endl ;
495  std::cout << "smin = " << smin << std::endl ;
496  std::cout << "smin_old = " << smin_old << std::endl ;
497  }
498 #endif
499  }
500  }
501 #if (DEBUG_LEVEL1)
502  std::cout << "end vpPose::CalculArbreDementhon() return "<< erreur << std::endl;
503 #endif
504 
505  return erreur ;
506 }
507 
516 void
518 {
519 #if (DEBUG_LEVEL1)
520  std::cout << "begin CCalculPose::PoseDementhonPlan()" << std::endl ;
521 #endif
522 
523  unsigned int i,j,k ;
524 
525  if (c3d !=NULL) delete []c3d ;
526  c3d = new vpPoint[npt] ;
527 
528  vpPoint p0 = listP.front() ;
529 
530  vpPoint P ;
531  i=0 ;
532  for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it)
533  {
534  P = *it;
535  c3d[i] = P ;
536  c3d[i].set_oX(P.get_oX()-p0.get_oX()) ;
537  c3d[i].set_oY(P.get_oY()-p0.get_oY()) ;
538  c3d[i].set_oZ(P.get_oZ()-p0.get_oZ()) ;
539  i++ ;
540  }
541 
542  vpMatrix a ;
543  try
544  {
545  a.resize(npt-1,3) ;
546  }
547  catch(...)
548  {
549  vpERROR_TRACE(" ") ;
550  throw ;
551  }
552 
553 
554  for (i=1 ; i < npt ; i++)
555  {
556  a[i-1][0]=c3d[i].get_oX();
557  a[i-1][1]=c3d[i].get_oY();
558  a[i-1][2]=c3d[i].get_oZ();
559  }
560 
561  // calcul a^T a
562  vpMatrix ata ;
563  ata = a.t()*a ;
564 
565  /* essai FC pour debug SVD */
566  /*
567  vpMatrix ata_old ;
568  ata_old = a.t()*a ;
569 
570  vpMatrix ata((ata_old.getRows()-1),(ata_old.getCols()-1)) ;
571  for (i=0;i<ata.getRows();i++)
572  for (j=0;j<ata.getCols();j++) ata[i][j] = ata_old[i][j];
573  */
574  vpMatrix ata_sav;
575  ata_sav = ata;
576 
577 #if (DEBUG_LEVEL2)
578  {
579  std::cout << "a" << std::endl <<a<<std::endl ;
580  std::cout << "ata" << std::endl <<ata<<std::endl ;
581  }
582 #endif
583 
584  // calcul (a^T a)^-1
585  vpMatrix ata1(ata.getRows(),ata.getCols()) ;
586  vpMatrix v(ata.getRows(),ata.getCols());
587  vpColVector sv(ata.getRows());
588  // ata1 = ata.i() ;
589  unsigned int imin = 0;
590  double s = 0.0;
591 
592  //calcul de ata^-1
593  ata.svd(sv,v) ;
594 
595  unsigned int nc = sv.getRows() ;
596  for (i=0; i < nc ; i++)
597  if (sv[i] > s) s = sv[i];
598 
599  s *= 0.0002;
600  int irank = 0;
601  for (i=0;i<nc;i++)
602  if (sv[i] > s ) irank++;
603 
604  double svm = 100.0;
605  for (i = 0; i < nc; i++)
606  if (sv[i] < svm) { imin = i; svm = sv[i]; }
607 
608 #if (DEBUG_LEVEL2)
609  {
610  std::cout << "rang: " << irank << std::endl ;;
611  std::cout <<"imin = " << imin << std::endl ;
612  std::cout << "sv " << sv.t() << std::endl ;
613  }
614 #endif
615 
616  for (i=0 ; i < ata.getRows() ; i++)
617  for (j=0 ; j < ata.getCols() ; j++)
618  {
619  ata1[i][j] = 0.0;
620  for (k=0 ; k < nc ; k++)
621  if (sv[k] > s)
622  ata1[i][j] += ((v[i][k]*ata[j][k])/sv[k]);
623  }
624 
625 
626 
627  vpMatrix b ; // b=(at a)^-1*at
628  b = ata1*a.t() ;
629 
630  //calcul de U
631  vpColVector U(3) ;
632  U = ata.column(imin+1) ;
633 
634 #if (DEBUG_LEVEL2)
635  {
636  std::cout << "a" << std::endl <<a<<std::endl ;
637  std::cout << "ata" << std::endl <<ata_sav<<std::endl ;
638  std::cout << "ata1" << std::endl <<ata1<<std::endl ;
639  std::cout << "ata1*ata" << std::endl << ata1*ata_sav ;
640  std::cout << "b" << std::endl << b ;
641  std::cout << "U " << U.t() << std::endl ;
642  }
643 #endif
644 
645  vpColVector xi(npt) ;
646  vpColVector yi(npt) ;
647  //calcul de la premiere solution
648  for (i = 0; i < npt; i++)
649  {
650  xi[i] = c3d[i].get_x() ;
651  yi[i] = c3d[i].get_y() ;
652 
653  }
654 
655  vpColVector I0(3) ; I0 = 0 ;
656  vpColVector J0(3) ; J0 = 0 ;
657  vpColVector I(3) ;
658  vpColVector J(3) ;
659 
660  for (i=1;i<npt;i++)
661  {
662  I0[0] += b[0][i-1] * (xi[i]-xi[0]);
663  I0[1] += b[1][i-1] * (xi[i]-xi[0]);
664  I0[2] += b[2][i-1] * (xi[i]-xi[0]);
665 
666  J0[0] += b[0][i-1] * (yi[i]-yi[0]);
667  J0[1] += b[1][i-1] * (yi[i]-yi[0]);
668  J0[2] += b[2][i-1] * (yi[i]-yi[0]);
669  }
670 
671 
672 #if (DEBUG_LEVEL2)
673  {
674  std::cout << "I0 "<<I0.t() ;
675  std::cout << "J0 "<<J0.t() ;
676  }
677 #endif
678 
679  s = -2.0*vpColVector::dotProd(I0,J0);
680  double c = J0.sumSquare() - I0.sumSquare() ;
681 
682  double r,theta,si,co ;
683  calculRTheta(s, c, r, theta);
684  co = cos(theta);
685  si = sin(theta);
686 
687  // calcul de la premiere solution
688  I = I0 + U*r*co ;
689  J = J0 + U*r*si ;
690 
691  vpHomogeneousMatrix cMo1f ;
692  calculSolutionDementhon(xi[0], yi[0], I, J, cMo1f);
693 
694 
695  int erreur1 = calculArbreDementhon(b, U, cMo1f);
696 
697  // calcul de la deuxieme solution
698  I = I0 - U*r*co ;
699  J = J0 - U*r*si ;
700 
701  vpHomogeneousMatrix cMo2f;
702  calculSolutionDementhon(xi[0], yi[0], I, J, cMo2f);
703 
704  int erreur2 = calculArbreDementhon(b, U, cMo2f);
705 
706  if ((erreur1 == 0) && (erreur2 == -1)) cMo = cMo1f ;
707  if ((erreur1 == -1) && (erreur2 == 0)) cMo = cMo2f ;
708  if ((erreur1 == 0) && (erreur2 == 0))
709  {
710  double s1 = sqrt(computeResidualDementhon(cMo1f)/npt) ;
711  double s2 = sqrt(computeResidualDementhon(cMo2f)/npt) ;
712 
713  if (s1<=s2) cMo = cMo1f ; else cMo = cMo2f ;
714  }
715 
716  cMo[0][3] -= p0.get_oX()*cMo[0][0]+p0.get_oY()*cMo[0][1]+p0.get_oZ()*cMo[0][2];
717  cMo[1][3] -= p0.get_oX()*cMo[1][0]+p0.get_oY()*cMo[1][1]+p0.get_oZ()*cMo[1][2];
718  cMo[2][3] -= p0.get_oX()*cMo[2][0]+p0.get_oY()*cMo[2][1]+p0.get_oZ()*cMo[2][2];
719 
720  delete [] c3d ; c3d = NULL ;
721 #if (DEBUG_LEVEL1)
722  std::cout << "end CCalculPose::PoseDementhonPlan()" << std::endl ;
723 #endif
724 }
725 
726 #undef DMIN
727 #undef EPS
728 #undef EPS_DEM
729 
730 
740 {
741  unsigned int i ;
742  double residual = 0 ;
743 
744 
745  residual =0 ;
746  for (i =0 ; i < npt ; i++)
747  {
748 
749  double X = c3d[i].get_oX()*cMo[0][0]+c3d[i].get_oY()*cMo[0][1]+c3d[i].get_oZ()*cMo[0][2] + cMo[0][3];
750  double Y = c3d[i].get_oX()*cMo[1][0]+c3d[i].get_oY()*cMo[1][1]+c3d[i].get_oZ()*cMo[1][2] + cMo[1][3];
751  double Z = c3d[i].get_oX()*cMo[2][0]+c3d[i].get_oY()*cMo[2][1]+c3d[i].get_oZ()*cMo[2][2] + cMo[2][3];
752 
753  double x = X/Z ;
754  double y = Y/Z ;
755 
756 
757 
758  residual += vpMath::sqr(x-c3d[i].get_x()) + vpMath::sqr(y-c3d[i].get_y()) ;
759  }
760  return residual ;
761 }
762 
763 
764 #undef DEBUG_LEVEL1
765 #undef DEBUG_LEVEL2
766 #undef DEBUG_LEVEL3
767 
768 
769 /*
770 * Local variables:
771 * c-basic-offset: 2
772 * End:
773 */
int calculArbreDementhon(vpMatrix &b, vpColVector &U, vpHomogeneousMatrix &cMo)
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
double residual
compute the residual in meter
Definition: vpPose.h:99
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:174
static vpColVector cross(const vpColVector &a, const vpColVector &b)
Definition: vpColVector.h:152
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
#define vpERROR_TRACE
Definition: vpDebug.h:379
double get_oY() const
Get the point Y coordinate in the object frame.
Definition: vpPoint.h:136
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.h:145
double sumSquare() const
return sum of the Aij^2 (for all i, for all j)
Definition: vpMatrix.cpp:758
std::list< vpPoint > listP
array of point (use here class vpPoint)
Definition: vpPose.h:97
void set_oX(const double X)
Set the point X coordinate in the object frame.
Definition: vpPoint.h:174
vpColVector column(const unsigned int j)
Column extraction.
Definition: vpMatrix.cpp:2238
Class that defines what is a point.
Definition: vpPoint.h:65
void set_oZ(const double Z)
Set the point Z coordinate in the object frame.
Definition: vpPoint.h:178
void svd(vpColVector &w, vpMatrix &v)
Definition: vpMatrix.cpp:1700
static double sqr(double x)
Definition: vpMath.h:106
vpRowVector t() const
transpose of Vector
double get_oZ() const
Get the point Z coordinate in the object frame.
Definition: vpPoint.h:138
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.h:143
unsigned int npt
number of point used in pose computation
Definition: vpPose.h:96
double get_oX() const
Get the point X coordinate in the object frame.
Definition: vpPoint.h:134
double computeResidualDementhon(vpHomogeneousMatrix &cMo)
Compute and return the residual expressed in meter for the pose matrix 'pose'.
vpMatrix t() const
Definition: vpMatrix.cpp:1174
void poseDementhonPlan(vpHomogeneousMatrix &cMo)
compute the pose using Dementhon approach (planar object)
void poseDementhonNonPlan(vpHomogeneousMatrix &cMo)
compute the pose using Dementhon approach (non planar object)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
unsigned int getCols() const
Return the number of columns of the matrix.
Definition: vpMatrix.h:159
static double dotProd(const vpColVector &a, const vpColVector &b)
Dot Product.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
Definition: vpMatrix.cpp:1810
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
vpColVector & normalize()
normalise the vector
void set_oY(const double Y)
Set the point Y coordinate in the object frame.
Definition: vpPoint.h:176
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94