From 59d1387c4154b4a285e8c53eca2128fbe59aeb54 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 28 Jan 2014 17:25:47 +0600 Subject: Improvements to weighted tracks behavior First thing changed by this commit is making it so Euclidean intersection takes track weight into account when solving minimization problem. This behaves the same exact way as it is for BA step. Second thing is related on how average reprojection error is being calculated. It didn't take track weight into account which could confuse users. Now average reprojection error will give the same result as intersection/BA uses during minimization which gives much more predictable behavior. Differential Revision: https://developer.blender.org/D265 --- extern/libmv/ChangeLog | 44 ++++++++++++++++--------- extern/libmv/libmv/simple_pipeline/intersect.cc | 26 ++++++++------- extern/libmv/libmv/simple_pipeline/pipeline.cc | 7 ++-- 3 files changed, 46 insertions(+), 31 deletions(-) (limited to 'extern') diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog index 476e01dbe28..f9ddbb8c1b9 100644 --- a/extern/libmv/ChangeLog +++ b/extern/libmv/ChangeLog @@ -1,8 +1,34 @@ -commit f71f7c59d4d13574ea4dc3a196cc22eef1c192df +commit cd7eb3eff2e69ce5e08570ead83ae6d35ee48857 +Author: Sergey Sharybin +Date: Tue Jan 28 17:23:47 2014 +0600 + + Improvements to weighted tracks behavior + + First thing changed by this commit is making it so + Euclidean intersection takes track weight into account + when solving minimization problem. This behaves the + same exact way as it is for BA step. + + Second thing is related on how average reprojection error + is being calculated. It didn't take track weight into + account which could confuse users. Now average reprojection + error will give the same result as intersection/BA uses + during minimization which gives much more predictable + behavior. + + Reviewers: keir + + Reviewed By: keir + + CC: sebastian_k + + Differential Revision: https://developer.blender.org/D265 + +commit 6559b36dc14369175bfa0830323146acd3426483 Author: Sergey Sharybin Date: Tue Jan 28 16:39:14 2014 +0600 - Fixed for keyframe selection + Fixes for keyframe selection Using tracks with constant zero weight used to crash keyframe selection since it was trying to use missing @@ -660,17 +686,3 @@ Date: Sat Apr 6 18:37:37 2013 +0600 It is failing at this moment and this is caused because of how SampleLinear works - seems it's assumption about pixel center is not correct for internal sampling. - -commit d449b820fb3352cd981e06d737f2838adb3d36bd -Author: Sergey Sharybin -Date: Sat Apr 6 16:54:08 2013 +0600 - - Tweak to KLT region tracker test - - KLT is usually used to track relatively small - motions, and in this case motion almost equals - to half window size. This confuses math and - leads to not so much expected result. - - Further, not actually sure this is nice idea - to use KLT in such synthetic case. diff --git a/extern/libmv/libmv/simple_pipeline/intersect.cc b/extern/libmv/libmv/simple_pipeline/intersect.cc index fad750e8212..6a098da272d 100644 --- a/extern/libmv/libmv/simple_pipeline/intersect.cc +++ b/extern/libmv/libmv/simple_pipeline/intersect.cc @@ -54,8 +54,8 @@ class EuclideanIntersectCostFunctor { Vec3 projected = R * x + t; projected /= projected(2); - residuals[0] = projected(0) - T(marker_.x); - residuals[1] = projected(1) - T(marker_.y); + residuals[0] = (projected(0) - T(marker_.x)) * marker_.weight; + residuals[1] = (projected(1) - T(marker_.y)) * marker_.weight; return true; } @@ -102,16 +102,18 @@ bool EuclideanIntersect(const vector &markers, for (int i = 0; i < markers.size(); ++i) { const Marker &marker = markers[i]; - const EuclideanCamera &camera = - *reconstruction->CameraForImage(marker.image); - - problem.AddResidualBlock( - new ceres::AutoDiffCostFunction< - EuclideanIntersectCostFunctor, - 2, /* num_residuals */ - 3>(new EuclideanIntersectCostFunctor(marker, camera)), - NULL, - &X(0)); + if (marker.weight != 0.0) { + const EuclideanCamera &camera = + *reconstruction->CameraForImage(marker.image); + + problem.AddResidualBlock( + new ceres::AutoDiffCostFunction< + EuclideanIntersectCostFunctor, + 2, /* num_residuals */ + 3>(new EuclideanIntersectCostFunctor(marker, camera)), + NULL, + &X(0)); + } } // Configure the solve. diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc index 41dd3251f10..6c8592baa00 100644 --- a/extern/libmv/libmv/simple_pipeline/pipeline.cc +++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc @@ -277,11 +277,12 @@ double InternalReprojectionError( double total_error = 0.0; vector markers = image_tracks.AllMarkers(); for (int i = 0; i < markers.size(); ++i) { + double weight = markers[i].weight; const typename PipelineRoutines::Camera *camera = reconstruction.CameraForImage(markers[i].image); const typename PipelineRoutines::Point *point = reconstruction.PointForTrack(markers[i].track); - if (!camera || !point) { + if (!camera || !point || weight == 0.0) { num_skipped++; continue; } @@ -289,8 +290,8 @@ double InternalReprojectionError( Marker reprojected_marker = PipelineRoutines::ProjectMarker(*point, *camera, intrinsics); - double ex = reprojected_marker.x - markers[i].x; - double ey = reprojected_marker.y - markers[i].y; + double ex = (reprojected_marker.x - markers[i].x) * weight; + double ey = (reprojected_marker.y - markers[i].y) * weight; const int N = 100; char line[N]; -- cgit v1.2.3