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