Commit Graph

161 Commits

Author SHA1 Message Date
Sameer Agarwal b9f15a5936 Add a dense Cholesky factorization based linear solver.
For problems with a small number of variables, but a large
number of residuals, it is sometimes beneficial to use the
Cholesky factorization on the normal equations, instead of
the dense QR factorization of the Jacobian, even though it
is numerically the better thing to do.

Change-Id: I3506b006195754018deec964e6e190b7e8c9ac8f
2012-08-19 14:47:38 -07:00
Arnaud Gelas b3fa009435 Set CMAKE_*_OUTPUT_DIRECTORY
Gather
 * all executables in ${CMAKE_BINARY_DIR}/bin
 * all libraries (static and dynamic) in ${CMAKE_BINARY_DIR}/lib

Change-Id: Ibc2fa1adfb6f0aea65d66d570259b79546bf3b07
2012-08-19 08:30:14 -07:00
Sameer Agarwal 1b8a4d5d11 Fix a minor bug in detect_structure logging.
Change-Id: I117f7745e4c67595b3ff9244cde82b5b5b34ee4b
2012-08-17 16:56:10 -07:00
Keir Mierle 31c1e784ab Minor cleanups.
Change-Id: Ida4866997deeaa1bc2cebd6b69313a05ac82e457
2012-08-17 16:16:32 -07:00
Sameer Agarwal e83f7879a8 Fix SuiteSparse3 UFConfig.h detection really.
Change-Id: Id187102e755b7d778dff4363f22f9a4697ed12dd
2012-08-17 15:37:39 -07:00
Sameer Agarwal 96f25dc576 Fix SuiteSparse3 UFConfig.h detection.
Change-Id: Ia59aefdb0ad7f713f76ed79692f2db4fa2821e5b
2012-08-17 15:34:42 -07:00
Markus Moll c497bd6cd9 Add UFconfig and/or SuiteSparse_config test to CMakeLists.txt
SuiteSparse 4 requires linking to libsuitesparseconfig.a.
Both SuiteSparse 3 and SuiteSparse 4 require an additional header
(either UFconfig.h or SuiteSparse_config.h) that is not found if it is
in a separate path. Therefore, add explicit checks.

Change-Id: I699902b5db4f1b7f17134b5a54f9aa681445e294
2012-08-17 15:15:01 -07:00
Sameer Agarwal 383c04f423 Fix QuaternionToAngleAxis to ensure rotations are between -pi and pi.
Thanks to Guoxuan Zhang for reporting this.

Change-Id: I2831ca3a04d5dc6467849c290461adbe23faaea3
2012-08-17 14:32:23 -07:00
Sameer Agarwal dd2b17d7dd CERES_DONT_HAVE_PROTOCOL_BUFFERS -> CERES_NO_PROTOCOL_BUFFERS.
Change-Id: I6c9f50e4c006faf4e75a8f417455db18357f3187
2012-08-17 13:21:33 -07:00
Sameer Agarwal 8b4cb7aa2c Fix sparse linear algebra library logging in Summary::FullReport.
Change-Id: Id2c902dc86c00954fde7749c7b4a67dd94215a31
2012-08-17 13:20:06 -07:00
Markus Moll 47d26bcd3b Do not implicitly negate the step in the TrustRegionMinimizer.
In the TrustRegionMinimizer, the step is currently implicitly negated.
This is done so that the linearized residual is |r - J*step|^2, which
corresponds to J*step = r, so neither J nor r have to be modified.
However, it leads to the rather unintuitive situation that the strategy
returns a step in positive gradient direction, which you would expect to
increase the function value. One way is to rename the "step" parameter in
the strategy to "negative_step" and document it.
This patch instead moves the negation inside the strategy, just around
the linear solver call, so that it is done in a local context and easier
to document.

Change-Id: Idb258149a01f61c64e22128ea221c5a30cd89c89
2012-08-17 13:19:14 -07:00
Markus Moll 51da590c84 Remove tmp file
Change-Id: I07496fafae7b0c5c12cc26ae336e0db3b5592735
2012-08-17 12:56:09 +02:00
Sameer Agarwal 7006a1f2b1 Correct example code in Powell's function example.
Thanks to Petter Strandmark for pointing this out.

Change-Id: I967632235dccdb481396e94904bb911c9a1efe1e
2012-08-16 18:04:22 -07:00
Keir Mierle 57a44b27bc Remove unnecessary flags in NDK build.
Change-Id: Ib5b4d0b7f2d898671252734978c789b8171d96a8
2012-08-16 17:04:50 -07:00
Keir Mierle f21bee2472 Fix for fpclassify.h NDK porting work.
Change-Id: I69df1b4caf2941ed96a53e35e43ec54073f84f59
2012-08-16 17:02:43 -07:00
Keir Mierle 8ceb02cb75 Add Android NDK build files.
This adds a Android.mk build that builds a Ceres static library
suitable for embetting in larger Android applications. This is
useful when needing to build Ceres without GPL'd components, since
the standalone toolchain (needed for the CMake Android build) does
not work with STLPort.

Change-Id: I8d857237f6f82658741017d161b2e31d9a20e5a7
2012-08-16 16:31:23 -07:00
Keir Mierle 6185db22f8 Fix STLPort fpclassify portability.
Change-Id: I9418c05a160aa635574370c5e35424566781dcb0
2012-08-16 14:22:53 -07:00
Keir Mierle 5c4467873e Fix a memory leak in the LM strategy test.
Change-Id: I7c4ed74dee60f869fee9395b74a9dfc77703f2ee
2012-08-16 11:40:57 -07:00
Markus Moll d3dce27c65 Fix early return in DoglegStrategy::StepAccepted
In StepAccepted, reuse_ was not cleared if the improvement was not good
enough. This is obviously wrong as the step was taken nevertheless and
the computed entities may be completely different at the new iterate.

Change-Id: I4bf3441f71550a0595dd8c5565aedd38d03e8b2f
2012-08-16 17:27:36 +02:00
Keir Mierle d216490ce0 Support building without TR1.
Change-Id: Ib59e201198e1ff2621626ab80e6b6f2156f0d1d1
2012-08-15 19:05:20 -07:00
Markus Moll a3fb17c8de Use elliptical trust region in DoglegStrategy.
In the Levenberg-Marquardt algorithm, the diagonal of J^T J is used to
regularize the problem. This corresponds to an elliptical trust region
|| D step || <= r, where D = sqrt(diag(J^T J)).

This commit adds the same elliptical trust region to the dogleg
strategy. The trust region problem becomes

  min. x^T H x + g^T x
  s.t. || D x || <= r

By substituting y = D x, it becomes

  min. y^T D^-1 H D^-1 y + g^T D^-1 y
  s.t. || y || <= r

which is the traditional spherical trust region problem.
This commit changes the DoglegStrategy so that the Gauss-Newton point,
the gradient, and the Cauchy point are scaled correctly (without
modifying the Jacobian directly). Then the dogleg step is computed the
same way as before, and finally the step is rescaled to obtain
x = D^-1 y.

Change-Id: Iea25a9113ecba911b746e269bc6e6fe51cb59003
2012-08-15 12:01:13 -07:00
Sameer Agarwal ceda487ed8 Minor correction to the README file.
Change-Id: Ic41672692be9d924cebfa8bb4b42b628a49b8bdf
2012-08-14 14:47:13 -07:00
Keir Mierle 8e68ff395b Zero-initialize Jet derivative components.
Change-Id: I9606aadb1a1f275608f6f332858af9258a120b05
2012-08-14 14:40:42 -07:00
Sameer Agarwal 62f50d1466 Move internal/ceres/mock_log.h to internal/ceres/gmock/mock-log.h
Change-Id: I652b25b7bfb56edf814d73f2dd7c796f9af983d5
2012-08-14 14:26:13 -07:00
Sameer Agarwal 9bdb6cc759 Rename macro to avoid namespace conflicts.
Change-Id: Iecf00f67dcd6250d6919875cee79a600fccab039
2012-08-14 13:02:20 -07:00
Sameer Agarwal c6bbecf26d Consolidate path handling for test data files.
Added CERES_TEST_SRCDIR_POSTFIX macro.
Added TestFileAbsolutePath function.

Change-Id: I223b74af027bfb775447e062edab897395b21514
2012-08-14 11:35:13 -07:00
Sameer Agarwal bc0a857fce Remove unused variable in evaluate_test.cc
Change-Id: Id5a4abb35d4b86c67dc2c9b0ac59a4950825a23d
2012-08-14 08:27:26 -07:00
Sameer Agarwal 0beab86dfa Fix glog includes and include sorting order.
Change-Id: I0ec85218e82d1714279d41f7635104d480fb91c3
2012-08-13 15:47:24 -07:00
Sameer Agarwal 4b0404352d data_fitting.cc should include gflags.
Also fix glog/gflag includes and sorting in examples.

Change-Id: Ie07563b99cbb9172c941bb8f5fb7decb95fbb5d1
2012-08-13 15:09:34 -07:00
Keir Mierle f18cc4a0d0 Fix copy and paste error.
Change-Id: Ie28196d44e163d26b09131687ef56f5f8cc77ac7
2012-08-13 11:36:17 -07:00
Sameer Agarwal 36a3309c84 Add the ability to normalize BALProblem.
Refactor some of the perturbation code so that the
normalization and perturbation code can share the
camera decomposition code.

Change-Id: I084064976804a92f9240d8f5e10d1bb23dcb5ff2
2012-08-13 07:17:14 -07:00
Markus Moll 214561083b Add WriteToFile function to BALProblem.
Change-Id: I1a4f14dad650fbb2103ee8b897889ac6194a084c
2012-08-11 07:01:34 -07:00
Sameer Agarwal a477273604 Make the camera center perturbation consistent.
The camera perturbation is now done so that after
the perturbation, the translation vector can still
be transformed back into the perturbed camera center.

Change-Id: Ib9e854e2456b2b33669724f348bb37c2d3b40dcd
2012-08-10 18:02:15 -07:00
Keir Mierle ff71d74967 Further encapsulate Ceres's Mutex class.
There are cases where one wishes to link Ceres against another
application or library which uses a mutex implementation with
similar ancestry to the one in Ceres. In those cases there are
problems due to macro interactions which can't be contained with
namespaces.

This further isolates the Ceres Mutex class by adding CERES_
prefix to all the macros and also working around a macro name
clash with MutexLock by renaming the MutexLock class to
CeresMutexLock.

Change-Id: I923f4427d5939823ea67d48005a90391736d7751
2012-08-10 17:56:38 -07:00
Sameer Agarwal 8d2e922a28 Perturb camera center instead of translation vector.
Change-Id: I636c84566be2596dd7b4eeab0bb511de597be111
2012-08-10 17:04:48 -07:00
Keir Mierle aff5a45378 Use the correct namespace for tr1 references.
Change-Id: I130bf9a7c811a2ec14425e007108279e60296035
2012-08-10 16:58:56 -07:00
Keir Mierle 716e2945fe Fix initialization order.
Change-Id: Ia854ce2878b5d39e167176556cccaadea4c98068
2012-08-10 16:53:37 -07:00
Keir Mierle d16c34fb4a Explicitly import string into the Ceres namespace.
This is a workaround for anyone building Ceres in an environment
where there is a non-standard string implementation in the global
namespace. Due to the way the standard is written, a "using
namespace X" import is not high enough precedence to resolve a
naked reference to "string". Instead, by explicitly importing
string, the lookup becomes unambiguous.

Change-Id: I8d70463de01c482796c5bc09da05b37d21e7af96
2012-08-10 16:44:52 -07:00
Keir Mierle 4d84182acc Remove unused variable.
Change-Id: Ic8de7931be8ac51f583eaa5da73178aa0a38122b
2012-08-10 16:41:00 -07:00
Sameer Agarwal 1b7f3b52fb Add ability to log solver execution to file.
Change-Id: I9996ba2fed5229fe5d621fbb1a027d4c360cd59d
2012-08-10 15:55:31 -07:00
Sameer Agarwal faa117a7e9 Fix off by one errors in perturbation code.
Change-Id: I42cfc59b71e13e3163779ed6703073320298f948
2012-08-10 14:30:44 -07:00
Sameer Agarwal 5476df506e Randomly perturb the bundle adjustment problem.
1. Add the ability to perturb the camera pose and the
point positions using user specified parameters.
2. Re-order the flags.
3. Minor name correction.
4. Added Box-Mueller generator to random.h

Change-Id: I2c9ce74c237f5bde9a7299cc71b205d1ca9bc742
2012-08-10 11:33:59 -07:00
Sameer Agarwal a8f87d7943 Non-monotonic trust region algorithm.
Non-monotonic trust region algorithm based on the work of Phil Toint, as
described in

Non-monotone trust region algorithms for nonlinear
optimization subject to convex constraints.
Philippe L. Toint
Mathematical Programming 77 (1997), 69-94.

Change-Id: I199ecc644e8d1a8cb43666052aef66fb93e15569
2012-08-10 11:09:12 -07:00
Markus Moll 82b689a5fd Close the bal_problem file when done reading it.
Change-Id: I2755822cd2caf4019059e5b4a50f30077142e37f
2012-08-10 14:21:43 +02:00
Keir Mierle ebcfdf4c65 Fix formatting in the polynomial rootfinder.
Change-Id: I771793bbabad30cdc4b369d37cae846e541c6f77
2012-08-08 10:33:06 -07:00
Keir Mierle 254f9d3828 Fix Windows build break.
Change-Id: I8b2b4c795429fd10ceeff83016825f1a9a8e305d
2012-08-02 21:30:46 -07:00
Sameer Agarwal 2278ec4f9e Fix off by one error in the polynomial solver
Change-Id: I682525a911ce62b6e057072ce396723c7249df1b
2012-08-02 18:57:18 -07:00
Keir Mierle aefb8a8cf2 Preliminary Android port of Ceres
This change adds several of the pieces needed to build Ceres on
Android. The port is incomplete, since GFlags doesn't build which
causes the tests to not build. However, simple_bundle_adjuster
builds and runs on the phone.

Thanks to Scott Ettinger for the original version of the minimal
GLog implementation which made this port possible. The Ceres logs
go to the various Android logging levels, as documented in
miniglog/glog/logging.h.

To control the Android build, this adds a new CMake build option:

  -DBUILD_ANDROID=ON/OFF

However, users may not want to set this manually, and should
instead run the script found in android/build_android.sh. The
script calls the NDK to make a standalone toolchain, downloads the
android-cmake toolchain, then configures CMake to cross-compile
Ceres to Android.

Note: At time of writing, the android-cmake toolchain that the
script downloads from Google Code doesn't work with the latest
Jellybean NDK. It's possible to manually hack the toolchain file
to make it build by setting the compiler version and manually
setting the path to the STL includes. I don't yet have a patch
suitable for upstreaming to http://android-cmake.googlecode.com.

Change-Id: Icb615be203145e87413d6acd05883171a395499d
2012-08-02 18:35:16 -07:00
Keir Mierle d2a5ab6500 Use C99 macros on Android for fpclassify.h
Change-Id: I7118f05b436afadbff5369ce40d5b9ab95e8a437
2012-07-26 14:31:56 -07:00
Markus Moll c9eca7812a Add a polynomial solver
Add a function to find the (complex) roots of a polynomial
with real coefficients. The roots are extracted as the
eigenvalues of the (balanced) companion matrix. Also adds a test.
The polynomial solver will be needed in the Dogleg subspace
strategy.

Change-Id: Ia6626158819efb858522b7f4998649ca010d6688
2012-07-26 22:26:21 +02:00