~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/libmv/libmv/multiview/euclidean_resection.cc

  • Committer: Reinhard Tartler
  • Date: 2014-05-31 01:50:05 UTC
  • mfrom: (14.2.27 sid)
  • Revision ID: siretart@tauware.de-20140531015005-ml6druahuj82nsav
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
namespace euclidean_resection {
35
35
 
36
36
typedef unsigned int uint;
37
 
  
38
 
bool EuclideanResectionPPnP(const Mat2X &x_camera,
39
 
                            const Mat3X &X_world,
40
 
                            Mat3 *R, Vec3 *t,
41
 
                            double tolerance);
42
37
 
43
38
bool EuclideanResection(const Mat2X &x_camera,
44
39
                        const Mat3X &X_world,
45
40
                        Mat3 *R, Vec3 *t,
46
 
                        ResectionMethod method,
47
 
                        double success_threshold) {
 
41
                        ResectionMethod method) {
48
42
  switch (method) {
49
43
    case RESECTION_ANSAR_DANIILIDIS:
50
44
      EuclideanResectionAnsarDaniilidis(x_camera, X_world, R, t);
51
45
      break;
52
46
    case RESECTION_EPNP:
53
 
      return EuclideanResectionEPnP(x_camera, X_world, R, t, success_threshold);
 
47
      return EuclideanResectionEPnP(x_camera, X_world, R, t);
54
48
      break;
55
49
    case RESECTION_PPNP:
56
 
      return EuclideanResectionPPnP(x_camera, X_world, R, t, success_threshold);
 
50
      return EuclideanResectionPPnP(x_camera, X_world, R, t);
57
51
      break;
58
52
    default:
59
53
      LOG(FATAL) << "Unknown resection method.";
444
438
 
445
439
bool EuclideanResectionEPnP(const Mat2X &x_camera,
446
440
                            const Mat3X &X_world,
447
 
                            Mat3 *R, Vec3 *t,
448
 
                            double success_threshold) {
 
441
                            Mat3 *R, Vec3 *t) {
449
442
  CHECK(x_camera.cols() == X_world.cols());
450
443
  CHECK(x_camera.cols() > 3);
451
444
  size_t num_points = X_world.cols();
553
546
  //
554
547
  // TODO(keir): Decide if setting this to infinity, effectively disabling the
555
548
  // check, is the right approach. So far this seems the case.
556
 
  //
557
 
  // TODO(sergey): Made it an option for now, in some cases it makes sense to
558
 
  // still fallback to reprojection solution
559
 
  // For details see bug [#32765] from Blender bug tracker
560
 
 
561
 
  // double kSuccessThreshold = std::numeric_limits<double>::max();
562
 
  double kSuccessThreshold = success_threshold;
 
549
   double kSuccessThreshold = std::numeric_limits<double>::max();
563
550
 
564
551
  // Find the first possible solution for R, t corresponding to:
565
552
  // Betas          = [b00 b01 b11 b02 b12 b22 b03 b13 b23 b33]
728
715
// other hand, it did work on the first try.
729
716
bool EuclideanResectionPPnP(const Mat2X &x_camera,
730
717
                            const Mat3X &X_world,
731
 
                            Mat3 *R, Vec3 *t,
732
 
                            double tolerance) {
 
718
                            Mat3 *R, Vec3 *t) {
733
719
  int n = x_camera.cols();
734
720
  Mat Z = Mat::Zero(n, n);
735
721
  Vec e = Vec::Ones(n);
750
736
  Mat E(n, 3);
751
737
  
752
738
  int iteration = 0;
753
 
  tolerance = 1e-5;
 
739
  double tolerance = 1e-5;
754
740
  // TODO(keir): The limit of 100 can probably be reduced, but this will require
755
741
  // some investigation.
756
742
  while (error > tolerance && iteration < 100) {