Commit Graph

449 Commits

Author SHA1 Message Date
Sameer Agarwal 67ccb7379e Fix broken build.
Change-Id: Ieb122bb96d5776f962fff6d6e9345dfc855bfed7
2013-07-03 06:28:34 -07:00
Sameer Agarwal 4f010b2db0 Improve Summary::FullReport when line search is used.
Disable reporting of preconditioner when direct factorization
is being used.

Change-Id: Id264d2292c5cab608724a6a8fab5d588db950468
2013-07-01 08:01:01 -07:00
Sameer Agarwal 09244015e3 Expose line search parameters in Solver::Options.
Change-Id: Ifc52980976e7bac73c8164d80518a5a19db1b79d
2013-06-30 22:51:21 -07:00
Sameer Agarwal 1c70ae9aa6 Fix Solver::Summary when line search is used.
Also enable line search in bundle_adjuster.

Change-Id: Ic4343a4334b9f5a6fdeab38d4e3e1f6932bbc601
2013-06-30 12:50:43 -07:00
Alex Stewart 70b06c89c7 Fix update of L-BFGS history buffers after they become full.
Previously there was an assignment dimension mismatch in the
history update; thus, over time, the history would contain
(only) replicated copies of the (max_num_corrections_ -1)-th
update and the most recent update.

Change-Id: I26203acf689686d41a5029c675ebbe001fe05d90
2013-06-30 18:49:56 +01:00
Sameer Agarwal a427c877f9 Lint cleanup.
Change-Id: Ie489f1ff182d99251ed8c0728cc6ea8e1c262ce0
2013-06-24 18:04:28 -07:00
Sameer Agarwal 6a7c1037d9 Remove dead code that depends on protobuf support.
Change-Id: I9dc948f25f492af6d8de7987a32ba7afc20b81da
2013-06-24 17:21:02 -07:00
Sameer Agarwal 79d9353036 Remove Protocol Buffers support.
Change-Id: I451c543c82cdfb566736aab94d836abcfb5c689d
2013-06-24 14:28:40 -07:00
Sameer Agarwal 5d00bf40f5 Fix the broken build.
1. When protocol buffers support is enabled CompressedRowSparseMatrix
   has a missing virtual method.
2. When SuiteSparse is missing, covariance_test tries to run the
   large scale covariance computation test.

Thanks to Alex Stewart for reporting #1.

Change-Id: I4238c966036362175e31749595ea8bb6f12a696c
2013-06-24 13:24:35 -07:00
Sameer Agarwal c367b12eeb Incomplete LQ Factorization.
Drop support for protocol buffers.
Add CompressedRowSparseMatrix::CreateBlockDiagonalMatrix.
Add CompressedRowSparseMatrix::SolveLowerTriangularInPlace.
Add CompressedRowSparseMatrix::SolveLowerTriangularTranposeInPlace.
Add CompressedRowSparseMatrix::Transpose.

Change-Id: I2328afca9fac632685eac72ebb00998bd3510187
2013-06-23 21:45:57 +00:00
Sergey Sharybin 72cc457a43 Fix configuration error on systems without SuiteSparse installed
Issue was caused by the way how SUITESPARSE_FOUND was set and
used in IF conditions later. Basically, SUITESPARSE_FOUND was
setting to a value which needed to be expanded using ${} to get
it's actual value.

Made it so SUITESPARSE_FOUND is setting to either TRUE or FALSE
from an IF condition which does check for whether all the
dependencies are met.

Also removed expanding some of the variables in IF conditions,
they're not needed actually.

Change-Id: Iad01a3a49fb500375e344e5352a56a0c89be3b5a
2013-06-23 21:12:20 +00:00
Arnaud Gelas 044786669d Enforce the read call returns correct value
fix compilation error on Ubuntu 12.0

In file included from /usr/include/fcntl.h:252:0,
                 from /home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc:91:
/home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc: In member function ‘T {anonymous}::EndianAwareFileReader::Read() const [with T = unsigned char]’:
/home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc:300:5: error: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]

Change-Id: Ib23ca19778761bbfe0d77bcf32a2181ce6db1a12
2013-06-21 16:05:15 +02:00
Sergey Sharybin 8b26cc7d35 Fix compilation error on systems without SuiteSparse installed
Issue was caused by declaring class PerThreadContext with some
members of choldmod-specific types. This class in only used from
an #ifndef CERES_NO_SUITESPARSE block and solved compilation error
by simply wrapping PerThreadContext with the same #ifndef block.

Change-Id: Icdc329073fcbd4a328e41ea8c0af0962e9c34ba8
2013-06-19 21:04:02 +06:00
Richard Stebbing 6dd18563a1 Fix DynamicAutoDiffCostFunction
Changed DynamicAutoDiffCostFunction to handle multiple derivative
sections as opposed to just a single contiguous block.

In the previous implementation it was assumed that non-constant
parameters occur in a single contiguous block so that constant
parameters could NOT lie between non-constant parameters. Previously,
start_derivative_section was first set as soon as the first
non-constant parameter block (marked by jacobians[i] != NULL) was
encountered. After this, entries in input_jets[parameter_cursor].v were
accessed with `parameter_cursor - start_derivative_section`. For
contiguous non-constant parameter blocks this is fine, but if constant
parameter blocks fall between then this indexing is incorrect because
`parameter_cursor - start_derivative_section` can go out of bounds.

For a concrete example, take a cost function with three parameter
blocks, each of size 1 and with the center block fixed. Assume that
Stride=1 so that two passes are required. On the first pass
start_derivative_section=0, and the first variable block is handled
correctly. At the end of the first pass end_derivative_section=1, so
for the second pass start_derivative_section=1. Now comes the problem.
When parameter_cursor=1, parameter_cursor >= start_derivative_section
so jacobian[1] is checked to be NULL. Since it is NULL (second
parameter block is constant) then nothing is done and
active_parameter_count is NOT incremented. Next, when
parameter_cursor=2, parameter_cursor >= start_derivative_section and
jacobian[2] is checked. Since it is not NULL then
input_jets[parameter_cursor].v[parameter_cursor -
start_derivative_section] is set to 1.0, BUT parameter_cursor -
start_derivative_section = 2 - 1 = 1 which is out of bounds
(input_jets[parameter_cursor].v is only of size Stride=1).

The proposed solution records the start of each contiguous block of
non-constant parameters and indexing into
input_jets[parameter_cursor].v is independent of parameter_cursor.

Change-Id: I388ab6a0bafa35d317491135ec6fe980453ff888
2013-06-19 02:24:31 +01:00
Johannes Schönberger 1b89595b4c Fix Problem::RemoveParameterBlock documentation
Ordering of Problem::RemoveParameterBlock and Problem::RemoveResidualBlock
changed, as RemoveResidualBlock is being referred in RemoveParameterBlock
with "above".

Change-Id: I07f8e7b7e20ba239a72c15ed9e79576f5def090a
2013-06-16 14:35:06 +02:00
Sameer Agarwal a7eb1d5fab Lint cleanup
Change-Id: I77e84d21e62a0316cab211aafa243d0e11bd8858
2013-06-14 10:25:33 -07:00
Sameer Agarwal 6445bb1a46 Fix a logging bug in parameter_block.h
Not entirely sure how and why this was compiling up till now.

Thanks to Carlos Hernandez for reporting this.

Change-Id: Ieadbb8cb0a3769afe9dcef927ff0287342e44f1f
2013-06-14 10:21:48 -07:00
Sameer Agarwal 2f1454faf2 Add a templated TypedPreconditioner class.
This sets the stage of preconditioners that can utilize
different kinds of matrix layouts, just like the LinearSolver
class hierarchy.

Change-Id: I3579cf344bcd2eeeecb1ae621cab02a3c9a0f920
2013-06-13 23:49:19 -07:00
Sameer Agarwal 85b7e9d3c1 Fix an uninitialized variable warning when building with GCC.
Change-Id: I6f24553a9c4dfb59e05778f19406aefa058b6342
2013-06-13 23:01:01 -07:00
Sameer Agarwal c4a329155c Enable support for dumping trust region minimizer problems.
This support was broken due to the TrustRegionMinimizer refactoring.
It is now enabled again, with the responsibilty for dumping the
problem shifted to the individual TrustRegionStrategy.

There is however one wrinkle, which is perhaps an indication of
poor design to start with. The LinearLeastSquaresProblemProto
carries in it num_eliminate_blocks, something which does not
exist anymore. More importantly, the TrustRegionStrategy does not
have access to this quantity anymore.

Dealing with this will be the subject of a future change.

Change-Id: I358adf6a2e386f4940b617bf950d6c7e87d2635d
2013-06-13 22:00:48 -07:00
Sameer Agarwal 5f433c8a22 Fix a reallocation bug in CreateJacobianBlockSparsityTranspose.
CreateJacobianBlockSparsityTranspose starts with a conservative
estimate of the size of the block sparsity pattern of the Jacobian.
When the Jacobian has more non-zeros than that, the TripletSparseMatrix
being used to store the sparsity has a Reallocate method which
allows one to resize the matrix and IF num_nonzeros is set, then the
existing values in the array are also copied into the newly allocated
memory.

Unfortunately the pattern we follow in ceres code is to call
set_num_nonzeros after one is done populating the sparsity pattern
of a matrix. This does not mix well with Reallocate and results
in the matrix having uninitialized memory.

This patch fixes this problem and adds a test that verifies the fix.

Thanks to Yuliy Schwartzburg for reporting this bug and providing
code to reproduce it.

Change-Id: I58583714ffaebd880d85af16e3685b2d6ee053e8
2013-06-13 06:57:58 -07:00
Sameer Agarwal 1f17f56c4e Add Covariance documentation to html docs.
Change-Id: I11ddc9f7069964596760c6ea4d85c44312c0a67a
2013-06-09 23:23:38 -07:00
Sameer Agarwal f3e1267aa1 Update the documentation for Covariance.
Remove some of the dire warnings about instability
as the implementation is reasonably stable.

Change-Id: I3b64cab04e4cda54c671fcf8a2ca5d95c15037bf
2013-06-04 21:52:12 -07:00
Sameer Agarwal d48feb838e Lint cleanup
Change-Id: Ia342b1203aa690e5380aeca20e5adec29a388835
2013-06-04 16:47:50 -07:00
Sameer Agarwal 8f7e8963cb Multithread covariance estimation.
1. Multithread the inversion of J'J.
2. Simplify the dense rank truncation loop.
3. Minor correction to building documentation.

Change-Id: Ide932811c0f28dc6c253809339fb2caa083865b5
2013-06-04 16:19:45 -07:00
Sameer Agarwal 4437639e9b Documentation updates.
1. Further tightening of the Covariance documentation.
2. Documented minimizer progress output.
3. Lint cleanup from William Rucklidge.
4. Updated version history.

Change-Id: I8bc28484675d4edf89a7c050b6379dbac6c39e91
2013-06-03 09:41:27 -07:00
Sameer Agarwal 7129cd3157 Pay attention to condition number in covariance estimation.
1. Sparse covariance estimation now uses cholmod_rcond to
detect singular Jacobians.

2. Dense covariance estimation now uses relative magnitude
of singular/eigen values to compute the pseudoinverse.

3. Truncation logic is now unified with Solver::Options::null_space_rank.

Change-Id: I095bd737510c836b4251255926190a7f31d64bce
2013-06-02 23:36:27 -07:00
Sameer Agarwal 0f6161ba60 Add a define for O_BINARY.
Also make libmv_bundle_adjuster more verbose by default.

Change-Id: Ie8c7c4d9eed737681382bcfe61e39174d5e3420d
2013-06-01 16:34:54 -07:00
Sergey Sharybin 9869c3dd44 Libmv bundle adjuster example application
Add example application which is based on bundle
adjustment code from Libmv library, which is heavily
used in Blender.

Apart from bundle adjustment code this commit also
contains real-life optimization problems from VFX
pipeline. This files are created from production
files of Tears of Steel movie.

New code is placed to examples, and could be used
either as an example implementation of BA or for
timing investigation of problems appearing in VFX.
Problems for this application are placed to
data/libmv-ba-problems.

Usage:
  ./libmv_bundle_adjuster --input=/path/to/problem_file.bin

There's also optional flag --refine_intrinsics which
declares explicitly whether intrinscis shall be
refined or not. If this flag is not passed, refinement
will happen for problems stored in image space.

Structure of problem files is described in header
comment of libmv_bundle_adjuster.cc.

Change-Id: I51202848c75dcd7612b707609e5ff3708e01b625
2013-06-01 17:08:31 +00:00
Sergey Sharybin f806576cf2 Collections port fix for MSVC 2008
Apparently, TR1 symbols are defined in different namespace
comparing to MSVC 2010, which lead to compilation error when
using MSVC 2008.

Change-Id: I4fa3ceae4b4e2c6e7a46b1fb5b498640e7b18b74
2013-06-01 17:07:00 +00:00
Sameer Agarwal 14297c977c Fix a grammo
Change-Id: I0b9d21cc17772902343430d7a05b31d1f52785ed
2013-05-31 16:44:22 -07:00
Sameer Agarwal ae6aad05fb Move citation information to the main page
Change-Id: Id8b803ac0ddb02390a422197565ec5e74378304f
2013-05-31 21:01:48 +00:00
Sergey Sharybin 2a3827e13d Compilation error fixes
- In C you're not allowed to define variables in the middle
  of the block. This was violated in curve_fitting.c by
  calling ceres_init() in the beginning of main() and declaring
  variables later.

- Also ifdef-ed suitesparse stuff in covariance estimation module.
  This solves compilation error when you don't have suitesparse
  compiled/installed.

Change-Id: I22b543c09ea01f55e127079daade99a0b781f789
2013-05-31 20:33:42 +00:00
Sameer Agarwal f0b071bac4 Lint and other fixes from William Rucklidge
Change-Id: Ic18561a5cdadccc75e97818fa4422bb5d9d43df9
2013-05-31 13:22:51 -07:00
Sameer Agarwal 0939632c57 More documentation updates
Change-Id: I762bd28b4ebc327d39a572990e02157ef55ad617
2013-05-30 07:39:38 +00:00
Johannes Schönberger a8d38d438a Add sinh, cosh, tanh and tan functions to automatic differentiation
Change-Id: I6eb43fe9b340d4074ed3eed1461dda315f6e8ce8
2013-05-30 00:39:43 +02:00
Sameer Agarwal eb04dc10c5 Minor fix to tutorial.rst
Change-Id: Idb4408dedf81ff96732b27b4e04cbaed9f257bf4
2013-05-28 11:01:20 -07:00
Sameer Agarwal ebbb984db8 Various corrections and enhancements to the documentation.
Change-Id: I03519bfccf4367b36d36006f1450d5fbcbbf8621
2013-05-28 10:37:01 -07:00
Sameer Agarwal 97e1795704 Minor documentation fixes
Change-Id: Ic531475acf2386b6f5839d2434bdcc1e4c730d14
2013-05-26 11:48:09 -07:00
Pablo Speciale 0ff3bb3197 CeresConfig.cmake (and similar files) will be installed in "${CMAKE_INSTALL_PREFIX}/cmake/Ceres" after make install
Change-Id: I724e446a01f60de56714f2f63b161d0cfd1b8fd7
2013-05-24 18:08:34 +00:00
Sameer Agarwal f9e9d6ef36 Declare the iterator variable outside the loop in curve_fitting.c
Change-Id: I4ce703c8d6a6deb3aebaccd3cd5d916c7aa4f92e
2013-05-24 15:06:53 +00:00
Pablo Speciale dbc398d66e Rodriques instead of Rodriquez (he was french), and other minor erros in documentation
Change-Id: Icb56acffb373f064314ecda1e91a728cfacd07b4
2013-05-24 02:43:16 +00:00
Sameer Agarwal 9f9488b162 Add iteration and time reporting for inner iterations.
Also

1. Remove an inadvertent LOG(INFO) from trust_region_minimizer.cc
2. Refactor some of the code in FullReport to reduce duplication
   across line search and trust region minimizers.
3. Consistent capitalization.

Change-Id: I9078b1704efab23d2858530636f524e60c7d9016
2013-05-23 21:03:31 +00:00
Sameer Agarwal 395b4e9dea Documentation fixes
Thanks for Stephan Wirth.

Change-Id: I1dc3c0ab15d97888fdfaa3814d80a3c529665731
2013-05-23 12:49:35 -07:00
Sameer Agarwal d4cb94b6d6 Add adaptive stopping to inner iterations.
Change-Id: I83c909b8b87f1320aa30dcc80ac43a63765b9181
2013-05-22 20:04:57 +00:00
Sameer Agarwal 07f208fd6d Speed up corrector.cc
Remove the Eigen temporary by revealing the columnwise nature
of the computation. This also allows us to get rid of the
special case for nrow = 1.

On problem-356-226730-pre.txt with -robustify evaluation times
change from:

Before:
  Residual Evaluations                  1.015
  Jacobian Evaluations                 18.313

After:
  Residual Evaluations                  1.005
  Jacobian Evaluations                  8.382

To give a sense of the overhead reduction, compare these numbers
when loss functions are disabled.

  Residual Evaluations                  0.955
  Jacobian Evaluations                  7.772

So, this is a 17.5x speedup!

The one dimensional specialization was motivated by denoising.cc.
The evaluation times there are essentially unchanged.

Before:
  Residual Evaluations                  2.774
  Jacobian Evaluations                 20.178

After:
  Residual Evaluations                  2.588
  Jacobian Evaluations                 19.781

Change-Id: Ic0efbaed75fe4489635039f17189ae24b97802c8
2013-05-22 12:58:58 -07:00
Sameer Agarwal df0125666a Add profiling to covariance estimation.
Prevent GetCovarianceBlock from being called before
Compute or when Compute failed.

Change-Id: I5c28d27a88081e230d316c5e365d3e21d6e23376
2013-05-21 15:12:21 -07:00
Sameer Agarwal 45ac14fac7 Add destructor to Covariance.
This allows CovarianceImpl to be forward declared without
scoped_ptr freaking out.

Thanks to Nima Keivan for reporting this.

Change-Id: Icd5aa766b3aab70246055225231a4b971c6b7b90
2013-05-20 09:16:28 -07:00
Sameer Agarwal 096d5934a2 Comment cleanup from Jim Roseborough
Change-Id: Id47101fe32e1449e660ec536934ee91fdaf452c7
2013-05-20 08:49:09 -07:00
Sameer Agarwal b99550dc9a Add BlockRandomAccessCRSMatrix.
Change-Id: I4b88402e2216c6ea2728472e2f89479d368dbd4b
2013-05-19 12:47:48 -07:00