[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56313] branches/soc-2011-tomato/extern/ libmv/libmv/simple_pipeline/keyframe_selection.cc: Keyframe selection improvements

Sergey Sharybin sergey.vfx at gmail.com
Fri Apr 26 14:57:28 CEST 2013


Revision: 56313
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56313
Author:   nazgul
Date:     2013-04-26 12:57:27 +0000 (Fri, 26 Apr 2013)
Log Message:
-----------
Keyframe selection improvements

Added additional criteria, which ignores
keyframe pair if success intersection factor
is lower than current candidate pair factor.

This solves issue with keyframe pair at which
most of the tracks are intersecting behind the
camera is accepted (because variance in this
case is really small),

Also tweaked generalized inverse function,
which now doesn't scale epsilon by maximal
matrix element. This gave issues at really bad
candidates with unstable covariance. In this
case almost all eigen values getting zeroed
on inverse leading to small expected error
estimation.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc

Modified: branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-04-26 11:43:28 UTC (rev 56312)
+++ branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-04-26 12:57:27 UTC (rev 56313)
@@ -259,9 +259,7 @@
   const SingularValuesType singularValues = jacobiSvd.singularValues();
   SingularValuesType singularValues_inv = singularValues;
 
-  double epsilon = std::numeric_limits<double>::epsilon() *
-                   std::max(matrix.rows(), matrix.cols()) *
-                   singularValues.array().abs().maxCoeff();
+  double epsilon = std::numeric_limits<double>::epsilon();
 
   for (int i = 0; i < singularValues.rows(); i++) {
     if (singularValues(i) > epsilon)
@@ -274,8 +272,6 @@
   // 7 equals to the number of gauge freedoms.
   singularValues_inv.tail<7>() = Eigen::Matrix<double, 1, 7>::Zero();
 
-  LG << singularValues_inv;
-
   return jacobiSvd.matrixV() *
          singularValues_inv.asDiagonal() *
          jacobiSvd.matrixU().transpose();
@@ -345,6 +341,7 @@
   Mat3 N_inverse = N.inverse();
 
   double Sc_best = std::numeric_limits<double>::max();
+  double success_intersects_factor_best = 0.0f;
 
   while (next_keyframe != -1) {
     int current_keyframe = next_keyframe;
@@ -480,6 +477,7 @@
       reconstruction.InsertCamera(candidate_image, R, t);
 
       // Reconstruct 3D points
+      int intersects_total = 0, intersects_success = 0;
       for (int i = 0; i < tracked_markers.size(); i++) {
         if (!reconstruction.PointForTrack(tracked_markers[i].track)) {
           vector<Marker> reconstructed_markers;
@@ -501,13 +499,29 @@
             }
           }
 
-          if (EuclideanIntersect(reconstructed_markers, &reconstruction))
+          intersects_total++;
+
+          if (EuclideanIntersect(reconstructed_markers, &reconstruction)) {
             LG << "Ran Intersect() for track " << track;
-          else
+            intersects_success++;
+          } else {
             LG << "Filed to intersect track " << track;
+          }
         }
       }
 
+      double success_intersects_factor =
+          (double) intersects_success / intersects_total;
+
+      if (success_intersects_factor < success_intersects_factor_best) {
+        LG << "Skip keyframe candidate because of "
+              "lower successful intersections ratio";
+
+        continue;
+      }
+
+      success_intersects_factor_best = success_intersects_factor;
+
       Tracks two_frames_tracks(tracked_markers);
       CameraIntrinsics empty_intrinsics;
       BundleEvaluation evaluation;




More information about the Bf-blender-cvs mailing list