35 #include <visp3/core/vpCameraParameters.h>
36 #include <visp3/core/vpMeterPixelConversion.h>
37 #include <visp3/core/vpPixelMeterConversion.h>
38 #include <visp3/core/vpDebug.h>
39 #include <visp3/core/vpGaussRand.h>
40 #include <visp3/core/vpHomogeneousMatrix.h>
41 #include <visp3/core/vpMath.h>
42 #include <visp3/core/vpPoint.h>
43 #include <visp3/core/vpRotationMatrix.h>
44 #include <visp3/core/vpRxyzVector.h>
45 #include <visp3/core/vpTranslationVector.h>
46 #include <visp3/vision/vpPose.h>
62 #ifdef ENABLE_VISP_NAMESPACE
68 const std::string &legend,
const double &translation3DThresh,
const double &rotationRadian3DThresh,
const double &pose2DThresh,
const double &posePixThresh);
71 const std::string &legend)
73 return compare_pose(pose, cMo_ref, cMo_est, cam,
74 legend, 0.001, 0.001, 0.001, 1.);
82 std::cout << std::endl
84 <<
"tx = " << cpo[0] <<
"\n "
85 <<
"ty = " << cpo[1] <<
"\n "
86 <<
"tz = " << cpo[2] <<
"\n "
87 <<
"tux = vpMath::rad(" <<
vpMath::deg(cpo[3]) <<
")\n "
88 <<
"tuy = vpMath::rad(" <<
vpMath::deg(cpo[4]) <<
")\n "
89 <<
"tuz = vpMath::rad(" <<
vpMath::deg(cpo[5]) <<
")\n"
95 const std::string &legend,
const double &translation3DThresh,
const double &rotation3DThresh,
const double &pose2DThresh,
const double &posePixThresh)
103 for (
unsigned int i = 0; i < 6; i++) {
104 double pose3DThresh = 0.;
106 pose3DThresh = translation3DThresh;
109 pose3DThresh = rotation3DThresh;
111 if (std::fabs(pose_ref[i] - pose_est[i]) > pose3DThresh) {
113 std::cout <<
"ref[" << i <<
"] - est[" << i <<
"] = " << pose_ref[i] - pose_est[i] <<
" > " << pose3DThresh << std::endl;
117 std::cout <<
"Based on 3D parameters " << legend <<
" is " << (fail_3d ?
"badly" :
"well") <<
" estimated" << std::endl;
123 if (pose.
listP.size() < 4) {
125 std::cout <<
"Not enough point" << std::endl;
128 r = sqrt(r / pose.
listP.size());
130 int fail_2d = (r > pose2DThresh) ? 1 : 0;
131 std::cout <<
"Based on 2D residual (" << r <<
") " << legend <<
" is " << (fail_2d ?
"badly" :
"well") <<
" estimated"
136 r_pix = sqrt(r_pix / pose.
listP.size());
138 int fail_pix = (r_pix > posePixThresh) ? 1 : 0;
139 std::cout <<
"Based on pixel residual (" << r_pix <<
") " << legend <<
" is " << (fail_pix ?
"badly" :
"well") <<
" estimated"
141 return fail_3d + fail_2d + fail_pix;
146 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
148 int test_planar_fail = 0, test_non_planar_fail = 0, fail = 0;
149 const double translation3DthreshWhenNoise = 0.005;
150 const double rotation3DthreshWhenNoise =
vpMath::rad(1.);
151 const double residual2DWhenNoise = 0.001;
152 const double residualPixelWhenNoise = 1.;
162 std::cout <<
"Start test considering planar case with 4 points..." << std::endl;
163 std::cout <<
"===================================================" << std::endl;
170 std::vector<vpPoint> P(npt);
173 P[0].setWorldCoordinates(-L, -L, Z);
174 P[1].setWorldCoordinates(L, -L, Z);
175 P[2].setWorldCoordinates(L, L, Z);
176 P[3].setWorldCoordinates(-L, L, Z);
180 for (
int i = 0; i < npt; i++) {
181 P[i].project(cMo_ref);
188 print_pose(cMo_ref, std::string(
"Reference pose"));
190 std::cout <<
"-------------------------------------------------" << std::endl;
193 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
194 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
195 test_planar_fail |= fail;
197 std::cout <<
"--------------------------------------------------" << std::endl;
200 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
201 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
202 test_planar_fail |= fail;
204 std::cout <<
"--------------------------------------------------" << std::endl;
210 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
211 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
212 test_planar_fail |= fail;
214 std::cout <<
"--------------------------------------------------" << std::endl;
217 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
218 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
219 test_planar_fail |= fail;
221 std::cout <<
"--------------------------------------------------" << std::endl;
224 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
225 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
226 test_planar_fail |= fail;
229 std::cout <<
"--------------------------------------------------" << std::endl;
232 print_pose(cMo, std::string(
"Pose estimated by VVS"));
233 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
234 test_planar_fail |= fail;
236 std::cout <<
"-------------------------------------------------" << std::endl;
239 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
240 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
241 test_planar_fail |= fail;
243 std::cout <<
"-------------------------------------------------" << std::endl;
246 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
247 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
248 test_planar_fail |= fail;
250 std::cout <<
"-------------------------------------------------" << std::endl;
253 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
254 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
255 test_planar_fail |= fail;
263 std::cout <<
"\nStart test considering non-planar case with 6 points..." << std::endl;
264 std::cout <<
"=======================================================" << std::endl;
270 std::vector<vpPoint> P(npt);
271 P[0].setWorldCoordinates(-L, -L, 0);
272 P[0].setWorldCoordinates(-L, -L, -0.02);
273 P[1].setWorldCoordinates(L, -L, 0);
274 P[2].setWorldCoordinates(L, L, 0);
275 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
276 P[4].setWorldCoordinates(-L, L, 0.01);
277 P[5].setWorldCoordinates(L, L / 2., 0.03);
281 for (
int i = 0; i < npt; i++) {
282 P[i].project(cMo_ref);
288 print_pose(cMo_ref, std::string(
"Reference pose"));
290 std::cout <<
"-------------------------------------------------" << std::endl;
293 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
294 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
295 test_non_planar_fail |= fail;
297 std::cout <<
"--------------------------------------------------" << std::endl;
300 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
301 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
302 test_non_planar_fail |= fail;
304 std::cout <<
"--------------------------------------------------" << std::endl;
309 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
310 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
311 test_non_planar_fail |= fail;
313 std::cout <<
"--------------------------------------------------" << std::endl;
316 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
317 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
318 test_non_planar_fail |= fail;
320 std::cout <<
"--------------------------------------------------" << std::endl;
323 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
324 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
325 test_non_planar_fail |= fail;
329 std::cout <<
"--------------------------------------------------" << std::endl;
332 print_pose(cMo, std::string(
"Pose estimated by VVS"));
333 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
334 test_non_planar_fail |= fail;
336 std::cout <<
"-------------------------------------------------" << std::endl;
339 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
340 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
341 test_non_planar_fail |= fail;
343 std::cout <<
"-------------------------------------------------" << std::endl;
346 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
347 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
348 test_non_planar_fail |= fail;
350 std::cout <<
"-------------------------------------------------" << std::endl;
353 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
354 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
355 test_non_planar_fail |= fail;
362 std::cout <<
"\nStart test considering non-planar case with 4 points..." << std::endl;
363 std::cout <<
"=======================================================" << std::endl;
367 std::vector<vpPoint> P(npt);
368 P[0].setWorldCoordinates(-L2, -L2, 0);
369 P[1].setWorldCoordinates(L2, -L2, 0.2);
370 P[2].setWorldCoordinates(L2, L2, -0.1);
371 P[3].setWorldCoordinates(-L2, L2, 0);
378 for (
int i = 0; i < npt; i++) {
379 P[i].project(cMo_ref);
385 print_pose(cMo_ref, std::string(
"Reference pose"));
387 std::cout <<
"--------------------------------------------------" << std::endl;
390 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
391 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
392 test_non_planar_fail |= fail;
394 std::cout <<
"--------------------------------------------------" << std::endl;
399 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
400 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
401 test_non_planar_fail |= fail;
403 std::cout <<
"--------------------------------------------------" << std::endl;
406 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
407 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
408 test_non_planar_fail |= fail;
411 std::cout <<
"--------------------------------------------------" << std::endl;
414 print_pose(cMo, std::string(
"Pose estimated by VVS"));
415 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
416 test_non_planar_fail |= fail;
418 std::cout <<
"-------------------------------------------------" << std::endl;
421 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
422 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
423 test_non_planar_fail |= fail;
425 std::cout <<
"-------------------------------------------------" << std::endl;
429 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
430 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
431 test_non_planar_fail |= fail;
433 std::cout <<
"-------------------------------------------------" << std::endl;
440 std::cout <<
"Start test considering planar case with 4 points and noise on the projection..." << std::endl;
441 std::cout <<
"===================================================" << std::endl;
447 std::vector<vpPoint> P(npt);
450 P[0].setWorldCoordinates(-L, -L, Z);
451 P[1].setWorldCoordinates(L, -L, Z);
452 P[2].setWorldCoordinates(L, L, Z);
453 P[3].setWorldCoordinates(-L, L, Z);
458 for (
int i = 0; i < npt; i++) {
460 P[i].project(cMo_ref);
463 double x_theo = P[i].get_X() / P[i].get_Z();
464 double y_theo = P[i].get_Y() / P[i].get_Z();
465 double u_theo = 0., v_theo = 0.;
469 double u_noisy = u_theo + random();
470 double v_noisy = v_theo + random();
473 double x_noisy = 0., y_noisy = 0.;
480 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
481 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
482 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
483 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
486 print_pose(cMo_ref, std::string(
"Reference pose"));
488 std::cout <<
"-------------------------------------------------" << std::endl;
491 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
492 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
493 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
494 test_planar_fail |= fail;
496 std::cout <<
"--------------------------------------------------" << std::endl;
499 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
500 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
501 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
502 test_planar_fail |= fail;
504 std::cout <<
"--------------------------------------------------" << std::endl;
510 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
511 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
512 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
513 test_planar_fail |= fail;
515 std::cout <<
"--------------------------------------------------" << std::endl;
518 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
519 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
520 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
521 test_planar_fail |= fail;
523 std::cout <<
"--------------------------------------------------" << std::endl;
526 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
527 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
528 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
529 test_planar_fail |= fail;
532 std::cout <<
"--------------------------------------------------" << std::endl;
535 print_pose(cMo, std::string(
"Pose estimated by VVS"));
536 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
537 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
538 test_planar_fail |= fail;
540 std::cout <<
"-------------------------------------------------" << std::endl;
543 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
544 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
545 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
546 test_planar_fail |= fail;
548 std::cout <<
"-------------------------------------------------" << std::endl;
551 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
552 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
553 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
554 test_planar_fail |= fail;
556 std::cout <<
"-------------------------------------------------" << std::endl;
559 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
560 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
561 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
562 test_planar_fail |= fail;
569 std::cout <<
"\nStart test considering non-planar case with 6 points and noise on the projection..." << std::endl;
570 std::cout <<
"=======================================================" << std::endl;
577 std::vector<vpPoint> P(npt);
578 P[0].setWorldCoordinates(-L, -L, 0);
579 P[0].setWorldCoordinates(-L, -L, -0.02);
580 P[1].setWorldCoordinates(L, -L, 0);
581 P[2].setWorldCoordinates(L, L, 0);
582 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
583 P[4].setWorldCoordinates(-L, L, 0.01);
584 P[5].setWorldCoordinates(L, L / 2., 0.03);
589 for (
int i = 0; i < npt; i++) {
591 P[i].project(cMo_ref);
594 double x_theo = P[i].get_X() / P[i].get_Z();
595 double y_theo = P[i].get_Y() / P[i].get_Z();
596 double u_theo = 0., v_theo = 0.;
600 double u_noisy = u_theo + random();
601 double v_noisy = v_theo + random();
604 double x_noisy = 0., y_noisy = 0.;
611 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
612 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
613 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
614 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
618 print_pose(cMo_ref, std::string(
"Reference pose"));
620 std::cout <<
"-------------------------------------------------" << std::endl;
623 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
624 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
625 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
626 test_non_planar_fail |= fail;
628 std::cout <<
"--------------------------------------------------" << std::endl;
631 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
632 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
633 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
634 test_non_planar_fail |= fail;
636 std::cout <<
"--------------------------------------------------" << std::endl;
641 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
642 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
643 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
644 test_non_planar_fail |= fail;
646 std::cout <<
"--------------------------------------------------" << std::endl;
649 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
650 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
651 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
652 test_non_planar_fail |= fail;
654 std::cout <<
"--------------------------------------------------" << std::endl;
657 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
658 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
659 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
660 test_non_planar_fail |= fail;
664 std::cout <<
"--------------------------------------------------" << std::endl;
667 print_pose(cMo, std::string(
"Pose estimated by VVS"));
668 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
669 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
670 test_non_planar_fail |= fail;
672 std::cout <<
"-------------------------------------------------" << std::endl;
675 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
676 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
677 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
678 test_non_planar_fail |= fail;
680 std::cout <<
"-------------------------------------------------" << std::endl;
683 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
684 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
685 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
686 test_non_planar_fail |= fail;
688 std::cout <<
"-------------------------------------------------" << std::endl;
691 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
692 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
693 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
694 test_non_planar_fail |= fail;
701 std::cout <<
"\nStart test considering non-planar case with 4 points and noise on the projection..." << std::endl;
702 std::cout <<
"=======================================================" << std::endl;
706 std::vector<vpPoint> P(npt);
707 P[0].setWorldCoordinates(-L2, -L2, 0.2);
708 P[1].setWorldCoordinates(L2, -L2, 0.4);
709 P[2].setWorldCoordinates(L2, L2, 0.1);
710 P[3].setWorldCoordinates(-L2, L2, 0.4);
719 for (
int i = 0; i < npt; i++) {
721 P[i].project(cMo_ref);
724 double x_theo = P[i].get_X() / P[i].get_Z();
725 double y_theo = P[i].get_Y() / P[i].get_Z();
726 double u_theo = 0., v_theo = 0.;
730 double u_noisy = u_theo + random();
731 double v_noisy = v_theo + random();
734 double x_noisy = 0., y_noisy = 0.;
741 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
742 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
743 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
744 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
748 print_pose(cMo_ref, std::string(
"Reference pose"));
750 std::cout <<
"--------------------------------------------------" << std::endl;
753 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
754 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
755 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
756 test_non_planar_fail |= fail;
758 std::cout <<
"--------------------------------------------------" << std::endl;
763 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
764 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
765 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
766 test_non_planar_fail |= fail;
768 std::cout <<
"--------------------------------------------------" << std::endl;
771 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
772 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
773 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
774 test_non_planar_fail |= fail;
777 std::cout <<
"--------------------------------------------------" << std::endl;
780 print_pose(cMo, std::string(
"Pose estimated by VVS"));
781 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
782 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
783 test_non_planar_fail |= fail;
785 std::cout <<
"-------------------------------------------------" << std::endl;
788 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
789 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
790 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
791 test_non_planar_fail |= fail;
793 std::cout <<
"-------------------------------------------------" << std::endl;
797 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
798 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
799 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
800 test_non_planar_fail |= fail;
802 std::cout <<
"-------------------------------------------------" << std::endl;
805 std::cout <<
"=======================================================" << std::endl;
806 std::cout <<
"Pose estimation test from planar points: " << (test_planar_fail ?
"fail" :
"is ok") << std::endl;
807 std::cout <<
"Pose estimation test from non-planar points: " << (test_non_planar_fail ?
"fail" :
"is ok")
809 std::cout <<
"Global pose estimation test: " << ((test_planar_fail | test_non_planar_fail) ?
"fail" :
"is ok")
812 return ((test_planar_fail | test_non_planar_fail) ? EXIT_FAILURE : EXIT_SUCCESS);
815 std::cout <<
"Catch an exception: " << e << std::endl;
819 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
Class for generating random number with normal probability density.
Implementation of an homogeneous matrix and operations on such kind of matrices.
static double rad(double deg)
static double deg(double rad)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Implementation of a pose vector and operations on poses.
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
void addPoint(const vpPoint &P)
void setRansacNbInliersToReachConsensus(const unsigned int &nbC)
@ DEMENTHON_LAGRANGE_VIRTUAL_VS
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, FuncCheckValidityPose func=nullptr)
std::list< vpPoint > listP
Array of point (use here class vpPoint)
double computeResidual(const vpHomogeneousMatrix &cMo) const
Compute and return the sum of squared residuals expressed in meter^2 for the pose matrix cMo.
void setRansacThreshold(const double &t)