34 #include <visp3/core/vpMath.h>
35 #include <visp3/core/vpPixelMeterConversion.h>
36 #include <visp3/vision/vpCalibration.h>
37 #include <visp3/vision/vpPose.h>
42 #define DEBUG_LEVEL1 0
43 #define DEBUG_LEVEL2 0
54 std::list<double>::const_iterator it_LoX = LoX.begin();
55 std::list<double>::const_iterator it_LoY = LoY.begin();
56 std::list<double>::const_iterator it_LoZ = LoZ.begin();
57 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
61 for (
unsigned int i = 0; i < npt; i++) {
69 double xi = ip.
get_u();
70 double yi = ip.
get_v();
72 A[2 * i][0] = x0 * xi;
73 A[2 * i][1] = y0 * xi;
74 A[2 * i][2] = z0 * xi;
84 A[2 * i + 1][0] = x0 * yi;
85 A[2 * i + 1][1] = y0 * yi;
86 A[2 * i + 1][2] = z0 * yi;
87 B[2 * i + 1][0] = 0.0;
88 B[2 * i + 1][1] = 0.0;
89 B[2 * i + 1][2] = 0.0;
90 B[2 * i + 1][3] = -x0;
91 B[2 * i + 1][4] = -y0;
92 B[2 * i + 1][5] = -z0;
93 B[2 * i + 1][6] = 0.0;
94 B[2 * i + 1][7] = -1.0;
120 e = -(A.t() * B) * r;
134 unsigned int imin = 1;
135 for (
unsigned int i = 0; i < x1.getRows(); i++) {
144 for (
unsigned int i = 0; i < x1.getRows(); i++) {
145 if (x1[i] < x1[imin])
149 for (
unsigned int i = 0; i < x1.getRows(); i++)
150 x1[i] = AtA[i][imin];
156 for (
unsigned int i = 0; i < 3; i++)
158 for (
unsigned int i = 0; i < 9; i++)
164 for (
unsigned int i = 0; i < 12; i++)
167 resul[0] = sol[3] * sol[0] + sol[4] * sol[1] + sol[5] * sol[2];
169 resul[1] = sol[6] * sol[0] + sol[7] * sol[1] + sol[8] * sol[2];
171 resul[2] = sqrt(sol[3] * sol[3] + sol[4] * sol[4] + sol[5] * sol[5]
172 - resul[0] * resul[0]);
177 resul[3] = sqrt(sol[6] * sol[6] + sol[7] * sol[7] + sol[8] * sol[8]
178 - resul[1] * resul[1]);
183 resul[4] = (sol[9] - sol[11] * resul[0]) / resul[2];
184 resul[5] = (sol[10] - sol[11] * resul[1]) / resul[3];
189 for (
unsigned int i = 0; i < 3; i++)
190 rd[0][i] = (sol[i + 3] - sol[i] * resul[0]) / resul[2];
191 for (
unsigned int i = 0; i < 3; i++)
192 rd[1][i] = (sol[i + 6] - sol[i] * resul[1]) / resul[3];
193 for (
unsigned int i = 0; i < 3; i++)
199 for (
unsigned int i = 0; i < 3; i++) {
200 for (
unsigned int j = 0; j < 3; j++)
201 cMo_est[i][j] = rd[i][j];
203 for (
unsigned int i = 0; i < 3; i++)
204 cMo_est[i][3] = resul[i + 4];
209 double deviation, deviation_dist;
215 std::ios::fmtflags original_flags(std::cout.flags());
216 std::cout.precision(10);
217 unsigned int n_points = npt;
230 std::list<double>::const_iterator it_LoX = LoX.begin();
231 std::list<double>::const_iterator it_LoY = LoY.begin();
232 std::list<double>::const_iterator it_LoZ = LoZ.begin();
233 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
235 for (
unsigned int i = 0; i < n_points; i++) {
252 unsigned int iter = 0;
254 double residu_1 = 1e12;
256 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
268 double u0 = cam_est.
get_u0();
269 double v0 = cam_est.
get_v0();
273 for (
unsigned int i = 0; i < n_points; i++) {
274 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
275 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
276 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
279 Pd[2 * i + 1] = v[i];
281 P[2 * i] = cX[i] / cZ[i] * px + u0;
282 P[2 * i + 1] = cY[i] / cZ[i] * py + v0;
292 for (
unsigned int i = 0; i < n_points; i++) {
296 double inv_z = 1 / z;
298 double X = x * inv_z;
299 double Y = y * inv_z;
303 L[2 * i][0] = px * (-inv_z);
305 L[2 * i][2] = px * X * inv_z;
306 L[2 * i][3] = px * X * Y;
307 L[2 * i][4] = -px * (1 + X * X);
308 L[2 * i][5] = px * Y;
324 L[2 * i + 1][1] = py * (-inv_z);
325 L[2 * i + 1][2] = py * (Y * inv_z);
326 L[2 * i + 1][3] = py * (1 + Y * Y);
327 L[2 * i + 1][4] = -py * X * Y;
328 L[2 * i + 1][5] = -py * X;
342 Lp = L.pseudoInverse(1e-10);
351 for (
unsigned int i = 0; i < 6; i++)
362 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
364 if (iter == nbIterMax) {
365 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
371 this->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].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].LoX.begin();
411 std::list<double>::const_iterator it_LoY = table_cal[p].LoY.begin();
412 std::list<double>::const_iterator it_LoZ = table_cal[p].LoZ.begin();
413 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].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, threshold) ==
false && iter < nbIterMax) {
443 if (aspect_ratio > 0.) {
445 py = px / aspect_ratio;
450 double u0 = cam_est.
get_u0();
451 double v0 = cam_est.
get_v0();
455 for (
unsigned int p = 0; p < nbPose; p++) {
457 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
458 unsigned int curPoint2 = 2 * curPoint;
461 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
463 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
465 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
467 Pd[curPoint2] = u[curPoint];
468 Pd[curPoint2 + 1] = v[curPoint];
470 P[curPoint2] = cX[curPoint] / cZ[curPoint] * px + u0;
471 P[curPoint2 + 1] = cY[curPoint] / cZ[curPoint] * py + v0;
482 vpMatrix L(nbPointTotal * 2, nbPose6 + 3 + (aspect_ratio > 0. ? 0 : 1));
484 for (
unsigned int p = 0; p < nbPose; p++) {
485 unsigned int q = 6 * p;
486 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
487 unsigned int curPoint2 = 2 * curPoint;
488 unsigned int curPoint21 = curPoint2 + 1;
490 double x = cX[curPoint];
491 double y = cY[curPoint];
492 double z = cZ[curPoint];
494 double inv_z = 1 / z;
496 double X = x * inv_z;
497 double Y = y * inv_z;
502 L[curPoint2][q] = px * (-inv_z);
503 L[curPoint2][q + 1] = 0;
504 L[curPoint2][q + 2] = px * (X * inv_z);
505 L[curPoint2][q + 3] = px * X * Y;
506 L[curPoint2][q + 4] = -px * (1 + X * X);
507 L[curPoint2][q + 5] = px * Y;
510 L[curPoint2][nbPose6] = 1;
511 L[curPoint2][nbPose6 + 1] = 0;
512 if (aspect_ratio > 0.) {
513 L[curPoint2][nbPose6 + 2] = X;
515 L[curPoint2][nbPose6 + 2] = X;
516 L[curPoint2][nbPose6 + 3] = 0;
520 L[curPoint21][q] = 0;
521 L[curPoint21][q + 1] = py * (-inv_z);
522 L[curPoint21][q + 2] = py * (Y * inv_z);
523 L[curPoint21][q + 3] = py * (1 + Y * Y);
524 L[curPoint21][q + 4] = -py * X * Y;
525 L[curPoint21][q + 5] = -py * X;
528 L[curPoint21][nbPose6] = 0;
529 L[curPoint21][nbPose6 + 1] = 1;
530 if (aspect_ratio > 0.) {
531 L[curPoint21][nbPose6 + 2] = Y;
533 L[curPoint21][nbPose6 + 2] = 0;
534 L[curPoint21][nbPose6 + 3] = Y;
542 Lp = L.pseudoInverse(1e-10);
551 for (
unsigned int i = 0; i < nbPose6; i++)
554 if (aspect_ratio > 0.) {
556 u0 + Tc[nbPose6], v0 + Tc[nbPose6 + 1]);
560 v0 + Tc[nbPose6 + 1]);
566 for (
unsigned int p = 0; p < nbPose; p++) {
567 for (
unsigned int i = 0; i < 6; i++)
568 Tc_v_Tmp[i] = Tc_v[6 * p + i];
574 std::cout <<
" std dev " << sqrt(r / nbPointTotal) << std::endl;
576 if (iter == nbIterMax) {
577 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
580 for (
unsigned int p = 0; p < nbPose; p++) {
581 table_cal[p].cMo_dist = table_cal[p].cMo;
582 table_cal[p].cam = cam_est;
583 table_cal[p].cam_dist = cam_est;
584 double deviation, deviation_dist;
585 table_cal[p].computeStdDeviation(deviation, deviation_dist);
587 globalReprojectionError = sqrt(r / nbPointTotal);
589 std::cout.flags(original_flags);
594 std::ios::fmtflags original_flags(std::cout.flags());
595 std::cout.precision(10);
596 unsigned int n_points = npt;
607 std::list<double>::const_iterator it_LoX = LoX.begin();
608 std::list<double>::const_iterator it_LoY = LoY.begin();
609 std::list<double>::const_iterator it_LoZ = LoZ.begin();
610 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
614 for (
unsigned int i = 0; i < n_points; i++) {
630 unsigned int iter = 0;
632 double residu_1 = 1e12;
634 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
639 double u0 = cam_est.
get_u0();
640 double v0 = cam_est.
get_v0();
651 double inv_px = 1 / px;
652 double inv_py = 1 / py;
654 double kud = cam_est.
get_kud();
655 double kdu = cam_est.
get_kdu();
657 double k2ud = 2 * kud;
658 double k2du = 2 * kdu;
661 for (
unsigned int i = 0; i < n_points; i++) {
662 unsigned int i4 = 4 * i;
663 unsigned int i41 = 4 * i + 1;
664 unsigned int i42 = 4 * i + 2;
665 unsigned int i43 = 4 * i + 3;
667 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
668 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
669 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
674 double inv_z = 1 / z;
676 double X = x * inv_z;
677 double Y = y * inv_z;
689 double up0 = up - u0;
690 double vp0 =
vp - v0;
692 double xp0 = up0 * inv_px;
693 double xp02 = xp0 * xp0;
695 double yp0 = vp0 * inv_py;
696 double yp02 = yp0 * yp0;
698 double r2du = xp02 + yp02;
699 double kr2du = kdu * r2du;
701 P[i4] = u0 + px * X - kr2du * (up0);
702 P[i41] = v0 + py * Y - kr2du * (vp0);
704 double r2ud = X2 + Y2;
705 double kr2ud = 1 + kud * r2ud;
707 double Axx = px * (kr2ud + k2ud * X2);
708 double Axy = px * k2ud * XY;
709 double Ayy = py * (kr2ud + k2ud * Y2);
710 double Ayx = py * k2ud * XY;
715 P[i42] = u0 + px * X * kr2ud;
716 P[i43] = v0 + py * Y * kr2ud;
725 L[i4][0] = px * (-inv_z);
727 L[i4][2] = px * X * inv_z;
728 L[i4][3] = px * X * Y;
729 L[i4][4] = -px * (1 + X2);
733 L[i4][6] = 1 + kr2du + k2du * xp02;
734 L[i4][7] = k2du * up0 * yp0 * inv_py;
737 L[i4][8] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
738 L[i4][9] = -(up0) * (r2du);
742 L[i4][8] = X + k2du * xp02 * xp0;
743 L[i4][9] = k2du * up0 * yp02 * inv_py;
744 L[i4][10] = -(up0) * (r2du);
750 L[i41][1] = py * (-inv_z);
751 L[i41][2] = py * Y * inv_z;
752 L[i41][3] = py * (1 + Y2);
753 L[i41][4] = -py * XY;
757 L[i41][6] = k2du * xp0 * vp0 * inv_px;
758 L[i41][7] = 1 + kr2du + k2du * yp02;
760 L[i41][8] = k2du * vp0 * xp02 * inv_px + Y + k2du * yp02 * yp0;
761 L[i41][9] = -vp0 * r2du;
765 L[i41][8] = k2du * vp0 * xp02 * inv_px;
766 L[i41][9] = Y + k2du * yp02 * yp0;
767 L[i41][10] = -vp0 * r2du;
773 L[i42][0] = Axx * (-inv_z);
774 L[i42][1] = Axy * (-inv_z);
775 L[i42][2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
776 L[i42][3] = Axx * X * Y + Axy * (1 + Y2);
777 L[i42][4] = -Axx * (1 + X2) - Axy * XY;
778 L[i42][5] = Axx * Y - Axy * X;
784 L[i42][8] = X * kr2ud;
786 L[i42][10] = px * X * r2ud;
789 L[i42][8] = X * kr2ud;
792 L[i42][11] = px * X * r2ud;
796 L[i43][0] = Ayx * (-inv_z);
797 L[i43][1] = Ayy * (-inv_z);
798 L[i43][2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
799 L[i43][3] = Ayx * XY + Ayy * (1 + Y2);
800 L[i43][4] = -Ayx * (1 + X2) - Ayy * XY;
801 L[i43][5] = Ayx * Y - Ayy * X;
807 L[i43][8] = Y * kr2ud;
809 L[i43][10] = py * Y * r2ud;
812 L[i43][9] = Y * kr2ud;
814 L[i43][11] = py * Y * r2ud;
825 Lp = L.pseudoInverse(1e-10);
833 for (
unsigned int i = 0; i < 6; i++)
838 kud + Tc[10], kdu + Tc[9]);
845 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
847 if (iter == nbIterMax) {
848 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
851 this->residual_dist = r;
856 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
859 std::cout.flags(original_flags);
862 void vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal,
vpCameraParameters &cam_est,
863 double &globalReprojectionError,
bool verbose,
double aspect_ratio)
865 std::ios::fmtflags original_flags(std::cout.flags());
866 std::cout.precision(10);
867 unsigned int nbPoint[1024];
868 unsigned int nbPointTotal = 0;
869 unsigned int nbPose = (
unsigned int)table_cal.size();
870 unsigned int nbPose6 = 6 * nbPose;
871 for (
unsigned int i = 0; i < nbPose; i++) {
872 nbPoint[i] = table_cal[i].npt;
873 nbPointTotal += nbPoint[i];
876 if (nbPointTotal < 4) {
891 unsigned int curPoint = 0;
892 for (
unsigned int p = 0; p < nbPose; p++) {
893 std::list<double>::const_iterator it_LoX = table_cal[p].LoX.begin();
894 std::list<double>::const_iterator it_LoY = table_cal[p].LoY.begin();
895 std::list<double>::const_iterator it_LoZ = table_cal[p].LoZ.begin();
896 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].Lip.begin();
898 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
899 oX[curPoint] = *it_LoX;
900 oY[curPoint] = *it_LoY;
901 oZ[curPoint] = *it_LoZ;
904 u[curPoint] = ip.
get_u();
905 v[curPoint] = ip.
get_v();
915 unsigned int iter = 0;
917 double residu_1 = 1e12;
919 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
925 for (
unsigned int p = 0; p < nbPose; p++) {
927 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
929 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
931 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
933 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
939 vpMatrix L(nbPointTotal * 4, nbPose6 + 5 + (aspect_ratio > 0. ? 0 : 1));
942 if (aspect_ratio > 0.) {
944 py = px / aspect_ratio;
949 double u0 = cam_est.
get_u0();
950 double v0 = cam_est.
get_v0();
952 double inv_px = 1 / px;
953 double inv_py = 1 / py;
955 double kud = cam_est.
get_kud();
956 double kdu = cam_est.
get_kdu();
958 double k2ud = 2 * kud;
959 double k2du = 2 * kdu;
961 for (
unsigned int p = 0; p < nbPose; p++) {
962 unsigned int q = 6 * p;
963 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
964 unsigned int curPoint4 = 4 * curPoint;
965 double x = cX[curPoint];
966 double y = cY[curPoint];
967 double z = cZ[curPoint];
969 double inv_z = 1 / z;
970 double X = x * inv_z;
971 double Y = y * inv_z;
977 double up = u[curPoint];
978 double vp = v[curPoint];
981 Pd[curPoint4 + 1] =
vp;
983 double up0 = up - u0;
984 double vp0 =
vp - v0;
986 double xp0 = up0 * inv_px;
987 double xp02 = xp0 * xp0;
989 double yp0 = vp0 * inv_py;
990 double yp02 = yp0 * yp0;
992 double r2du = xp02 + yp02;
993 double kr2du = kdu * r2du;
995 P[curPoint4] = u0 + px * X - kr2du * (up0);
996 P[curPoint4 + 1] = v0 + py * Y - kr2du * (vp0);
998 double r2ud = X2 + Y2;
999 double kr2ud = 1 + kud * r2ud;
1001 double Axx = px * (kr2ud + k2ud * X2);
1002 double Axy = px * k2ud * XY;
1003 double Ayy = py * (kr2ud + k2ud * Y2);
1004 double Ayx = py * k2ud * XY;
1006 Pd[curPoint4 + 2] = up;
1007 Pd[curPoint4 + 3] =
vp;
1009 P[curPoint4 + 2] = u0 + px * X * kr2ud;
1010 P[curPoint4 + 3] = v0 + py * Y * kr2ud;
1016 unsigned int curInd = curPoint4;
1020 L[curInd][q] = px * (-inv_z);
1021 L[curInd][q + 1] = 0;
1022 L[curInd][q + 2] = px * X * inv_z;
1023 L[curInd][q + 3] = px * X * Y;
1024 L[curInd][q + 4] = -px * (1 + X2);
1025 L[curInd][q + 5] = px * Y;
1028 L[curInd][nbPose6] = 1 + kr2du + k2du * xp02;
1029 L[curInd][nbPose6 + 1] = k2du * up0 * yp0 * inv_py;
1030 if (aspect_ratio > 0.) {
1031 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
1032 L[curInd][nbPose6 + 3] = -(up0) * (r2du);
1033 L[curInd][nbPose6 + 4] = 0;
1035 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0;
1036 L[curInd][nbPose6 + 3] = k2du * up0 * yp02 * inv_py;
1037 L[curInd][nbPose6 + 4] = -(up0) * (r2du);
1038 L[curInd][nbPose6 + 5] = 0;
1044 L[curInd][q + 1] = py * (-inv_z);
1045 L[curInd][q + 2] = py * Y * inv_z;
1046 L[curInd][q + 3] = py * (1 + Y2);
1047 L[curInd][q + 4] = -py * XY;
1048 L[curInd][q + 5] = -py * X;
1051 L[curInd][nbPose6] = k2du * xp0 * vp0 * inv_px;
1052 L[curInd][nbPose6 + 1] = 1 + kr2du + k2du * yp02;
1053 if (aspect_ratio > 0.) {
1054 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px + Y + k2du * yp02 * yp0;
1055 L[curInd][nbPose6 + 3] = -vp0 * r2du;
1056 L[curInd][nbPose6 + 4] = 0;
1058 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px;
1059 L[curInd][nbPose6 + 3] = Y + k2du * yp02 * yp0;
1060 L[curInd][nbPose6 + 4] = -vp0 * r2du;
1061 L[curInd][nbPose6 + 5] = 0;
1067 L[curInd][q] = Axx * (-inv_z);
1068 L[curInd][q + 1] = Axy * (-inv_z);
1069 L[curInd][q + 2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
1070 L[curInd][q + 3] = Axx * X * Y + Axy * (1 + Y2);
1071 L[curInd][q + 4] = -Axx * (1 + X2) - Axy * XY;
1072 L[curInd][q + 5] = Axx * Y - Axy * X;
1075 L[curInd][nbPose6] = 1;
1076 L[curInd][nbPose6 + 1] = 0;
1077 if (aspect_ratio > 0.) {
1078 L[curInd][nbPose6 + 2] = X * kr2ud;
1079 L[curInd][nbPose6 + 3] = 0;
1080 L[curInd][nbPose6 + 4] = px * X * r2ud;
1082 L[curInd][nbPose6 + 2] = X * kr2ud;
1083 L[curInd][nbPose6 + 3] = 0;
1084 L[curInd][nbPose6 + 4] = 0;
1085 L[curInd][nbPose6 + 5] = px * X * r2ud;
1090 L[curInd][q] = Ayx * (-inv_z);
1091 L[curInd][q + 1] = Ayy * (-inv_z);
1092 L[curInd][q + 2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
1093 L[curInd][q + 3] = Ayx * XY + Ayy * (1 + Y2);
1094 L[curInd][q + 4] = -Ayx * (1 + X2) - Ayy * XY;
1095 L[curInd][q + 5] = Ayx * Y - Ayy * X;
1098 L[curInd][nbPose6] = 0;
1099 L[curInd][nbPose6 + 1] = 1;
1100 if (aspect_ratio > 0.) {
1101 L[curInd][nbPose6 + 2] = Y * kr2ud;
1102 L[curInd][nbPose6 + 3] = 0;
1103 L[curInd][nbPose6 + 4] = py * Y * r2ud;
1105 L[curInd][nbPose6 + 2] = 0;
1106 L[curInd][nbPose6 + 3] = Y * kr2ud;
1107 L[curInd][nbPose6 + 4] = 0;
1108 L[curInd][nbPose6 + 5] = py * Y * r2ud;
1122 L.pseudoInverse(Lp, 1e-10);
1127 for (
unsigned int i = 0; i < 6 * nbPose; i++)
1130 if (aspect_ratio > 0.) {
1132 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 4], kdu + Tc[nbPose6 + 3]);
1135 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 5], kdu + Tc[nbPose6 + 4]);
1139 for (
unsigned int p = 0; p < nbPose; p++) {
1140 for (
unsigned int i = 0; i < 6; i++)
1141 Tc_v_Tmp[i] = Tc_v[6 * p + i];
1146 std::cout <<
" std dev: " << sqrt(r / nbPointTotal) << std::endl;
1149 if (iter == nbIterMax) {
1150 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
1157 for (
unsigned int p = 0; p < nbPose; p++) {
1158 table_cal[p].cam_dist = cam_est;
1160 table_cal[p].computeStdDeviation_dist(table_cal[p].
cMo_dist, cam_est);
1164 globalReprojectionError = sqrt(r / (nbPointTotal));
1167 std::cout <<
" Global std dev " << globalReprojectionError << std::endl;
1170 std::cout.flags(original_flags);
1174 bool verbose,
double aspect_ratio)
1176 std::vector<vpCalibration> v_table_cal(nbPose);
1177 double globalReprojectionError = 0;
1178 for (
unsigned int i = 0; i < nbPose; i++) {
1179 v_table_cal[i] = table_cal[i];
1182 calibVVSMulti(v_table_cal, cam_est, globalReprojectionError, verbose, aspect_ratio);
1184 for (
unsigned int i = 0; i < nbPose; i++) {
1185 table_cal[i] = v_table_cal[i];
1189 void vpCalibration::calibVVSWithDistortionMulti(
unsigned int nbPose,
vpCalibration table_cal[],
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 calibVVSWithDistortionMulti(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 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1207 #include <visp3/vision/vpHandEyeCalibration.h>
1249 unsigned int nbPose = (
unsigned int)table_cal.size();
1251 std::vector<vpHomogeneousMatrix> table_cMo(nbPose);
1252 std::vector<vpHomogeneousMatrix> table_cMo_dist(nbPose);
1253 std::vector<vpHomogeneousMatrix> table_rMe(nbPose);
1255 for (
unsigned int i = 0; i < nbPose; i++) {
1256 table_cMo[i] = table_cal[i].cMo;
1257 table_cMo_dist[i] = table_cal[i].cMo_dist;
1258 table_rMe[i] = table_cal[i].rMe;
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)
static vp_deprecated int computeCalibrationTsai(const std::vector< vpCalibration > &table_cal, vpHomogeneousMatrix &eMc, vpHomogeneousMatrix &eMc_dist)
vpHomogeneousMatrix eMc_dist
static vp_deprecated void calibrationTsai(const std::vector< vpHomogeneousMatrix > &cMo, const std::vector< vpHomogeneousMatrix > &rMe, vpHomogeneousMatrix &eMc)
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.
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static vpHomogeneousMatrix direct(const vpColVector &v)
static int calibrate(const std::vector< vpHomogeneousMatrix > &cMo, const std::vector< vpHomogeneousMatrix > &rMe, vpHomogeneousMatrix &eMc)
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