34 #include <visp3/core/vpDebug.h>
35 #include <visp3/core/vpMath.h>
36 #include <visp3/core/vpPixelMeterConversion.h>
37 #include <visp3/vision/vpCalibration.h>
38 #include <visp3/vision/vpPose.h>
49 std::list<double>::const_iterator it_LoX = m_LoX.begin();
50 std::list<double>::const_iterator it_LoY = m_LoY.begin();
51 std::list<double>::const_iterator it_LoZ = m_LoZ.begin();
52 std::list<vpImagePoint>::const_iterator it_Lip = m_Lip.begin();
56 for (
unsigned int i = 0; i < m_npt; i++) {
64 double xi = ip.
get_u();
65 double yi = ip.
get_v();
67 A[2 * i][0] = x0 * xi;
68 A[2 * i][1] = y0 * xi;
69 A[2 * i][2] = z0 * xi;
79 A[2 * i + 1][0] = x0 * yi;
80 A[2 * i + 1][1] = y0 * yi;
81 A[2 * i + 1][2] = z0 * yi;
82 B[2 * i + 1][0] = 0.0;
83 B[2 * i + 1][1] = 0.0;
84 B[2 * i + 1][2] = 0.0;
85 B[2 * i + 1][3] = -x0;
86 B[2 * i + 1][4] = -y0;
87 B[2 * i + 1][5] = -z0;
88 B[2 * i + 1][6] = 0.0;
89 B[2 * i + 1][7] = -1.0;
115 e = -(A.t() * B) * r;
129 unsigned int imin = 1;
130 for (
unsigned int i = 0; i < x1.getRows(); i++) {
139 for (
unsigned int i = 0; i < x1.getRows(); i++) {
140 if (x1[i] < x1[imin])
144 for (
unsigned int i = 0; i < x1.getRows(); i++)
145 x1[i] = AtA[i][imin];
151 for (
unsigned int i = 0; i < 3; i++)
153 for (
unsigned int i = 0; i < 9; i++)
159 for (
unsigned int i = 0; i < 12; i++)
162 resul[0] = sol[3] * sol[0] + sol[4] * sol[1] + sol[5] * sol[2];
164 resul[1] = sol[6] * sol[0] + sol[7] * sol[1] + sol[8] * sol[2];
166 resul[2] = sqrt(sol[3] * sol[3] + sol[4] * sol[4] + sol[5] * sol[5]
167 - resul[0] * resul[0]);
173 resul[3] = sqrt(sol[6] * sol[6] + sol[7] * sol[7] + sol[8] * sol[8]
174 - resul[1] * resul[1]);
179 resul[4] = (sol[9] - sol[11] * resul[0]) / resul[2];
180 resul[5] = (sol[10] - sol[11] * resul[1]) / resul[3];
185 for (
unsigned int i = 0; i < 3; i++)
186 rd[0][i] = (sol[i + 3] - sol[i] * resul[0]) / resul[2];
187 for (
unsigned int i = 0; i < 3; i++)
188 rd[1][i] = (sol[i + 6] - sol[i] * resul[1]) / resul[3];
189 for (
unsigned int i = 0; i < 3; i++)
195 for (
unsigned int i = 0; i < 3; i++) {
196 for (
unsigned int j = 0; j < 3; j++)
197 cMo_est[i][j] = rd[i][j];
199 for (
unsigned int i = 0; i < 3; i++)
200 cMo_est[i][3] = resul[i + 4];
205 double deviation, deviation_dist;
211 std::ios::fmtflags original_flags(std::cout.flags());
212 std::cout.precision(10);
213 unsigned int n_points = m_npt;
226 std::list<double>::const_iterator it_LoX = m_LoX.begin();
227 std::list<double>::const_iterator it_LoY = m_LoY.begin();
228 std::list<double>::const_iterator it_LoZ = m_LoZ.begin();
229 std::list<vpImagePoint>::const_iterator it_Lip = m_Lip.begin();
231 for (
unsigned int i = 0; i < n_points; i++) {
248 unsigned int iter = 0;
250 double residu_1 = 1e12;
252 while (
vpMath::equal(residu_1, r, m_threshold) ==
false && iter < m_nbIterMax) {
265 double u0 = cam_est.
get_u0();
266 double v0 = cam_est.
get_v0();
270 for (
unsigned int i = 0; i < n_points; i++) {
271 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
272 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
273 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
276 Pd[2 * i + 1] = v[i];
278 P[2 * i] = cX[i] / cZ[i] * px + u0;
279 P[2 * i + 1] = cY[i] / cZ[i] * py + v0;
289 for (
unsigned int i = 0; i < n_points; i++) {
293 double inv_z = 1 / z;
295 double X = x * inv_z;
296 double Y = y * inv_z;
300 L[2 * i][0] = px * (-inv_z);
302 L[2 * i][2] = px * X * inv_z;
303 L[2 * i][3] = px * X * Y;
304 L[2 * i][4] = -px * (1 + X * X);
305 L[2 * i][5] = px * Y;
322 L[2 * i + 1][1] = py * (-inv_z);
323 L[2 * i + 1][2] = py * (Y * inv_z);
324 L[2 * i + 1][3] = py * (1 + Y * Y);
325 L[2 * i + 1][4] = -py * X * Y;
326 L[2 * i + 1][5] = -py * X;
341 Lp = L.pseudoInverse(1e-10);
350 for (
unsigned int i = 0; i < 6; i++)
362 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
364 if (iter == m_nbIterMax) {
365 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", m_nbIterMax);
370 this->m_residual = r;
371 this->m_residual_dist = r;
373 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
375 std::cout.flags(original_flags);
378 void vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal,
vpCameraParameters &cam_est,
379 double &globalReprojectionError,
bool verbose,
double aspect_ratio)
381 std::ios::fmtflags original_flags(std::cout.flags());
382 std::cout.precision(10);
383 unsigned int nbPoint[256];
384 unsigned int nbPointTotal = 0;
385 unsigned int nbPose = (
unsigned int)table_cal.size();
386 unsigned int nbPose6 = 6 * nbPose;
388 for (
unsigned int i = 0; i < nbPose; i++) {
389 nbPoint[i] = table_cal[i].m_npt;
390 nbPointTotal += nbPoint[i];
393 if (nbPointTotal < 4) {
408 unsigned int curPoint = 0;
409 for (
unsigned int p = 0; p < nbPose; p++) {
410 std::list<double>::const_iterator it_LoX = table_cal[p].m_LoX.begin();
411 std::list<double>::const_iterator it_LoY = table_cal[p].m_LoY.begin();
412 std::list<double>::const_iterator it_LoZ = table_cal[p].m_LoZ.begin();
413 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].m_Lip.begin();
415 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
416 oX[curPoint] = *it_LoX;
417 oY[curPoint] = *it_LoY;
418 oZ[curPoint] = *it_LoZ;
421 u[curPoint] = ip.
get_u();
422 v[curPoint] = ip.
get_v();
433 unsigned int iter = 0;
435 double residu_1 = 1e12;
437 while (
vpMath::equal(residu_1, r, m_threshold) ==
false && iter < m_nbIterMax) {
443 if (aspect_ratio > 0.) {
445 py = px / aspect_ratio;
451 double u0 = cam_est.
get_u0();
452 double v0 = cam_est.
get_v0();
456 for (
unsigned int p = 0; p < nbPose; p++) {
458 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
459 unsigned int curPoint2 = 2 * curPoint;
462 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
464 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
466 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
468 Pd[curPoint2] = u[curPoint];
469 Pd[curPoint2 + 1] = v[curPoint];
471 P[curPoint2] = cX[curPoint] / cZ[curPoint] * px + u0;
472 P[curPoint2 + 1] = cY[curPoint] / cZ[curPoint] * py + v0;
483 vpMatrix L(nbPointTotal * 2, nbPose6 + 3 + (aspect_ratio > 0. ? 0 : 1));
485 for (
unsigned int p = 0; p < nbPose; p++) {
486 unsigned int q = 6 * p;
487 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
488 unsigned int curPoint2 = 2 * curPoint;
489 unsigned int curPoint21 = curPoint2 + 1;
491 double x = cX[curPoint];
492 double y = cY[curPoint];
493 double z = cZ[curPoint];
495 double inv_z = 1 / z;
497 double X = x * inv_z;
498 double Y = y * inv_z;
503 L[curPoint2][q] = px * (-inv_z);
504 L[curPoint2][q + 1] = 0;
505 L[curPoint2][q + 2] = px * (X * inv_z);
506 L[curPoint2][q + 3] = px * X * Y;
507 L[curPoint2][q + 4] = -px * (1 + X * X);
508 L[curPoint2][q + 5] = px * Y;
511 L[curPoint2][nbPose6] = 1;
512 L[curPoint2][nbPose6 + 1] = 0;
513 if (aspect_ratio > 0.) {
514 L[curPoint2][nbPose6 + 2] = X;
517 L[curPoint2][nbPose6 + 2] = X;
518 L[curPoint2][nbPose6 + 3] = 0;
522 L[curPoint21][q] = 0;
523 L[curPoint21][q + 1] = py * (-inv_z);
524 L[curPoint21][q + 2] = py * (Y * inv_z);
525 L[curPoint21][q + 3] = py * (1 + Y * Y);
526 L[curPoint21][q + 4] = -py * X * Y;
527 L[curPoint21][q + 5] = -py * X;
530 L[curPoint21][nbPose6] = 0;
531 L[curPoint21][nbPose6 + 1] = 1;
532 if (aspect_ratio > 0.) {
533 L[curPoint21][nbPose6 + 2] = Y;
536 L[curPoint21][nbPose6 + 2] = 0;
537 L[curPoint21][nbPose6 + 3] = Y;
545 Lp = L.pseudoInverse(1e-10);
554 for (
unsigned int i = 0; i < nbPose6; i++)
557 if (aspect_ratio > 0.) {
559 u0 + Tc[nbPose6], v0 + Tc[nbPose6 + 1]);
564 v0 + Tc[nbPose6 + 1]);
570 for (
unsigned int p = 0; p < nbPose; p++) {
571 for (
unsigned int i = 0; i < 6; i++)
572 Tc_v_Tmp[i] = Tc_v[6 * p + i];
578 std::cout <<
" std dev " << sqrt(r / nbPointTotal) << std::endl;
580 if (iter == m_nbIterMax) {
581 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", m_nbIterMax);
584 for (
unsigned int p = 0; p < nbPose; p++) {
585 table_cal[p].cMo_dist = table_cal[p].cMo;
586 table_cal[p].cam = cam_est;
587 table_cal[p].cam_dist = cam_est;
588 double deviation, deviation_dist;
589 table_cal[p].computeStdDeviation(deviation, deviation_dist);
591 globalReprojectionError = sqrt(r / nbPointTotal);
593 std::cout.flags(original_flags);
598 std::ios::fmtflags original_flags(std::cout.flags());
599 std::cout.precision(10);
600 unsigned int n_points = m_npt;
611 std::list<double>::const_iterator it_LoX = m_LoX.begin();
612 std::list<double>::const_iterator it_LoY = m_LoY.begin();
613 std::list<double>::const_iterator it_LoZ = m_LoZ.begin();
614 std::list<vpImagePoint>::const_iterator it_Lip = m_Lip.begin();
618 for (
unsigned int i = 0; i < n_points; i++) {
634 unsigned int iter = 0;
636 double residu_1 = 1e12;
638 while (
vpMath::equal(residu_1, r, m_threshold) ==
false && iter < m_nbIterMax) {
643 double u0 = cam_est.
get_u0();
644 double v0 = cam_est.
get_v0();
656 double inv_px = 1 / px;
657 double inv_py = 1 / py;
659 double kud = cam_est.
get_kud();
660 double kdu = cam_est.
get_kdu();
662 double k2ud = 2 * kud;
663 double k2du = 2 * kdu;
666 for (
unsigned int i = 0; i < n_points; i++) {
667 unsigned int i4 = 4 * i;
668 unsigned int i41 = 4 * i + 1;
669 unsigned int i42 = 4 * i + 2;
670 unsigned int i43 = 4 * i + 3;
672 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
673 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
674 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
679 double inv_z = 1 / z;
681 double X = x * inv_z;
682 double Y = y * inv_z;
694 double up0 = up - u0;
695 double vp0 = vp - v0;
697 double xp0 = up0 * inv_px;
698 double xp02 = xp0 * xp0;
700 double yp0 = vp0 * inv_py;
701 double yp02 = yp0 * yp0;
703 double r2du = xp02 + yp02;
704 double kr2du = kdu * r2du;
706 P[i4] = u0 + px * X - kr2du * (up0);
707 P[i41] = v0 + py * Y - kr2du * (vp0);
709 double r2ud = X2 + Y2;
710 double kr2ud = 1 + kud * r2ud;
712 double Axx = px * (kr2ud + k2ud * X2);
713 double Axy = px * k2ud * XY;
714 double Ayy = py * (kr2ud + k2ud * Y2);
715 double Ayx = py * k2ud * XY;
720 P[i42] = u0 + px * X * kr2ud;
721 P[i43] = v0 + py * Y * kr2ud;
730 L[i4][0] = px * (-inv_z);
732 L[i4][2] = px * X * inv_z;
733 L[i4][3] = px * X * Y;
734 L[i4][4] = -px * (1 + X2);
738 L[i4][6] = 1 + kr2du + k2du * xp02;
739 L[i4][7] = k2du * up0 * yp0 * inv_py;
742 L[i4][8] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
743 L[i4][9] = -(up0) * (r2du);
748 L[i4][8] = X + k2du * xp02 * xp0;
749 L[i4][9] = k2du * up0 * yp02 * inv_py;
750 L[i4][10] = -(up0) * (r2du);
756 L[i41][1] = py * (-inv_z);
757 L[i41][2] = py * Y * inv_z;
758 L[i41][3] = py * (1 + Y2);
759 L[i41][4] = -py * XY;
763 L[i41][6] = k2du * xp0 * vp0 * inv_px;
764 L[i41][7] = 1 + kr2du + k2du * yp02;
766 L[i41][8] = k2du * vp0 * xp02 * inv_px + Y + k2du * yp02 * yp0;
767 L[i41][9] = -vp0 * r2du;
772 L[i41][8] = k2du * vp0 * xp02 * inv_px;
773 L[i41][9] = Y + k2du * yp02 * yp0;
774 L[i41][10] = -vp0 * r2du;
780 L[i42][0] = Axx * (-inv_z);
781 L[i42][1] = Axy * (-inv_z);
782 L[i42][2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
783 L[i42][3] = Axx * X * Y + Axy * (1 + Y2);
784 L[i42][4] = -Axx * (1 + X2) - Axy * XY;
785 L[i42][5] = Axx * Y - Axy * X;
791 L[i42][8] = X * kr2ud;
793 L[i42][10] = px * X * r2ud;
797 L[i42][8] = X * kr2ud;
800 L[i42][11] = px * X * r2ud;
804 L[i43][0] = Ayx * (-inv_z);
805 L[i43][1] = Ayy * (-inv_z);
806 L[i43][2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
807 L[i43][3] = Ayx * XY + Ayy * (1 + Y2);
808 L[i43][4] = -Ayx * (1 + X2) - Ayy * XY;
809 L[i43][5] = Ayx * Y - Ayy * X;
815 L[i43][8] = Y * kr2ud;
817 L[i43][10] = py * Y * r2ud;
821 L[i43][9] = Y * kr2ud;
823 L[i43][11] = py * Y * r2ud;
834 Lp = L.pseudoInverse(1e-10);
842 for (
unsigned int i = 0; i < 6; i++)
847 kud + Tc[10], kdu + Tc[9]);
855 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
857 if (iter == m_nbIterMax) {
858 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", m_nbIterMax);
861 this->m_residual_dist = r;
866 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
869 std::cout.flags(original_flags);
872 void vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal,
vpCameraParameters &cam_est,
873 double &globalReprojectionError,
bool verbose,
double aspect_ratio)
875 std::ios::fmtflags original_flags(std::cout.flags());
876 std::cout.precision(10);
877 unsigned int nbPoint[1024];
878 unsigned int nbPointTotal = 0;
879 unsigned int nbPose = (
unsigned int)table_cal.size();
880 unsigned int nbPose6 = 6 * nbPose;
881 for (
unsigned int i = 0; i < nbPose; i++) {
882 nbPoint[i] = table_cal[i].m_npt;
883 nbPointTotal += nbPoint[i];
886 if (nbPointTotal < 4) {
901 unsigned int curPoint = 0;
902 for (
unsigned int p = 0; p < nbPose; p++) {
903 std::list<double>::const_iterator it_LoX = table_cal[p].m_LoX.begin();
904 std::list<double>::const_iterator it_LoY = table_cal[p].m_LoY.begin();
905 std::list<double>::const_iterator it_LoZ = table_cal[p].m_LoZ.begin();
906 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].m_Lip.begin();
908 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
909 oX[curPoint] = *it_LoX;
910 oY[curPoint] = *it_LoY;
911 oZ[curPoint] = *it_LoZ;
914 u[curPoint] = ip.
get_u();
915 v[curPoint] = ip.
get_v();
925 unsigned int iter = 0;
927 double residu_1 = 1e12;
929 while (
vpMath::equal(residu_1, r, m_threshold) ==
false && iter < m_nbIterMax) {
935 for (
unsigned int p = 0; p < nbPose; p++) {
937 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
939 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
941 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
943 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
949 vpMatrix L(nbPointTotal * 4, nbPose6 + 5 + (aspect_ratio > 0. ? 0 : 1));
952 if (aspect_ratio > 0.) {
954 py = px / aspect_ratio;
960 double u0 = cam_est.
get_u0();
961 double v0 = cam_est.
get_v0();
963 double inv_px = 1 / px;
964 double inv_py = 1 / py;
966 double kud = cam_est.
get_kud();
967 double kdu = cam_est.
get_kdu();
969 double k2ud = 2 * kud;
970 double k2du = 2 * kdu;
972 for (
unsigned int p = 0; p < nbPose; p++) {
973 unsigned int q = 6 * p;
974 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
975 unsigned int curPoint4 = 4 * curPoint;
976 double x = cX[curPoint];
977 double y = cY[curPoint];
978 double z = cZ[curPoint];
980 double inv_z = 1 / z;
981 double X = x * inv_z;
982 double Y = y * inv_z;
988 double up = u[curPoint];
989 double vp = v[curPoint];
992 Pd[curPoint4 + 1] = vp;
994 double up0 = up - u0;
995 double vp0 = vp - v0;
997 double xp0 = up0 * inv_px;
998 double xp02 = xp0 * xp0;
1000 double yp0 = vp0 * inv_py;
1001 double yp02 = yp0 * yp0;
1003 double r2du = xp02 + yp02;
1004 double kr2du = kdu * r2du;
1006 P[curPoint4] = u0 + px * X - kr2du * (up0);
1007 P[curPoint4 + 1] = v0 + py * Y - kr2du * (vp0);
1009 double r2ud = X2 + Y2;
1010 double kr2ud = 1 + kud * r2ud;
1012 double Axx = px * (kr2ud + k2ud * X2);
1013 double Axy = px * k2ud * XY;
1014 double Ayy = py * (kr2ud + k2ud * Y2);
1015 double Ayx = py * k2ud * XY;
1017 Pd[curPoint4 + 2] = up;
1018 Pd[curPoint4 + 3] = vp;
1020 P[curPoint4 + 2] = u0 + px * X * kr2ud;
1021 P[curPoint4 + 3] = v0 + py * Y * kr2ud;
1027 unsigned int curInd = curPoint4;
1031 L[curInd][q] = px * (-inv_z);
1032 L[curInd][q + 1] = 0;
1033 L[curInd][q + 2] = px * X * inv_z;
1034 L[curInd][q + 3] = px * X * Y;
1035 L[curInd][q + 4] = -px * (1 + X2);
1036 L[curInd][q + 5] = px * Y;
1039 L[curInd][nbPose6] = 1 + kr2du + k2du * xp02;
1040 L[curInd][nbPose6 + 1] = k2du * up0 * yp0 * inv_py;
1041 if (aspect_ratio > 0.) {
1042 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
1043 L[curInd][nbPose6 + 3] = -(up0) * (r2du);
1044 L[curInd][nbPose6 + 4] = 0;
1047 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0;
1048 L[curInd][nbPose6 + 3] = k2du * up0 * yp02 * inv_py;
1049 L[curInd][nbPose6 + 4] = -(up0) * (r2du);
1050 L[curInd][nbPose6 + 5] = 0;
1056 L[curInd][q + 1] = py * (-inv_z);
1057 L[curInd][q + 2] = py * Y * inv_z;
1058 L[curInd][q + 3] = py * (1 + Y2);
1059 L[curInd][q + 4] = -py * XY;
1060 L[curInd][q + 5] = -py * X;
1063 L[curInd][nbPose6] = k2du * xp0 * vp0 * inv_px;
1064 L[curInd][nbPose6 + 1] = 1 + kr2du + k2du * yp02;
1065 if (aspect_ratio > 0.) {
1066 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px + Y + k2du * yp02 * yp0;
1067 L[curInd][nbPose6 + 3] = -vp0 * r2du;
1068 L[curInd][nbPose6 + 4] = 0;
1071 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px;
1072 L[curInd][nbPose6 + 3] = Y + k2du * yp02 * yp0;
1073 L[curInd][nbPose6 + 4] = -vp0 * r2du;
1074 L[curInd][nbPose6 + 5] = 0;
1080 L[curInd][q] = Axx * (-inv_z);
1081 L[curInd][q + 1] = Axy * (-inv_z);
1082 L[curInd][q + 2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
1083 L[curInd][q + 3] = Axx * X * Y + Axy * (1 + Y2);
1084 L[curInd][q + 4] = -Axx * (1 + X2) - Axy * XY;
1085 L[curInd][q + 5] = Axx * Y - Axy * X;
1088 L[curInd][nbPose6] = 1;
1089 L[curInd][nbPose6 + 1] = 0;
1090 if (aspect_ratio > 0.) {
1091 L[curInd][nbPose6 + 2] = X * kr2ud;
1092 L[curInd][nbPose6 + 3] = 0;
1093 L[curInd][nbPose6 + 4] = px * X * r2ud;
1096 L[curInd][nbPose6 + 2] = X * kr2ud;
1097 L[curInd][nbPose6 + 3] = 0;
1098 L[curInd][nbPose6 + 4] = 0;
1099 L[curInd][nbPose6 + 5] = px * X * r2ud;
1104 L[curInd][q] = Ayx * (-inv_z);
1105 L[curInd][q + 1] = Ayy * (-inv_z);
1106 L[curInd][q + 2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
1107 L[curInd][q + 3] = Ayx * XY + Ayy * (1 + Y2);
1108 L[curInd][q + 4] = -Ayx * (1 + X2) - Ayy * XY;
1109 L[curInd][q + 5] = Ayx * Y - Ayy * X;
1112 L[curInd][nbPose6] = 0;
1113 L[curInd][nbPose6 + 1] = 1;
1114 if (aspect_ratio > 0.) {
1115 L[curInd][nbPose6 + 2] = Y * kr2ud;
1116 L[curInd][nbPose6 + 3] = 0;
1117 L[curInd][nbPose6 + 4] = py * Y * r2ud;
1120 L[curInd][nbPose6 + 2] = 0;
1121 L[curInd][nbPose6 + 3] = Y * kr2ud;
1122 L[curInd][nbPose6 + 4] = 0;
1123 L[curInd][nbPose6 + 5] = py * Y * r2ud;
1137 L.pseudoInverse(Lp, 1e-10);
1142 for (
unsigned int i = 0; i < 6 * nbPose; i++)
1145 if (aspect_ratio > 0.) {
1147 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 4], kdu + Tc[nbPose6 + 3]);
1151 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 5], kdu + Tc[nbPose6 + 4]);
1155 for (
unsigned int p = 0; p < nbPose; p++) {
1156 for (
unsigned int i = 0; i < 6; i++)
1157 Tc_v_Tmp[i] = Tc_v[6 * p + i];
1162 std::cout <<
" std dev: " << sqrt(r / nbPointTotal) << std::endl;
1165 if (iter == m_nbIterMax) {
1166 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", m_nbIterMax);
1173 for (
unsigned int p = 0; p < nbPose; p++) {
1174 table_cal[p].cam_dist = cam_est;
1176 table_cal[p].computeStdDeviation_dist(table_cal[p].
cMo_dist, cam_est);
1180 globalReprojectionError = sqrt(r / (nbPointTotal));
1183 std::cout <<
" Global std dev " << globalReprojectionError << std::endl;
1186 std::cout.flags(original_flags);
1190 bool verbose,
double aspect_ratio)
1192 std::vector<vpCalibration> v_table_cal(nbPose);
1193 double globalReprojectionError = 0;
1194 for (
unsigned int i = 0; i < nbPose; i++) {
1195 v_table_cal[i] = table_cal[i];
1198 calibVVSMulti(v_table_cal, cam_est, globalReprojectionError, verbose, aspect_ratio);
1200 for (
unsigned int i = 0; i < nbPose; i++) {
1201 table_cal[i] = v_table_cal[i];
1205 void vpCalibration::calibVVSWithDistortionMulti(
unsigned int nbPose,
vpCalibration table_cal[],
1208 std::vector<vpCalibration> v_table_cal(nbPose);
1209 double globalReprojectionError = 0;
1210 for (
unsigned int i = 0; i < nbPose; i++) {
1211 v_table_cal[i] = table_cal[i];
1214 calibVVSWithDistortionMulti(v_table_cal, cam_est, globalReprojectionError, verbose, aspect_ratio);
1216 for (
unsigned int i = 0; i < nbPose; i++) {
1217 table_cal[i] = v_table_cal[i];
Error that can be emitted by the vpCalibration class.
@ convergencyError
Iterative algorithm doesn't converge.
@ notInitializedError
Something is not initialized.
Tools for perspective camera calibration.
void computeStdDeviation(double &deviation, double &deviation_dist)
vpCameraParameters cam_dist
vpHomogeneousMatrix cMo_dist
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
Implementation of column vector and the associated operations.
static vpHomogeneousMatrix direct(const vpColVector &v)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double sqr(double x)
static bool equal(double x, double y, double threshold=0.001)
Implementation of a matrix and operations on matrices.
void svd(vpColVector &w, vpMatrix &V)
vpMatrix pseudoInverse(double svThreshold=1e-6) const