40 #include <visp3/core/vpMath.h> 41 #include <visp3/core/vpPixelMeterConversion.h> 42 #include <visp3/vision/vpCalibration.h> 43 #include <visp3/vision/vpPose.h> 48 #define DEBUG_LEVEL1 0 49 #define DEBUG_LEVEL2 0 60 std::list<double>::const_iterator it_LoX = LoX.begin();
61 std::list<double>::const_iterator it_LoY = LoY.begin();
62 std::list<double>::const_iterator it_LoZ = LoZ.begin();
63 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
67 for (
unsigned int i = 0; i < npt; i++) {
75 double xi = ip.
get_u();
76 double yi = ip.
get_v();
78 A[2 * i][0] = x0 * xi;
79 A[2 * i][1] = y0 * xi;
80 A[2 * i][2] = z0 * xi;
90 A[2 * i + 1][0] = x0 * yi;
91 A[2 * i + 1][1] = y0 * yi;
92 A[2 * i + 1][2] = z0 * yi;
93 B[2 * i + 1][0] = 0.0;
94 B[2 * i + 1][1] = 0.0;
95 B[2 * i + 1][2] = 0.0;
96 B[2 * i + 1][3] = -x0;
97 B[2 * i + 1][4] = -y0;
98 B[2 * i + 1][5] = -z0;
99 B[2 * i + 1][6] = 0.0;
100 B[2 * i + 1][7] = -1.0;
101 B[2 * i + 1][8] = yi;
126 e = -(A.t() * B) * r;
140 unsigned int imin = 1;
141 for (
unsigned int i = 0; i < x1.getRows(); i++) {
150 for (
unsigned int i = 0; i < x1.getRows(); i++) {
151 if (x1[i] < x1[imin])
155 for (
unsigned int i = 0; i < x1.getRows(); i++)
156 x1[i] = AtA[i][imin];
162 for (
unsigned int i = 0; i < 3; i++)
164 for (
unsigned int i = 0; i < 9; i++)
170 for (
unsigned int i = 0; i < 12; i++)
173 resul[0] = sol[3] * sol[0] + sol[4] * sol[1] + sol[5] * sol[2];
175 resul[1] = sol[6] * sol[0] + sol[7] * sol[1] + sol[8] * sol[2];
177 resul[2] = sqrt(sol[3] * sol[3] + sol[4] * sol[4] + sol[5] * sol[5]
178 - resul[0] * resul[0]);
183 resul[3] = sqrt(sol[6] * sol[6] + sol[7] * sol[7] + sol[8] * sol[8]
184 - resul[1] * resul[1]);
189 resul[4] = (sol[9] - sol[11] * resul[0]) / resul[2];
190 resul[5] = (sol[10] - sol[11] * resul[1]) / resul[3];
195 for (
unsigned int i = 0; i < 3; i++)
196 rd[0][i] = (sol[i + 3] - sol[i] * resul[0]) / resul[2];
197 for (
unsigned int i = 0; i < 3; i++)
198 rd[1][i] = (sol[i + 6] - sol[i] * resul[1]) / resul[3];
199 for (
unsigned int i = 0; i < 3; i++)
205 for (
unsigned int i = 0; i < 3; i++) {
206 for (
unsigned int j = 0; j < 3; j++)
207 cMo_est[i][j] = rd[i][j];
209 for (
unsigned int i = 0; i < 3; i++)
210 cMo_est[i][3] = resul[i + 4];
215 double deviation, deviation_dist;
221 std::ios::fmtflags original_flags(std::cout.flags());
222 std::cout.precision(10);
223 unsigned int n_points = npt;
236 std::list<double>::const_iterator it_LoX = LoX.begin();
237 std::list<double>::const_iterator it_LoY = LoY.begin();
238 std::list<double>::const_iterator it_LoZ = LoZ.begin();
239 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
241 for (
unsigned int i = 0; i < n_points; i++) {
258 unsigned int iter = 0;
260 double residu_1 = 1e12;
262 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
274 double u0 = cam_est.
get_u0();
275 double v0 = cam_est.
get_v0();
279 for (
unsigned int i = 0; i < n_points; i++) {
280 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
281 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
282 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
285 Pd[2 * i + 1] = v[i];
287 P[2 * i] = cX[i] / cZ[i] * px + u0;
288 P[2 * i + 1] = cY[i] / cZ[i] * py + v0;
298 for (
unsigned int i = 0; i < n_points; i++) {
302 double inv_z = 1 / z;
304 double X = x * inv_z;
305 double Y = y * inv_z;
309 L[2 * i][0] = px * (-inv_z);
311 L[2 * i][2] = px * X * inv_z;
312 L[2 * i][3] = px * X * Y;
313 L[2 * i][4] = -px * (1 + X * X);
314 L[2 * i][5] = px * Y;
330 L[2 * i + 1][1] = py * (-inv_z);
331 L[2 * i + 1][2] = py * (Y * inv_z);
332 L[2 * i + 1][3] = py * (1 + Y * Y);
333 L[2 * i + 1][4] = -py * X * Y;
334 L[2 * i + 1][5] = -py * X;
348 Lp = L.pseudoInverse(1e-10);
357 for (
unsigned int i = 0; i < 6; i++)
368 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
370 if (iter == nbIterMax) {
371 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
377 this->residual_dist = r;
379 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
381 std::cout.flags(original_flags);
384 void vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal,
vpCameraParameters &cam_est,
385 double &globalReprojectionError,
bool verbose,
double aspect_ratio)
387 std::ios::fmtflags original_flags(std::cout.flags());
388 std::cout.precision(10);
389 unsigned int nbPoint[256];
390 unsigned int nbPointTotal = 0;
391 unsigned int nbPose = (
unsigned int)table_cal.size();
392 unsigned int nbPose6 = 6 * nbPose;
394 for (
unsigned int i = 0; i < nbPose; i++) {
395 nbPoint[i] = table_cal[i].npt;
396 nbPointTotal += nbPoint[i];
399 if (nbPointTotal < 4) {
414 unsigned int curPoint = 0;
415 for (
unsigned int p = 0; p < nbPose; p++) {
416 std::list<double>::const_iterator it_LoX = table_cal[p].LoX.begin();
417 std::list<double>::const_iterator it_LoY = table_cal[p].LoY.begin();
418 std::list<double>::const_iterator it_LoZ = table_cal[p].LoZ.begin();
419 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].Lip.begin();
421 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
422 oX[curPoint] = *it_LoX;
423 oY[curPoint] = *it_LoY;
424 oZ[curPoint] = *it_LoZ;
427 u[curPoint] = ip.
get_u();
428 v[curPoint] = ip.
get_v();
439 unsigned int iter = 0;
441 double residu_1 = 1e12;
443 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
449 if (aspect_ratio > 0.) {
451 py = px / aspect_ratio;
456 double u0 = cam_est.
get_u0();
457 double v0 = cam_est.
get_v0();
461 for (
unsigned int p = 0; p < nbPose; p++) {
463 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
464 unsigned int curPoint2 = 2 * curPoint;
467 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
469 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
471 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
473 Pd[curPoint2] = u[curPoint];
474 Pd[curPoint2 + 1] = v[curPoint];
476 P[curPoint2] = cX[curPoint] / cZ[curPoint] * px + u0;
477 P[curPoint2 + 1] = cY[curPoint] / cZ[curPoint] * py + v0;
488 vpMatrix L(nbPointTotal * 2, nbPose6 + 3 + (aspect_ratio > 0. ? 0 : 1));
490 for (
unsigned int p = 0; p < nbPose; p++) {
491 unsigned int q = 6 * p;
492 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
493 unsigned int curPoint2 = 2 * curPoint;
494 unsigned int curPoint21 = curPoint2 + 1;
496 double x = cX[curPoint];
497 double y = cY[curPoint];
498 double z = cZ[curPoint];
500 double inv_z = 1 / z;
502 double X = x * inv_z;
503 double Y = y * inv_z;
508 L[curPoint2][q] = px * (-inv_z);
509 L[curPoint2][q + 1] = 0;
510 L[curPoint2][q + 2] = px * (X * inv_z);
511 L[curPoint2][q + 3] = px * X * Y;
512 L[curPoint2][q + 4] = -px * (1 + X * X);
513 L[curPoint2][q + 5] = px * Y;
516 L[curPoint2][nbPose6] = 1;
517 L[curPoint2][nbPose6 + 1] = 0;
518 if (aspect_ratio > 0.) {
519 L[curPoint2][nbPose6 + 2] = X;
521 L[curPoint2][nbPose6 + 2] = X;
522 L[curPoint2][nbPose6 + 3] = 0;
526 L[curPoint21][q] = 0;
527 L[curPoint21][q + 1] = py * (-inv_z);
528 L[curPoint21][q + 2] = py * (Y * inv_z);
529 L[curPoint21][q + 3] = py * (1 + Y * Y);
530 L[curPoint21][q + 4] = -py * X * Y;
531 L[curPoint21][q + 5] = -py * X;
534 L[curPoint21][nbPose6] = 0;
535 L[curPoint21][nbPose6 + 1] = 1;
536 if (aspect_ratio > 0.) {
537 L[curPoint21][nbPose6 + 2] = Y;
539 L[curPoint21][nbPose6 + 2] = 0;
540 L[curPoint21][nbPose6 + 3] = Y;
548 Lp = L.pseudoInverse(1e-10);
557 for (
unsigned int i = 0; i < nbPose6; i++)
560 if (aspect_ratio > 0.) {
562 u0 + Tc[nbPose6], v0 + Tc[nbPose6 + 1]);
566 v0 + Tc[nbPose6 + 1]);
572 for (
unsigned int p = 0; p < nbPose; p++) {
573 for (
unsigned int i = 0; i < 6; i++)
574 Tc_v_Tmp[i] = Tc_v[6 * p + i];
580 std::cout <<
" std dev " << sqrt(r / nbPointTotal) << std::endl;
582 if (iter == nbIterMax) {
583 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
586 for (
unsigned int p = 0; p < nbPose; p++) {
587 table_cal[p].cMo_dist = table_cal[p].cMo;
588 table_cal[p].cam = cam_est;
589 table_cal[p].cam_dist = cam_est;
590 double deviation, deviation_dist;
591 table_cal[p].computeStdDeviation(deviation, deviation_dist);
593 globalReprojectionError = sqrt(r / nbPointTotal);
595 std::cout.flags(original_flags);
600 std::ios::fmtflags original_flags(std::cout.flags());
601 std::cout.precision(10);
602 unsigned int n_points = npt;
613 std::list<double>::const_iterator it_LoX = LoX.begin();
614 std::list<double>::const_iterator it_LoY = LoY.begin();
615 std::list<double>::const_iterator it_LoZ = LoZ.begin();
616 std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();
620 for (
unsigned int i = 0; i < n_points; i++) {
636 unsigned int iter = 0;
638 double residu_1 = 1e12;
640 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
645 double u0 = cam_est.
get_u0();
646 double v0 = cam_est.
get_v0();
657 double inv_px = 1 / px;
658 double inv_py = 1 / py;
660 double kud = cam_est.
get_kud();
661 double kdu = cam_est.
get_kdu();
663 double k2ud = 2 * kud;
664 double k2du = 2 * kdu;
667 for (
unsigned int i = 0; i < n_points; i++) {
668 unsigned int i4 = 4 * i;
669 unsigned int i41 = 4 * i + 1;
670 unsigned int i42 = 4 * i + 2;
671 unsigned int i43 = 4 * i + 3;
673 cX[i] = oX[i] * cMo_est[0][0] + oY[i] * cMo_est[0][1] + oZ[i] * cMo_est[0][2] + cMo_est[0][3];
674 cY[i] = oX[i] * cMo_est[1][0] + oY[i] * cMo_est[1][1] + oZ[i] * cMo_est[1][2] + cMo_est[1][3];
675 cZ[i] = oX[i] * cMo_est[2][0] + oY[i] * cMo_est[2][1] + oZ[i] * cMo_est[2][2] + cMo_est[2][3];
680 double inv_z = 1 / z;
682 double X = x * inv_z;
683 double Y = y * inv_z;
695 double up0 = up - u0;
696 double vp0 = vp - v0;
698 double xp0 = up0 * inv_px;
699 double xp02 = xp0 * xp0;
701 double yp0 = vp0 * inv_py;
702 double yp02 = yp0 * yp0;
704 double r2du = xp02 + yp02;
705 double kr2du = kdu * r2du;
707 P[i4] = u0 + px * X - kr2du * (up0);
708 P[i41] = v0 + py * Y - kr2du * (vp0);
710 double r2ud = X2 + Y2;
711 double kr2ud = 1 + kud * r2ud;
713 double Axx = px * (kr2ud + k2ud * X2);
714 double Axy = px * k2ud * XY;
715 double Ayy = py * (kr2ud + k2ud * Y2);
716 double Ayx = py * k2ud * XY;
721 P[i42] = u0 + px * X * kr2ud;
722 P[i43] = v0 + py * Y * kr2ud;
731 L[i4][0] = px * (-inv_z);
733 L[i4][2] = px * X * inv_z;
734 L[i4][3] = px * X * Y;
735 L[i4][4] = -px * (1 + X2);
739 L[i4][6] = 1 + kr2du + k2du * xp02;
740 L[i4][7] = k2du * up0 * yp0 * inv_py;
743 L[i4][8] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
744 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;
771 L[i41][8] = k2du * vp0 * xp02 * inv_px;
772 L[i41][9] = Y + k2du * yp02 * yp0;
773 L[i41][10] = -vp0 * r2du;
779 L[i42][0] = Axx * (-inv_z);
780 L[i42][1] = Axy * (-inv_z);
781 L[i42][2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
782 L[i42][3] = Axx * X * Y + Axy * (1 + Y2);
783 L[i42][4] = -Axx * (1 + X2) - Axy * XY;
784 L[i42][5] = Axx * Y - Axy * X;
790 L[i42][8] = X * kr2ud;
792 L[i42][10] = px * X * r2ud;
795 L[i42][8] = X * kr2ud;
798 L[i42][11] = px * X * r2ud;
802 L[i43][0] = Ayx * (-inv_z);
803 L[i43][1] = Ayy * (-inv_z);
804 L[i43][2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
805 L[i43][3] = Ayx * XY + Ayy * (1 + Y2);
806 L[i43][4] = -Ayx * (1 + X2) - Ayy * XY;
807 L[i43][5] = Ayx * Y - Ayy * X;
813 L[i43][8] = Y * kr2ud;
815 L[i43][10] = py * Y * r2ud;
818 L[i43][9] = Y * kr2ud;
820 L[i43][11] = py * Y * r2ud;
831 Lp = L.pseudoInverse(1e-10);
839 for (
unsigned int i = 0; i < 6; i++)
844 kud + Tc[10], kdu + Tc[9]);
851 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
853 if (iter == nbIterMax) {
854 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
857 this->residual_dist = r;
862 std::cout <<
" std dev " << sqrt(r / n_points) << std::endl;
865 std::cout.flags(original_flags);
868 void vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal,
vpCameraParameters &cam_est,
869 double &globalReprojectionError,
bool verbose,
double aspect_ratio)
871 std::ios::fmtflags original_flags(std::cout.flags());
872 std::cout.precision(10);
873 unsigned int nbPoint[1024];
874 unsigned int nbPointTotal = 0;
875 unsigned int nbPose = (
unsigned int)table_cal.size();
876 unsigned int nbPose6 = 6 * nbPose;
877 for (
unsigned int i = 0; i < nbPose; i++) {
878 nbPoint[i] = table_cal[i].npt;
879 nbPointTotal += nbPoint[i];
882 if (nbPointTotal < 4) {
897 unsigned int curPoint = 0;
898 for (
unsigned int p = 0; p < nbPose; p++) {
899 std::list<double>::const_iterator it_LoX = table_cal[p].LoX.begin();
900 std::list<double>::const_iterator it_LoY = table_cal[p].LoY.begin();
901 std::list<double>::const_iterator it_LoZ = table_cal[p].LoZ.begin();
902 std::list<vpImagePoint>::const_iterator it_Lip = table_cal[p].Lip.begin();
904 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
905 oX[curPoint] = *it_LoX;
906 oY[curPoint] = *it_LoY;
907 oZ[curPoint] = *it_LoZ;
910 u[curPoint] = ip.
get_u();
911 v[curPoint] = ip.
get_v();
921 unsigned int iter = 0;
923 double residu_1 = 1e12;
925 while (
vpMath::equal(residu_1, r, threshold) ==
false && iter < nbIterMax) {
931 for (
unsigned int p = 0; p < nbPose; p++) {
933 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
935 oX[curPoint] * cMoTmp[0][0] + oY[curPoint] * cMoTmp[0][1] + oZ[curPoint] * cMoTmp[0][2] + cMoTmp[0][3];
937 oX[curPoint] * cMoTmp[1][0] + oY[curPoint] * cMoTmp[1][1] + oZ[curPoint] * cMoTmp[1][2] + cMoTmp[1][3];
939 oX[curPoint] * cMoTmp[2][0] + oY[curPoint] * cMoTmp[2][1] + oZ[curPoint] * cMoTmp[2][2] + cMoTmp[2][3];
945 vpMatrix L(nbPointTotal * 4, nbPose6 + 5 + (aspect_ratio > 0. ? 0 : 1));
948 if (aspect_ratio > 0.) {
950 py = px / aspect_ratio;
955 double u0 = cam_est.
get_u0();
956 double v0 = cam_est.
get_v0();
958 double inv_px = 1 / px;
959 double inv_py = 1 / py;
961 double kud = cam_est.
get_kud();
962 double kdu = cam_est.
get_kdu();
964 double k2ud = 2 * kud;
965 double k2du = 2 * kdu;
967 for (
unsigned int p = 0; p < nbPose; p++) {
968 unsigned int q = 6 * p;
969 for (
unsigned int i = 0; i < nbPoint[p]; i++) {
970 unsigned int curPoint4 = 4 * curPoint;
971 double x = cX[curPoint];
972 double y = cY[curPoint];
973 double z = cZ[curPoint];
975 double inv_z = 1 / z;
976 double X = x * inv_z;
977 double Y = y * inv_z;
983 double up = u[curPoint];
984 double vp = v[curPoint];
987 Pd[curPoint4 + 1] = vp;
989 double up0 = up - u0;
990 double vp0 = vp - v0;
992 double xp0 = up0 * inv_px;
993 double xp02 = xp0 * xp0;
995 double yp0 = vp0 * inv_py;
996 double yp02 = yp0 * yp0;
998 double r2du = xp02 + yp02;
999 double kr2du = kdu * r2du;
1001 P[curPoint4] = u0 + px * X - kr2du * (up0);
1002 P[curPoint4 + 1] = v0 + py * Y - kr2du * (vp0);
1004 double r2ud = X2 + Y2;
1005 double kr2ud = 1 + kud * r2ud;
1007 double Axx = px * (kr2ud + k2ud * X2);
1008 double Axy = px * k2ud * XY;
1009 double Ayy = py * (kr2ud + k2ud * Y2);
1010 double Ayx = py * k2ud * XY;
1012 Pd[curPoint4 + 2] = up;
1013 Pd[curPoint4 + 3] = vp;
1015 P[curPoint4 + 2] = u0 + px * X * kr2ud;
1016 P[curPoint4 + 3] = v0 + py * Y * kr2ud;
1022 unsigned int curInd = curPoint4;
1026 L[curInd][q] = px * (-inv_z);
1027 L[curInd][q + 1] = 0;
1028 L[curInd][q + 2] = px * X * inv_z;
1029 L[curInd][q + 3] = px * X * Y;
1030 L[curInd][q + 4] = -px * (1 + X2);
1031 L[curInd][q + 5] = px * Y;
1034 L[curInd][nbPose6] = 1 + kr2du + k2du * xp02;
1035 L[curInd][nbPose6 + 1] = k2du * up0 * yp0 * inv_py;
1036 if (aspect_ratio > 0.) {
1037 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0 + k2du * up0 * yp02 * inv_py;
1038 L[curInd][nbPose6 + 3] = -(up0) * (r2du);
1039 L[curInd][nbPose6 + 4] = 0;
1041 L[curInd][nbPose6 + 2] = X + k2du * xp02 * xp0;
1042 L[curInd][nbPose6 + 3] = k2du * up0 * yp02 * inv_py;
1043 L[curInd][nbPose6 + 4] = -(up0) * (r2du);
1044 L[curInd][nbPose6 + 5] = 0;
1050 L[curInd][q + 1] = py * (-inv_z);
1051 L[curInd][q + 2] = py * Y * inv_z;
1052 L[curInd][q + 3] = py * (1 + Y2);
1053 L[curInd][q + 4] = -py * XY;
1054 L[curInd][q + 5] = -py * X;
1057 L[curInd][nbPose6] = k2du * xp0 * vp0 * inv_px;
1058 L[curInd][nbPose6 + 1] = 1 + kr2du + k2du * yp02;
1059 if (aspect_ratio > 0.) {
1060 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px + Y + k2du * yp02 * yp0;
1061 L[curInd][nbPose6 + 3] = -vp0 * r2du;
1062 L[curInd][nbPose6 + 4] = 0;
1064 L[curInd][nbPose6 + 2] = k2du * vp0 * xp02 * inv_px;
1065 L[curInd][nbPose6 + 3] = Y + k2du * yp02 * yp0;
1066 L[curInd][nbPose6 + 4] = -vp0 * r2du;
1067 L[curInd][nbPose6 + 5] = 0;
1073 L[curInd][q] = Axx * (-inv_z);
1074 L[curInd][q + 1] = Axy * (-inv_z);
1075 L[curInd][q + 2] = Axx * (X * inv_z) + Axy * (Y * inv_z);
1076 L[curInd][q + 3] = Axx * X * Y + Axy * (1 + Y2);
1077 L[curInd][q + 4] = -Axx * (1 + X2) - Axy * XY;
1078 L[curInd][q + 5] = Axx * Y - Axy * X;
1081 L[curInd][nbPose6] = 1;
1082 L[curInd][nbPose6 + 1] = 0;
1083 if (aspect_ratio > 0.) {
1084 L[curInd][nbPose6 + 2] = X * kr2ud;
1085 L[curInd][nbPose6 + 3] = 0;
1086 L[curInd][nbPose6 + 4] = px * X * r2ud;
1088 L[curInd][nbPose6 + 2] = X * kr2ud;
1089 L[curInd][nbPose6 + 3] = 0;
1090 L[curInd][nbPose6 + 4] = 0;
1091 L[curInd][nbPose6 + 5] = px * X * r2ud;
1096 L[curInd][q] = Ayx * (-inv_z);
1097 L[curInd][q + 1] = Ayy * (-inv_z);
1098 L[curInd][q + 2] = Ayx * (X * inv_z) + Ayy * (Y * inv_z);
1099 L[curInd][q + 3] = Ayx * XY + Ayy * (1 + Y2);
1100 L[curInd][q + 4] = -Ayx * (1 + X2) - Ayy * XY;
1101 L[curInd][q + 5] = Ayx * Y - Ayy * X;
1104 L[curInd][nbPose6] = 0;
1105 L[curInd][nbPose6 + 1] = 1;
1106 if (aspect_ratio > 0.) {
1107 L[curInd][nbPose6 + 2] = Y * kr2ud;
1108 L[curInd][nbPose6 + 3] = 0;
1109 L[curInd][nbPose6 + 4] = py * Y * r2ud;
1111 L[curInd][nbPose6 + 2] = 0;
1112 L[curInd][nbPose6 + 3] = Y * kr2ud;
1113 L[curInd][nbPose6 + 4] = 0;
1114 L[curInd][nbPose6 + 5] = py * Y * r2ud;
1128 L.pseudoInverse(Lp, 1e-10);
1133 for (
unsigned int i = 0; i < 6 * nbPose; i++)
1136 if (aspect_ratio > 0.) {
1138 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 4], kdu + Tc[nbPose6 + 3]);
1141 v0 + Tc[nbPose6 + 1], kud + Tc[nbPose6 + 5], kdu + Tc[nbPose6 + 4]);
1145 for (
unsigned int p = 0; p < nbPose; p++) {
1146 for (
unsigned int i = 0; i < 6; i++)
1147 Tc_v_Tmp[i] = Tc_v[6 * p + i];
1152 std::cout <<
" std dev: " << sqrt(r / nbPointTotal) << std::endl;
1155 if (iter == nbIterMax) {
1156 vpERROR_TRACE(
"Iterations number exceed the maximum allowed (%d)", nbIterMax);
1163 for (
unsigned int p = 0; p < nbPose; p++) {
1164 table_cal[p].cam_dist = cam_est;
1166 table_cal[p].computeStdDeviation_dist(table_cal[p].
cMo_dist, cam_est);
1170 globalReprojectionError = sqrt(r / (nbPointTotal));
1173 std::cout <<
" Global std dev " << globalReprojectionError << std::endl;
1176 std::cout.flags(original_flags);
1180 bool verbose,
double aspect_ratio)
1182 std::vector<vpCalibration> v_table_cal(nbPose);
1183 double globalReprojectionError = 0;
1184 for (
unsigned int i = 0; i < nbPose; i++) {
1185 v_table_cal[i] = table_cal[i];
1188 calibVVSMulti(v_table_cal, cam_est, globalReprojectionError, verbose, aspect_ratio);
1190 for (
unsigned int i = 0; i < nbPose; i++) {
1191 table_cal[i] = v_table_cal[i];
1195 void vpCalibration::calibVVSWithDistortionMulti(
unsigned int nbPose,
vpCalibration table_cal[],
1198 std::vector<vpCalibration> v_table_cal(nbPose);
1199 double globalReprojectionError = 0;
1200 for (
unsigned int i = 0; i < nbPose; i++) {
1201 v_table_cal[i] = table_cal[i];
1204 calibVVSWithDistortionMulti(v_table_cal, cam_est, globalReprojectionError, verbose, aspect_ratio);
1206 for (
unsigned int i = 0; i < nbPose; i++) {
1207 table_cal[i] = v_table_cal[i];
1211 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 1213 #include <visp3/vision/vpHandEyeCalibration.h> 1255 unsigned int nbPose = (
unsigned int)table_cal.size();
1257 std::vector<vpHomogeneousMatrix> table_cMo(nbPose);
1258 std::vector<vpHomogeneousMatrix> table_cMo_dist(nbPose);
1259 std::vector<vpHomogeneousMatrix> table_rMe(nbPose);
1261 for (
unsigned int i = 0; i < nbPose; i++) {
1262 table_cMo[i] = table_cal[i].cMo;
1263 table_cMo_dist[i] = table_cal[i].cMo_dist;
1264 table_rMe[i] = table_cal[i].rMe;
1275 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) void svd(vpColVector &w, vpMatrix &V)
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Error that can be emited by the vpCalibration class.
double m_aspect_ratio
Fix aspect ratio (px/py)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static int calibrate(const std::vector< vpHomogeneousMatrix > &cMo, const std::vector< vpHomogeneousMatrix > &rMe, vpHomogeneousMatrix &eMc)
static bool equal(double x, double y, double s=0.001)
error that can be emited by ViSP classes.
vpHomogeneousMatrix inverse() const
Tools for perspective camera calibration.
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
vpHomogeneousMatrix cMo
(as a 3x4 matrix [R T])
something is not initialized
static vp_deprecated int computeCalibrationTsai(const std::vector< vpCalibration > &table_cal, vpHomogeneousMatrix &eMc, vpHomogeneousMatrix &eMc_dist)
static double sqr(double x)
vpHomogeneousMatrix cMo_dist
Generic class defining intrinsic camera parameters.
vpHomogeneousMatrix eMc_dist
Position of the camera in end-effector frame using camera parameters with distorsion.
vpHomogeneousMatrix rMe
reference coordinates (manipulator base coordinates)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
vpCameraParameters cam_dist
projection model with distortion
Implementation of column vector and the associated operations.
static vp_deprecated void calibrationTsai(const std::vector< vpHomogeneousMatrix > &cMo, const std::vector< vpHomogeneousMatrix > &rMe, vpHomogeneousMatrix &eMc)
iterative algorithm doesn't converge
static vpHomogeneousMatrix direct(const vpColVector &v)
vpHomogeneousMatrix eMc
Position of the camera in end-effector frame using camera parameters without distorsion.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void computeStdDeviation(double &deviation, double &deviation_dist)