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);
70 const std::string &legend,
const double &translation3DThresh,
const double &rotationRadian3DThresh,
const double &pose2DThresh,
const double &posePixThresh);
73 const std::string &legend)
75 return compare_pose(pose, cMo_ref, cMo_est, cam,
76 legend, 0.001, 0.001, 0.001, 1.);
84 std::cout << std::endl
86 <<
"tx = " << cpo[0] <<
"\n "
87 <<
"ty = " << cpo[1] <<
"\n "
88 <<
"tz = " << cpo[2] <<
"\n "
89 <<
"tux = vpMath::rad(" <<
vpMath::deg(cpo[3]) <<
")\n "
90 <<
"tuy = vpMath::rad(" <<
vpMath::deg(cpo[4]) <<
")\n "
91 <<
"tuz = vpMath::rad(" <<
vpMath::deg(cpo[5]) <<
")\n"
97 const std::string &legend,
const double &translation3DThresh,
const double &rotation3DThresh,
const double &pose2DThresh,
const double &posePixThresh)
105 for (
unsigned int i = 0;
i < 6;
i++) {
106 double pose3DThresh = 0.;
108 pose3DThresh = translation3DThresh;
111 pose3DThresh = rotation3DThresh;
113 if (std::fabs(pose_ref[i] - pose_est[i]) > pose3DThresh) {
115 std::cout <<
"ref[" <<
i <<
"] - est[" <<
i <<
"] = " << pose_ref[
i] - pose_est[
i] <<
" > " << pose3DThresh << std::endl;
119 std::cout <<
"Based on 3D parameters " << legend <<
" is " << (fail_3d ?
"badly" :
"well") <<
" estimated" << std::endl;
125 if (pose.
listP.size() < 4) {
127 std::cout <<
"Not enough point" << std::endl;
130 r = sqrt(r / pose.
listP.size());
132 int fail_2d = (
r > pose2DThresh) ? 1 : 0;
133 std::cout <<
"Based on 2D residual (" <<
r <<
") " << legend <<
" is " << (fail_2d ?
"badly" :
"well") <<
" estimated"
138 r_pix = sqrt(r_pix / pose.
listP.size());
140 int fail_pix = (r_pix > posePixThresh) ? 1 : 0;
141 std::cout <<
"Based on pixel residual (" << r_pix <<
") " << legend <<
" is " << (fail_pix ?
"badly" :
"well") <<
" estimated"
143 return fail_3d + fail_2d + fail_pix;
148#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
150 int test_planar_fail = 0, test_non_planar_fail = 0, fail = 0;
151 const double translation3DthreshWhenNoise = 0.005;
152 const double rotation3DthreshWhenNoise =
vpMath::rad(1.);
153 const double residual2DWhenNoise = 0.001;
154 const double residualPixelWhenNoise = 1.;
164 std::cout <<
"Start test considering planar case with 4 points..." << std::endl;
165 std::cout <<
"===================================================" << std::endl;
172 std::vector<vpPoint> P(npt);
175 P[0].setWorldCoordinates(-L, -L, Z);
176 P[1].setWorldCoordinates(L, -L, Z);
177 P[2].setWorldCoordinates(L, L, Z);
178 P[3].setWorldCoordinates(-L, L, Z);
182 for (
int i = 0;
i < npt;
i++) {
183 P[
i].project(cMo_ref);
190 print_pose(cMo_ref, std::string(
"Reference pose"));
192 std::cout <<
"-------------------------------------------------" << std::endl;
195 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
196 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
197 test_planar_fail |= fail;
199 std::cout <<
"--------------------------------------------------" << std::endl;
202 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
203 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
204 test_planar_fail |= fail;
206 std::cout <<
"--------------------------------------------------" << std::endl;
212 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
213 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
214 test_planar_fail |= fail;
216 std::cout <<
"--------------------------------------------------" << std::endl;
219 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
220 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
221 test_planar_fail |= fail;
223 std::cout <<
"--------------------------------------------------" << std::endl;
226 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
227 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
228 test_planar_fail |= fail;
231 std::cout <<
"--------------------------------------------------" << std::endl;
234 print_pose(cMo, std::string(
"Pose estimated by VVS"));
235 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
236 test_planar_fail |= fail;
238 std::cout <<
"-------------------------------------------------" << std::endl;
241 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
242 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
243 test_planar_fail |= fail;
245 std::cout <<
"-------------------------------------------------" << std::endl;
248 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
249 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
250 test_planar_fail |= fail;
252 std::cout <<
"-------------------------------------------------" << std::endl;
255 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
256 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
257 test_planar_fail |= fail;
265 std::cout <<
"\nStart test considering non-planar case with 6 points..." << std::endl;
266 std::cout <<
"=======================================================" << std::endl;
272 std::vector<vpPoint> P(npt);
273 P[0].setWorldCoordinates(-L, -L, 0);
274 P[0].setWorldCoordinates(-L, -L, -0.02);
275 P[1].setWorldCoordinates(L, -L, 0);
276 P[2].setWorldCoordinates(L, L, 0);
277 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
278 P[4].setWorldCoordinates(-L, L, 0.01);
279 P[5].setWorldCoordinates(L, L / 2., 0.03);
283 for (
int i = 0;
i < npt;
i++) {
284 P[
i].project(cMo_ref);
290 print_pose(cMo_ref, std::string(
"Reference pose"));
292 std::cout <<
"-------------------------------------------------" << std::endl;
295 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
296 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange");
297 test_non_planar_fail |= fail;
299 std::cout <<
"--------------------------------------------------" << std::endl;
302 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
303 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
304 test_non_planar_fail |= fail;
306 std::cout <<
"--------------------------------------------------" << std::endl;
311 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
312 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
313 test_non_planar_fail |= fail;
315 std::cout <<
"--------------------------------------------------" << std::endl;
318 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
319 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe");
320 test_non_planar_fail |= fail;
322 std::cout <<
"--------------------------------------------------" << std::endl;
325 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
326 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
327 test_non_planar_fail |= fail;
331 std::cout <<
"--------------------------------------------------" << std::endl;
334 print_pose(cMo, std::string(
"Pose estimated by VVS"));
335 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
336 test_non_planar_fail |= fail;
338 std::cout <<
"-------------------------------------------------" << std::endl;
341 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
342 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
343 test_non_planar_fail |= fail;
345 std::cout <<
"-------------------------------------------------" << std::endl;
348 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
349 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS");
350 test_non_planar_fail |= fail;
352 std::cout <<
"-------------------------------------------------" << std::endl;
355 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
356 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
357 test_non_planar_fail |= fail;
364 std::cout <<
"\nStart test considering non-planar case with 4 points..." << std::endl;
365 std::cout <<
"=======================================================" << std::endl;
369 std::vector<vpPoint> P(npt);
370 P[0].setWorldCoordinates(-L2, -L2, 0);
371 P[1].setWorldCoordinates(L2, -L2, 0.2);
372 P[2].setWorldCoordinates(L2, L2, -0.1);
373 P[3].setWorldCoordinates(-L2, L2, 0);
380 for (
int i = 0;
i < npt;
i++) {
381 P[
i].project(cMo_ref);
387 print_pose(cMo_ref, std::string(
"Reference pose"));
389 std::cout <<
"--------------------------------------------------" << std::endl;
392 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
393 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon");
394 test_non_planar_fail |= fail;
396 std::cout <<
"--------------------------------------------------" << std::endl;
401 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
402 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac");
403 test_non_planar_fail |= fail;
405 std::cout <<
"--------------------------------------------------" << std::endl;
408 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
409 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe");
410 test_non_planar_fail |= fail;
413 std::cout <<
"--------------------------------------------------" << std::endl;
416 print_pose(cMo, std::string(
"Pose estimated by VVS"));
417 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS");
418 test_non_planar_fail |= fail;
420 std::cout <<
"-------------------------------------------------" << std::endl;
423 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
424 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS");
425 test_non_planar_fail |= fail;
427 std::cout <<
"-------------------------------------------------" << std::endl;
431 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
432 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS");
433 test_non_planar_fail |= fail;
435 std::cout <<
"-------------------------------------------------" << std::endl;
442 std::cout <<
"Start test considering planar case with 4 points and noise on the projection..." << std::endl;
443 std::cout <<
"===================================================" << std::endl;
449 std::vector<vpPoint> P(npt);
452 P[0].setWorldCoordinates(-L, -L, Z);
453 P[1].setWorldCoordinates(L, -L, Z);
454 P[2].setWorldCoordinates(L, L, Z);
455 P[3].setWorldCoordinates(-L, L, Z);
460 for (
int i = 0;
i < npt;
i++) {
462 P[
i].project(cMo_ref);
465 double x_theo = P[
i].get_X() / P[
i].get_Z();
466 double y_theo = P[
i].get_Y() / P[
i].get_Z();
467 double u_theo = 0., v_theo = 0.;
471 double u_noisy = u_theo + random();
472 double v_noisy = v_theo + random();
475 double x_noisy = 0., y_noisy = 0.;
482 std::cout <<
"P[" <<
i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
483 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
484 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
485 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
488 print_pose(cMo_ref, std::string(
"Reference pose"));
490 std::cout <<
"-------------------------------------------------" << std::endl;
493 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
494 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
495 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
496 test_planar_fail |= fail;
498 std::cout <<
"--------------------------------------------------" << std::endl;
501 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
502 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
503 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
504 test_planar_fail |= fail;
506 std::cout <<
"--------------------------------------------------" << std::endl;
512 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
513 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
514 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
515 test_planar_fail |= fail;
517 std::cout <<
"--------------------------------------------------" << std::endl;
520 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
521 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
522 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
523 test_planar_fail |= fail;
525 std::cout <<
"--------------------------------------------------" << std::endl;
528 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
529 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
530 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
531 test_planar_fail |= fail;
534 std::cout <<
"--------------------------------------------------" << std::endl;
537 print_pose(cMo, std::string(
"Pose estimated by VVS"));
538 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
539 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
540 test_planar_fail |= fail;
542 std::cout <<
"-------------------------------------------------" << std::endl;
545 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
546 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
547 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
548 test_planar_fail |= fail;
550 std::cout <<
"-------------------------------------------------" << std::endl;
553 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
554 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
555 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
556 test_planar_fail |= fail;
558 std::cout <<
"-------------------------------------------------" << std::endl;
561 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
562 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
563 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
564 test_planar_fail |= fail;
571 std::cout <<
"\nStart test considering non-planar case with 6 points and noise on the projection..." << std::endl;
572 std::cout <<
"=======================================================" << std::endl;
579 std::vector<vpPoint> P(npt);
580 P[0].setWorldCoordinates(-L, -L, 0);
581 P[0].setWorldCoordinates(-L, -L, -0.02);
582 P[1].setWorldCoordinates(L, -L, 0);
583 P[2].setWorldCoordinates(L, L, 0);
584 P[3].setWorldCoordinates(-2 * L, 3 * L, 0);
585 P[4].setWorldCoordinates(-L, L, 0.01);
586 P[5].setWorldCoordinates(L, L / 2., 0.03);
591 for (
int i = 0;
i < npt;
i++) {
593 P[
i].project(cMo_ref);
596 double x_theo = P[
i].get_X() / P[
i].get_Z();
597 double y_theo = P[
i].get_Y() / P[
i].get_Z();
598 double u_theo = 0., v_theo = 0.;
602 double u_noisy = u_theo + random();
603 double v_noisy = v_theo + random();
606 double x_noisy = 0., y_noisy = 0.;
613 std::cout <<
"P[" <<
i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
614 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
615 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
616 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
620 print_pose(cMo_ref, std::string(
"Reference pose"));
622 std::cout <<
"-------------------------------------------------" << std::endl;
625 print_pose(cMo, std::string(
"Pose estimated by Lagrange"));
626 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange"
627 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
628 test_non_planar_fail |= fail;
630 std::cout <<
"--------------------------------------------------" << std::endl;
633 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
634 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
635 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
636 test_non_planar_fail |= fail;
638 std::cout <<
"--------------------------------------------------" << std::endl;
643 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
644 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
645 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
646 test_non_planar_fail |= fail;
648 std::cout <<
"--------------------------------------------------" << std::endl;
651 print_pose(cMo, std::string(
"Pose estimated by Lagrange then Lowe"));
652 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then Lowe"
653 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
654 test_non_planar_fail |= fail;
656 std::cout <<
"--------------------------------------------------" << std::endl;
659 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
660 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
661 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
662 test_non_planar_fail |= fail;
666 std::cout <<
"--------------------------------------------------" << std::endl;
669 print_pose(cMo, std::string(
"Pose estimated by VVS"));
670 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
671 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
672 test_non_planar_fail |= fail;
674 std::cout <<
"-------------------------------------------------" << std::endl;
677 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
678 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
679 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
680 test_non_planar_fail |= fail;
682 std::cout <<
"-------------------------------------------------" << std::endl;
685 print_pose(cMo, std::string(
"Pose estimated by Lagrange then by VVS"));
686 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Lagrange then by VVS"
687 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
688 test_non_planar_fail |= fail;
690 std::cout <<
"-------------------------------------------------" << std::endl;
693 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
694 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
695 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
696 test_non_planar_fail |= fail;
703 std::cout <<
"\nStart test considering non-planar case with 4 points and noise on the projection..." << std::endl;
704 std::cout <<
"=======================================================" << std::endl;
708 std::vector<vpPoint> P(npt);
709 P[0].setWorldCoordinates(-L2, -L2, 0.2);
710 P[1].setWorldCoordinates(L2, -L2, 0.4);
711 P[2].setWorldCoordinates(L2, L2, 0.1);
712 P[3].setWorldCoordinates(-L2, L2, 0.4);
721 for (
int i = 0;
i < npt;
i++) {
723 P[
i].project(cMo_ref);
726 double x_theo = P[
i].get_X() / P[
i].get_Z();
727 double y_theo = P[
i].get_Y() / P[
i].get_Z();
728 double u_theo = 0., v_theo = 0.;
732 double u_noisy = u_theo + random();
733 double v_noisy = v_theo + random();
736 double x_noisy = 0., y_noisy = 0.;
743 std::cout <<
"P[" <<
i <<
"]:\n\tu_theo = " << u_theo <<
"\tu_noisy = " << u_noisy << std::endl;
744 std::cout <<
"\tv_theo = " << v_theo <<
"\tv_noisy = " << v_noisy << std::endl;
745 std::cout <<
"\tx_theo = " << x_theo <<
"\ty_noisy = " << x_noisy << std::endl;
746 std::cout <<
"\ty_theo = " << y_theo <<
"\tx_noisy = " << y_noisy << std::endl;
750 print_pose(cMo_ref, std::string(
"Reference pose"));
752 std::cout <<
"--------------------------------------------------" << std::endl;
755 print_pose(cMo, std::string(
"Pose estimated by Dementhon"));
756 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon"
757 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
758 test_non_planar_fail |= fail;
760 std::cout <<
"--------------------------------------------------" << std::endl;
765 print_pose(cMo, std::string(
"Pose estimated by Ransac"));
766 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Ransac"
767 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
768 test_non_planar_fail |= fail;
770 std::cout <<
"--------------------------------------------------" << std::endl;
773 print_pose(cMo, std::string(
"Pose estimated by Dementhon then Lowe"));
774 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then Lowe"
775 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
776 test_non_planar_fail |= fail;
779 std::cout <<
"--------------------------------------------------" << std::endl;
782 print_pose(cMo, std::string(
"Pose estimated by VVS"));
783 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by VVS"
784 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
785 test_non_planar_fail |= fail;
787 std::cout <<
"-------------------------------------------------" << std::endl;
790 print_pose(cMo, std::string(
"Pose estimated by Dementhon then by VVS"));
791 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose by Dementhon then by VVS"
792 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
793 test_non_planar_fail |= fail;
795 std::cout <<
"-------------------------------------------------" << std::endl;
799 print_pose(cMo, std::string(
"Pose estimated either by Dementhon or Lagrange then by VVS"));
800 fail = compare_pose(pose, cMo_ref, cMo, cam,
"pose either by Dementhon or Lagrange then by VVS"
801 , translation3DthreshWhenNoise, rotation3DthreshWhenNoise, residual2DWhenNoise, residualPixelWhenNoise);
802 test_non_planar_fail |= fail;
804 std::cout <<
"-------------------------------------------------" << std::endl;
807 std::cout <<
"=======================================================" << std::endl;
808 std::cout <<
"Pose estimation test from planar points: " << (test_planar_fail ?
"fail" :
"is ok") << std::endl;
809 std::cout <<
"Pose estimation test from non-planar points: " << (test_non_planar_fail ?
"fail" :
"is ok")
811 std::cout <<
"Global pose estimation test: " << ((test_planar_fail | test_non_planar_fail) ?
"fail" :
"is ok")
814 return ((test_planar_fail | test_non_planar_fail) ? EXIT_FAILURE : EXIT_SUCCESS);
817 std::cout <<
"Catch an exception: " <<
e << std::endl;
821 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)