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>
64 const std::string &legend,
const double &translation3DThresh,
const double &rotationRadian3DThresh,
const double &pose2DThresh,
const double &posePixThresh);
67 const std::string &legend)
69 return compare_pose(pose, cMo_ref, cMo_est, cam,
70 legend, 0.001, 0.001, 0.001, 1.);
78 std::cout << std::endl
80 <<
"tx = " << cpo[0] <<
"\n "
81 <<
"ty = " << cpo[1] <<
"\n "
82 <<
"tz = " << cpo[2] <<
"\n "
83 <<
"tux = vpMath::rad(" <<
vpMath::deg(cpo[3]) <<
")\n "
84 <<
"tuy = vpMath::rad(" <<
vpMath::deg(cpo[4]) <<
")\n "
85 <<
"tuz = vpMath::rad(" <<
vpMath::deg(cpo[5]) <<
")\n"
91 const std::string &legend,
const double &translation3DThresh,
const double &rotation3DThresh,
const double &pose2DThresh,
const double &posePixThresh)
99 for (
unsigned int i = 0; i < 6; i++) {
100 double pose3DThresh = 0.;
102 pose3DThresh = translation3DThresh;
105 pose3DThresh = rotation3DThresh;
107 if (std::fabs(pose_ref[i] - pose_est[i]) > pose3DThresh) {
109 std::cout <<
"ref[" << i <<
"] - est[" << i <<
"] = " << pose_ref[i] - pose_est[i] <<
" > " << pose3DThresh << std::endl;
113 std::cout <<
"Based on 3D parameters " << legend <<
" is " << (fail_3d ?
"badly" :
"well") <<
" estimated" << std::endl;
119 if (pose.
listP.size() < 4) {
121 std::cout <<
"Not enough point" << std::endl;
124 r = sqrt(r / pose.
listP.size());
126 int fail_2d = (r > pose2DThresh) ? 1 : 0;
127 std::cout <<
"Based on 2D residual (" << r <<
") " << legend <<
" is " << (fail_2d ?
"badly" :
"well") <<
" estimated"
132 r_pix = sqrt(r_pix / pose.
listP.size());
134 int fail_pix = (r_pix > posePixThresh) ? 1 : 0;
135 std::cout <<
"Based on pixel residual (" << r_pix <<
") " << legend <<
" is " << (fail_pix ?
"badly" :
"well") <<
" estimated"
137 return fail_3d + fail_2d + fail_pix;
142 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
144 int test_planar_fail = 0, test_non_planar_fail = 0, fail = 0;
145 const double translation3DthreshWhenNoise = 0.005;
146 const double rotation3DthreshWhenNoise =
vpMath::rad(1.);
147 const double residual2DWhenNoise = 0.001;
148 const double residualPixelWhenNoise = 1.;
158 std::cout <<
"Start test considering planar case with 4 points..." << std::endl;
159 std::cout <<
"===================================================" << std::endl;
166 std::vector<vpPoint> P(npt);
169 P[0].setWorldCoordinates(-L, -L, Z);
170 P[1].setWorldCoordinates(L, -L, Z);
171 P[2].setWorldCoordinates(L, L, Z);
172 P[3].setWorldCoordinates(-L, L, Z);
176 for (
int i = 0; i < npt; i++) {
177 P[i].project(cMo_ref);
184 print_pose(cMo_ref, std::string(
"Reference pose"));
186 std::cout <<
"-------------------------------------------------" << std::endl;
189 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
190 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
191 test_planar_fail |= fail;
193 std::cout <<
"--------------------------------------------------" << std::endl;
196 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
197 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
198 test_planar_fail |= fail;
200 std::cout <<
"--------------------------------------------------" << std::endl;
206 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
207 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
208 test_planar_fail |= fail;
210 std::cout <<
"--------------------------------------------------" << std::endl;
213 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
214 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
215 test_planar_fail |= fail;
217 std::cout <<
"--------------------------------------------------" << std::endl;
220 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
221 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
222 test_planar_fail |= fail;
225 std::cout <<
"--------------------------------------------------" << std::endl;
228 print_pose(cMo, std::string(
"Pose estimated by VVS"));
229 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
230 test_planar_fail |= fail;
232 std::cout <<
"-------------------------------------------------" << std::endl;
235 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
236 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
237 test_planar_fail |= fail;
239 std::cout <<
"-------------------------------------------------" << std::endl;
242 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
243 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
244 test_planar_fail |= fail;
246 std::cout <<
"-------------------------------------------------" << std::endl;
249 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
250 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
251 test_planar_fail |= fail;
259 std::cout <<
"\nStart test considering non-planar case with 6 points..." << std::endl;
260 std::cout <<
"=======================================================" << std::endl;
266 std::vector<vpPoint> P(npt);
267 P[0].setWorldCoordinates(-L, -L, 0);
268 P[0].setWorldCoordinates(-L, -L, -0.02);
269 P[1].setWorldCoordinates(L, -L, 0);
270 P[2].setWorldCoordinates(L, L, 0);
271 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
272 P[4].setWorldCoordinates(-L, L, 0.01);
273 P[5].setWorldCoordinates(L, L / 2., 0.03);
277 for (
int i = 0; i < npt; i++) {
278 P[i].project(cMo_ref);
284 print_pose(cMo_ref, std::string(
"Reference pose"));
286 std::cout <<
"-------------------------------------------------" << std::endl;
289 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
290 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
291 test_non_planar_fail |= fail;
293 std::cout <<
"--------------------------------------------------" << std::endl;
296 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
297 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
298 test_non_planar_fail |= fail;
300 std::cout <<
"--------------------------------------------------" << std::endl;
305 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
306 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
307 test_non_planar_fail |= fail;
309 std::cout <<
"--------------------------------------------------" << std::endl;
312 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
313 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
314 test_non_planar_fail |= fail;
316 std::cout <<
"--------------------------------------------------" << std::endl;
319 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
320 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
321 test_non_planar_fail |= fail;
325 std::cout <<
"--------------------------------------------------" << std::endl;
328 print_pose(cMo, std::string(
"Pose estimated by VVS"));
329 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
330 test_non_planar_fail |= fail;
332 std::cout <<
"-------------------------------------------------" << std::endl;
335 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
336 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
337 test_non_planar_fail |= fail;
339 std::cout <<
"-------------------------------------------------" << std::endl;
342 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
343 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
344 test_non_planar_fail |= fail;
346 std::cout <<
"-------------------------------------------------" << std::endl;
349 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
350 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
351 test_non_planar_fail |= fail;
358 std::cout <<
"\nStart test considering non-planar case with 4 points..." << std::endl;
359 std::cout <<
"=======================================================" << std::endl;
363 std::vector<vpPoint> P(npt);
364 P[0].setWorldCoordinates(-L2, -L2, 0);
365 P[1].setWorldCoordinates(L2, -L2, 0.2);
366 P[2].setWorldCoordinates(L2, L2, -0.1);
367 P[3].setWorldCoordinates(-L2, L2, 0);
374 for (
int i = 0; i < npt; i++) {
375 P[i].project(cMo_ref);
381 print_pose(cMo_ref, std::string(
"Reference pose"));
383 std::cout <<
"--------------------------------------------------" << std::endl;
386 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
387 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
388 test_non_planar_fail |= fail;
390 std::cout <<
"--------------------------------------------------" << std::endl;
395 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
396 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
397 test_non_planar_fail |= fail;
399 std::cout <<
"--------------------------------------------------" << std::endl;
402 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
403 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
404 test_non_planar_fail |= fail;
407 std::cout <<
"--------------------------------------------------" << std::endl;
410 print_pose(cMo, std::string(
"Pose estimated by VVS"));
411 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
412 test_non_planar_fail |= fail;
414 std::cout <<
"-------------------------------------------------" << std::endl;
417 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
418 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
419 test_non_planar_fail |= fail;
421 std::cout <<
"-------------------------------------------------" << std::endl;
425 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
426 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
427 test_non_planar_fail |= fail;
429 std::cout <<
"-------------------------------------------------" << std::endl;
436 std::cout <<
"Start test considering planar case with 4 points and noise on the projection..." << std::endl;
437 std::cout <<
"===================================================" << std::endl;
443 std::vector<vpPoint> P(npt);
446 P[0].setWorldCoordinates(-L, -L, Z);
447 P[1].setWorldCoordinates(L, -L, Z);
448 P[2].setWorldCoordinates(L, L, Z);
449 P[3].setWorldCoordinates(-L, L, Z);
454 for (
int i = 0; i < npt; i++) {
456 P[i].project(cMo_ref);
459 double x_theo = P[i].get_X() / P[i].get_Z();
460 double y_theo = P[i].get_Y() / P[i].get_Z();
461 double u_theo = 0., v_theo = 0.;
465 double u_noisy = u_theo + random();
466 double v_noisy = v_theo + random();
469 double x_noisy = 0., y_noisy = 0.;
476 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
477 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
478 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
479 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
482 print_pose(cMo_ref, std::string(
"Reference pose"));
484 std::cout <<
"-------------------------------------------------" << std::endl;
487 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
488 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
489 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
490 test_planar_fail |= fail;
492 std::cout <<
"--------------------------------------------------" << std::endl;
495 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
496 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
497 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
498 test_planar_fail |= fail;
500 std::cout <<
"--------------------------------------------------" << std::endl;
506 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
507 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
508 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
509 test_planar_fail |= fail;
511 std::cout <<
"--------------------------------------------------" << std::endl;
514 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
515 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
516 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
517 test_planar_fail |= fail;
519 std::cout <<
"--------------------------------------------------" << std::endl;
522 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
523 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
524 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
525 test_planar_fail |= fail;
528 std::cout <<
"--------------------------------------------------" << std::endl;
531 print_pose(cMo, std::string(
"Pose estimated by VVS"));
532 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
533 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
534 test_planar_fail |= fail;
536 std::cout <<
"-------------------------------------------------" << std::endl;
539 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
540 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
541 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
542 test_planar_fail |= fail;
544 std::cout <<
"-------------------------------------------------" << std::endl;
547 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
548 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
549 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
550 test_planar_fail |= fail;
552 std::cout <<
"-------------------------------------------------" << std::endl;
555 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
556 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
557 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
558 test_planar_fail |= fail;
565 std::cout <<
"\nStart test considering non-planar case with 6 points and noise on the projection..." << std::endl;
566 std::cout <<
"=======================================================" << std::endl;
573 std::vector<vpPoint> P(npt);
574 P[0].setWorldCoordinates(-L, -L, 0);
575 P[0].setWorldCoordinates(-L, -L, -0.02);
576 P[1].setWorldCoordinates(L, -L, 0);
577 P[2].setWorldCoordinates(L, L, 0);
578 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
579 P[4].setWorldCoordinates(-L, L, 0.01);
580 P[5].setWorldCoordinates(L, L / 2., 0.03);
585 for (
int i = 0; i < npt; i++) {
587 P[i].project(cMo_ref);
590 double x_theo = P[i].get_X() / P[i].get_Z();
591 double y_theo = P[i].get_Y() / P[i].get_Z();
592 double u_theo = 0., v_theo = 0.;
596 double u_noisy = u_theo + random();
597 double v_noisy = v_theo + random();
600 double x_noisy = 0., y_noisy = 0.;
607 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
608 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
609 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
610 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
614 print_pose(cMo_ref, std::string(
"Reference pose"));
616 std::cout <<
"-------------------------------------------------" << std::endl;
619 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
620 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
621 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
622 test_non_planar_fail |= fail;
624 std::cout <<
"--------------------------------------------------" << std::endl;
627 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
628 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
629 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
630 test_non_planar_fail |= fail;
632 std::cout <<
"--------------------------------------------------" << std::endl;
637 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
638 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
639 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
640 test_non_planar_fail |= fail;
642 std::cout <<
"--------------------------------------------------" << std::endl;
645 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
646 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
647 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
648 test_non_planar_fail |= fail;
650 std::cout <<
"--------------------------------------------------" << std::endl;
653 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
654 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
655 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
656 test_non_planar_fail |= fail;
660 std::cout <<
"--------------------------------------------------" << std::endl;
663 print_pose(cMo, std::string(
"Pose estimated by VVS"));
664 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
665 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
666 test_non_planar_fail |= fail;
668 std::cout <<
"-------------------------------------------------" << std::endl;
671 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
672 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
673 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
674 test_non_planar_fail |= fail;
676 std::cout <<
"-------------------------------------------------" << std::endl;
679 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
680 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
681 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
682 test_non_planar_fail |= fail;
684 std::cout <<
"-------------------------------------------------" << std::endl;
687 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
688 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
689 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
690 test_non_planar_fail |= fail;
697 std::cout <<
"\nStart test considering non-planar case with 4 points and noise on the projection..." << std::endl;
698 std::cout <<
"=======================================================" << std::endl;
702 std::vector<vpPoint> P(npt);
703 P[0].setWorldCoordinates(-L2, -L2, 0.2);
704 P[1].setWorldCoordinates(L2, -L2, 0.4);
705 P[2].setWorldCoordinates(L2, L2, 0.1);
706 P[3].setWorldCoordinates(-L2, L2, 0.4);
715 for (
int i = 0; i < npt; i++) {
717 P[i].project(cMo_ref);
720 double x_theo = P[i].get_X() / P[i].get_Z();
721 double y_theo = P[i].get_Y() / P[i].get_Z();
722 double u_theo = 0., v_theo = 0.;
726 double u_noisy = u_theo + random();
727 double v_noisy = v_theo + random();
730 double x_noisy = 0., y_noisy = 0.;
737 std::cout <<
"P[" << i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
738 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
739 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
740 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
744 print_pose(cMo_ref, std::string(
"Reference pose"));
746 std::cout <<
"--------------------------------------------------" << std::endl;
749 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
750 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
751 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
752 test_non_planar_fail |= fail;
754 std::cout <<
"--------------------------------------------------" << std::endl;
759 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
760 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
761 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
762 test_non_planar_fail |= fail;
764 std::cout <<
"--------------------------------------------------" << std::endl;
767 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
768 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
769 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
770 test_non_planar_fail |= fail;
773 std::cout <<
"--------------------------------------------------" << std::endl;
776 print_pose(cMo, std::string(
"Pose estimated by VVS"));
777 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
778 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
779 test_non_planar_fail |= fail;
781 std::cout <<
"-------------------------------------------------" << std::endl;
784 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
785 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
786 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
787 test_non_planar_fail |= fail;
789 std::cout <<
"-------------------------------------------------" << std::endl;
793 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
794 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
795 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
796 test_non_planar_fail |= fail;
798 std::cout <<
"-------------------------------------------------" << std::endl;
801 std::cout <<
"=======================================================" << std::endl;
802 std::cout <<
"Pose estimation test from planar points: " << (test_planar_fail ?
"fail" :
"is ok") << std::endl;
803 std::cout <<
"Pose estimation test from non-planar points: " << (test_non_planar_fail ?
"fail" :
"is ok")
805 std::cout <<
"Global pose estimation test: " << ((test_planar_fail | test_non_planar_fail) ?
"fail" :
"is ok")
808 return ((test_planar_fail | test_non_planar_fail) ? EXIT_FAILURE : EXIT_SUCCESS);
811 std::cout <<
"Catch an exception: " << e << std::endl;
815 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
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.
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, bool(*func)(const vpHomogeneousMatrix &)=nullptr)
void setRansacThreshold(const double &t)