Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-09-26 19:07:06 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-09-26 19:07:06 +0400
commit8615218d579cff461dc449b731e480f18817095e (patch)
tree9fbba059ac3ab245347543b70409014ff8b70175 /extern
parent503ec930f1704e52fe11b21d1c3ee2d213084bdc (diff)
Camera tracking integration
=========================== - If render size is set to "Full Render" and undistorted render is enabled, do on-fly undistortion so distortion coefficients can be visually verifed before baking. - Made slight change in libmv-side to survive with large distortion coefficients. Hope this change is fine.
Diffstat (limited to 'extern')
-rwxr-xr-xextern/libmv/bundle.sh4
-rw-r--r--extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc10
-rw-r--r--extern/libmv/patches/function_derivative.patch21
-rw-r--r--extern/libmv/patches/high_distortion_crash_fix.patch21
-rw-r--r--extern/libmv/patches/levenberg_marquardt.patch71
-rw-r--r--extern/libmv/patches/series3
6 files changed, 123 insertions, 7 deletions
diff --git a/extern/libmv/bundle.sh b/extern/libmv/bundle.sh
index 1f2e8f51668..352a56e2984 100755
--- a/extern/libmv/bundle.sh
+++ b/extern/libmv/bundle.sh
@@ -176,8 +176,6 @@ IF(WIN32)
string(REPLACE "${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endforeach()
ENDIF(MSVC)
-
- add_definitions(-DEIGEN_DONT_ALIGN_STATICALLY)
ELSE(WIN32)
list(APPEND SRC
${third_glog_sources}
@@ -234,8 +232,6 @@ ${win_src}
cflags_libmv = Split(env['REL_CFLAGS'])
ccflags_libmv = Split(env['REL_CCFLAGS'])
cxxflags_libmv = Split(env['REL_CXXFLAGS'])
-
- defs.append('EIGEN_DONT_ALIGN_STATICALLY')
else:
src += env.Glob("third_party/glog/src/*.cc")
incs += ' ./third_party/glog/src'
diff --git a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
index 4e88e1f6a5d..f9888ff3ae6 100644
--- a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
+++ b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
@@ -160,9 +160,13 @@ void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) {
if( iy < 0 ) { iy = 0, fy = 0; }
if( ix >= width-2 ) ix = width-2;
if( iy >= height-2 ) iy = height-2;
- //assert( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 );
- Offset offset = { ix-x, iy-y, fx, fy };
- grid[y*width+x] = offset;
+ if ( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 ) {
+ Offset offset = { ix-x, iy-y, fx, fy };
+ grid[y*width+x] = offset;
+ } else {
+ Offset offset = { 0, 0, 0, 0 };
+ grid[y*width+x] = offset;
+ }
}
}
}
diff --git a/extern/libmv/patches/function_derivative.patch b/extern/libmv/patches/function_derivative.patch
new file mode 100644
index 00000000000..be7ccfc911a
--- /dev/null
+++ b/extern/libmv/patches/function_derivative.patch
@@ -0,0 +1,21 @@
+diff --git a/src/libmv/numeric/function_derivative.h b/src/libmv/numeric/function_derivative.h
+index 0075d23..d7bc437 100644
+--- a/src/libmv/numeric/function_derivative.h
++++ b/src/libmv/numeric/function_derivative.h
+@@ -24,6 +24,7 @@
+ #include <cmath>
+
+ #include "libmv/numeric/numeric.h"
++#include "libmv/logging/logging.h"
+
+ namespace libmv {
+
+@@ -97,7 +98,7 @@ bool CheckJacobian(const Function &f, const typename Function::XMatrixType &x) {
+
+ typename NumericJacobian<Function>::JMatrixType J_numeric = j_numeric(x);
+ typename NumericJacobian<Function>::JMatrixType J_analytic = j_analytic(x);
+- //LG << J_numeric - J_analytic;
++ LG << J_numeric - J_analytic;
+ return true;
+ }
+
diff --git a/extern/libmv/patches/high_distortion_crash_fix.patch b/extern/libmv/patches/high_distortion_crash_fix.patch
new file mode 100644
index 00000000000..54ab66fa27c
--- /dev/null
+++ b/extern/libmv/patches/high_distortion_crash_fix.patch
@@ -0,0 +1,21 @@
+diff --git a/src/libmv/simple_pipeline/camera_intrinsics.cc b/src/libmv/simple_pipeline/camera_intrinsics.cc
+index 4e88e1f..f9888ff 100644
+--- a/src/libmv/simple_pipeline/camera_intrinsics.cc
++++ b/src/libmv/simple_pipeline/camera_intrinsics.cc
+@@ -160,9 +160,13 @@ void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) {
+ if( iy < 0 ) { iy = 0, fy = 0; }
+ if( ix >= width-2 ) ix = width-2;
+ if( iy >= height-2 ) iy = height-2;
+- //assert( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 );
+- Offset offset = { ix-x, iy-y, fx, fy };
+- grid[y*width+x] = offset;
++ if ( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 ) {
++ Offset offset = { ix-x, iy-y, fx, fy };
++ grid[y*width+x] = offset;
++ } else {
++ Offset offset = { 0, 0, 0, 0 };
++ grid[y*width+x] = offset;
++ }
+ }
+ }
+ }
diff --git a/extern/libmv/patches/levenberg_marquardt.patch b/extern/libmv/patches/levenberg_marquardt.patch
new file mode 100644
index 00000000000..49ef82d73d2
--- /dev/null
+++ b/extern/libmv/patches/levenberg_marquardt.patch
@@ -0,0 +1,71 @@
+diff --git a/src/libmv/numeric/levenberg_marquardt.h b/src/libmv/numeric/levenberg_marquardt.h
+index 6a54f66..4473b72 100644
+--- a/src/libmv/numeric/levenberg_marquardt.h
++++ b/src/libmv/numeric/levenberg_marquardt.h
+@@ -33,6 +33,7 @@
+
+ #include "libmv/numeric/numeric.h"
+ #include "libmv/numeric/function_derivative.h"
++#include "libmv/logging/logging.h"
+
+ namespace libmv {
+
+@@ -123,26 +124,40 @@ class LevenbergMarquardt {
+ Parameters dx, x_new;
+ int i;
+ for (i = 0; results.status == RUNNING && i < params.max_iterations; ++i) {
+- if (dx.norm() <= params.relative_step_threshold * x.norm()) {
++ VLOG(1) << "iteration: " << i;
++ VLOG(1) << "||f(x)||: " << f_(x).norm();
++ VLOG(1) << "max(g): " << g.array().abs().maxCoeff();
++ VLOG(1) << "u: " << u;
++ VLOG(1) << "v: " << v;
++
++ AMatrixType A_augmented = A + u*AMatrixType::Identity(J.cols(), J.cols());
++ Solver solver(A_augmented);
++ dx = solver.solve(g);
++ bool solved = (A_augmented * dx).isApprox(g);
++ if (!solved) {
++ LOG(ERROR) << "Failed to solve";
++ }
++ if (solved && dx.norm() <= params.relative_step_threshold * x.norm()) {
+ results.status = RELATIVE_STEP_SIZE_TOO_SMALL;
+ break;
+- }
+- x_new = x + dx;
+- // Rho is the ratio of the actual reduction in error to the reduction
+- // in error that would be obtained if the problem was linear.
+- // See [1] for details.
+- Scalar rho((error.squaredNorm() - f_(x_new).squaredNorm())
+- / dx.dot(u*dx + g));
+- if (rho > 0) {
+- // Accept the Gauss-Newton step because the linear model fits well.
+- x = x_new;
+- results.status = Update(x, params, &J, &A, &error, &g);
+- Scalar tmp = Scalar(2*rho-1);
+- u = u*std::max(1/3., 1 - (tmp*tmp*tmp));
+- v = 2;
+- continue;
+- }
+-
++ }
++ if (solved) {
++ x_new = x + dx;
++ // Rho is the ratio of the actual reduction in error to the reduction
++ // in error that would be obtained if the problem was linear.
++ // See [1] for details.
++ Scalar rho((error.squaredNorm() - f_(x_new).squaredNorm())
++ / dx.dot(u*dx + g));
++ if (rho > 0) {
++ // Accept the Gauss-Newton step because the linear model fits well.
++ x = x_new;
++ results.status = Update(x, params, &J, &A, &error, &g);
++ Scalar tmp = Scalar(2*rho-1);
++ u = u*std::max(1/3., 1 - (tmp*tmp*tmp));
++ v = 2;
++ continue;
++ }
++ }
+ // Reject the update because either the normal equations failed to solve
+ // or the local linear model was not good (rho < 0). Instead, increase u
+ // to move closer to gradient descent.
diff --git a/extern/libmv/patches/series b/extern/libmv/patches/series
index 80f0d2cdd42..8b0e7406634 100644
--- a/extern/libmv/patches/series
+++ b/extern/libmv/patches/series
@@ -3,3 +3,6 @@ snrptinf_fix.patch
bundle_tweaks.patch
fast.patch
config_mac.patch
+levenberg_marquardt.patch
+function_derivative.patch
+high_distortion_crash_fix.patch