[Bf-blender-cvs] [ce82e9e64a0] master: Libmv: Pass entire camera intrinsics to reprojection error functor

Sergey Sharybin noreply at git.blender.org
Mon Apr 20 16:27:14 CEST 2020


Commit: ce82e9e64a033c2ba0577316a203e2f4c892ed4b
Author: Sergey Sharybin
Date:   Mon Apr 20 11:19:47 2020 +0200
Branches: master
https://developer.blender.org/rBce82e9e64a033c2ba0577316a203e2f4c892ed4b

Libmv: Pass entire camera intrinsics to reprojection error functor

Currently no functional changes, but allows to have access to some
invariant settings of camera intrinsics such as image dimensions.

===================================================================

M	intern/libmv/libmv/simple_pipeline/bundle.cc

===================================================================

diff --git a/intern/libmv/libmv/simple_pipeline/bundle.cc b/intern/libmv/libmv/simple_pipeline/bundle.cc
index 25e63b219d1..b7d1e1e57fb 100644
--- a/intern/libmv/libmv/simple_pipeline/bundle.cc
+++ b/intern/libmv/libmv/simple_pipeline/bundle.cc
@@ -72,11 +72,11 @@ namespace {
 //
 // This functor uses a radial distortion model.
 struct OpenCVReprojectionError {
-  OpenCVReprojectionError(const DistortionModelType distortion_model,
+  OpenCVReprojectionError(const CameraIntrinsics *invariant_intrinsics,
                           const double observed_x,
                           const double observed_y,
                           const double weight)
-      : distortion_model_(distortion_model),
+      : invariant_intrinsics_(invariant_intrinsics),
         observed_x_(observed_x), observed_y_(observed_y),
         weight_(weight) {}
 
@@ -113,7 +113,7 @@ struct OpenCVReprojectionError {
     // Apply distortion to the normalized points to get (xd, yd).
     // TODO(keir): Do early bailouts for zero distortion; these are expensive
     // jet operations.
-    switch (distortion_model_) {
+    switch (invariant_intrinsics_->GetDistortionModelType()) {
       case DISTORTION_MODEL_POLYNOMIAL:
         {
           const T& k1 = intrinsics[OFFSET_K1];
@@ -158,7 +158,7 @@ struct OpenCVReprojectionError {
     return true;
   }
 
-  const DistortionModelType distortion_model_;
+  const CameraIntrinsics *invariant_intrinsics_;
   const double observed_x_;
   const double observed_y_;
   const double weight_;
@@ -376,7 +376,7 @@ void EuclideanBundlerPerformEvaluation(const Tracks &tracks,
 //
 // At this point we only need to bundle points positions, cameras
 // are to be totally still here.
-void EuclideanBundlePointsOnly(const DistortionModelType distortion_model,
+void EuclideanBundlePointsOnly(const CameraIntrinsics *invariant_intrinsics,
                                const vector<Marker> &markers,
                                vector<Vec6> &all_cameras_R_t,
                                double ceres_intrinsics[OFFSET_MAX],
@@ -399,7 +399,7 @@ void EuclideanBundlePointsOnly(const DistortionModelType distortion_model,
     problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
         OpenCVReprojectionError, 2, OFFSET_MAX, 6, 3>(
             new OpenCVReprojectionError(
-                distortion_model,
+                invariant_intrinsics,
                 marker.x,
                 marker.y,
                 1.0)),
@@ -439,7 +439,6 @@ void EuclideanBundlePointsOnly(const DistortionModelType distortion_model,
   ceres::Solve(options, &problem, &summary);
 
   LG << "Final report:\n" << summary.FullReport();
-
 }
 
 }  // namespace
@@ -520,7 +519,7 @@ void EuclideanBundleCommonIntrinsics(
       problem.AddResidualBlock(new ceres::AutoDiffCostFunction<
           OpenCVReprojectionError, 2, OFFSET_MAX, 6, 3>(
               new OpenCVReprojectionError(
-                  intrinsics->GetDistortionModelType(),
+                  intrinsics,
                   marker.x,
                   marker.y,
                   marker.weight)),
@@ -642,7 +641,7 @@ void EuclideanBundleCommonIntrinsics(
 
   if (zero_weight_markers.size()) {
     LG << "Refining position of constant zero-weighted tracks";
-    EuclideanBundlePointsOnly(intrinsics->GetDistortionModelType(),
+    EuclideanBundlePointsOnly(intrinsics,
                               zero_weight_markers,
                               all_cameras_R_t,
                               ceres_intrinsics,



More information about the Bf-blender-cvs mailing list