Commit Graph

850 Commits

Author SHA1 Message Date
Sergey Sharybin
1de23f6c0d Tweaks and improvements to fundamental/homography estimation
- A bit more reasonable name for the estimation option
  structure and estimation functions.

- Get rid of unclear function and parameter tolerance,
  it wasn't clear at all in which units they are.

  Now we've got expected_average_symmetric_distance as
  an early output check and as soon as average symmetric
  error goes below this threshold refining finishes.

  This distance is measured in the same units as input
  points are.

  It is arguable whether we need callback for this or not,
  but seems Ceres doesn't have some kind of absolute
  threshold for function value and function_tolerance
  behaves different from logic behind expected symmetric
  error.

- Added option to normalize correspondences before
  estimating the homography in order to increase estimation
  stability. See

    R. Hartley and A. Zisserman. Multiple View Geometry in Computer
    Vision. Cambridge University Press, second edition, 2003.

    https://www.cs.ubc.ca/grads/resources/thesis/May09/Dubrofsky_Elan.pdf
2013-11-20 15:30:28 +06:00
Campbell Barton
cf9edb2610 rangetree: support for building on freebsd-10 2013-11-16 18:31:13 +11:00
Jens Verwiebe
a3ec6edc05 OSX/scons: make MACOSX_SDK_CHECK a local var is sconstruct and remove from env, also fix a longstanding misuse of MACOSX_SDK_CHECK in ceres, use MACOSX_SDK instead 2013-11-08 13:44:10 +00:00
Sergej Reich
13caf5cc14 bullet: Remove patch applied upstream 2013-11-04 17:02:01 +00:00
Keir Mierle
427844c28d Eagerly attempt to refine a track before doing a brute search
Before the refinement phase of tracking, a brute force SAD search
is run across the search area. This works well but is slow;
especially if the guess for the track's location is accurate.

This patch runs a refinement phase before running a brute force
search, hoping that the guessed position (in x2, y2) is close to
the best answer. If it is, then no brute search is done. If it is
not, then a normal brute force search followed by refinement is
done.

In some cases this may produce worse tracks than before; the
regressions will need investigation. The predictive motion model
(to be implemented) will reduce the probability of that happening.
2013-10-29 01:06:50 +00:00
Keir Mierle
d10abe6d4d Fix bug where libmv tracking incorrectly succeeds on failure
Before this patch, if Ceres returned USER_SUCCESS indicating that
Ceres was only changing the tracked quad slightly between
iterations (indicating convergence), no final correlation check
was done. This leads to incorrectly returning that the tracking
was successful, when it actually failed.
2013-10-28 18:34:19 +00:00
Sergey Sharybin
9f32e83175 Weighted tracks
Added a weight slider to track which defines
how much particular track affects in a final
reconstruction. This weight is for sure
animateable.

Currently it affects on BA step only which in
most cases will work just fine.

The usecase of this slider is to have it set
to 1.0 most of the time where the track is
good, but blend it's weight down to 0 when
tracker looses the track. This will prevent
camera from jump.

Tutorial is to be done by Sebastian.
2013-10-26 13:22:38 +00:00
Sergej Reich
451b60f1a3 Fix building with scons
Can't actually test here so hope this is enough.
2013-10-25 03:56:17 +00:00
Sergej Reich
472a021aca bullet: Update to version 2.82 (bullet revision 2705)
Remove patch that has been applied upstream.

Fixes several bugs.
2013-10-25 03:43:20 +00:00
Sergey Sharybin
dc46febec8 Code cleanup: move function prototype to header file 2013-10-15 15:21:44 +00:00
Sergey Sharybin
eb69cb7de3 Get rid of Allow Fallback option
It was rather confusing from the user usage point
of view and didn't get so much improvement after
new bundle adjuster was added.

In the future we might want to switch resection
to PPnP algorithm, which could also might be a
nice alternative to fallback option.
2013-10-15 15:21:41 +00:00
Sergey Sharybin
36039be6b5 Libmv: make sure CmakeList.txt is re-created with all needed headers on re-bundle 2013-10-09 20:21:12 +00:00
Sergey Sharybin
b5491291e4 Libmv: move platform-specific defines into own file 2013-10-09 20:02:02 +00:00
Sergey Sharybin
ccd2e4375a Fix compilation error after recent libmv change
- Tweaked typedefs in stdint so they match
  what we've got in BLI_sys_types (needed to
  explicitly tell sign to MSVC).

  Not so much harmful to be more explicit here,
  but we really better to have single stdint
  int blender.

- Tweaked allocations macros so MSVC is happy
  with structures allocation.
2013-10-09 19:49:09 +00:00
Sergey Sharybin
49bc310671 Move guarded objetc allocation to a guardedalloc header
Also made libmv-capi use guarded objetc allocation.
Run into some suspecious cases when it was not so
clear whether memory is being freed or not.

Now we'll know for sure whether there're leaks or not :)

Having this macros in a guardedalloc header helps
using them in other areas (for now it's OCIO and libmv,
but in the future it'll be more places).
2013-10-09 08:46:02 +00:00
Sergey Sharybin
724b015da2 libmv: fix matrix address being printed instead of actual values 2013-10-02 10:18:43 +00:00
Sergey Sharybin
3169e96ae2 Optimization for recent changes in keyframe selection 2013-10-01 14:55:34 +00:00
Sergey Sharybin
404274040b Fix issues according to codereview page
Mainly just a comment cleanups.
2013-10-01 11:15:24 +00:00
Sergey Sharybin
2ddbb5d1e1 Fix for plane track jittering
Jittering was caused by homography not being estimated
accurate enough.

Before this, only algebraic estimation was used, which
is indeed not so much great, Now use algebraic estimation
followed with refinement step using Ceres minimizer.

The code was already there since keyframe selection patch,
made such estimation a generic function in multiview/ and
changed API for estimation in order to pass all additional
options via an options structure (the same way as it's
done fr Ceres).

This includes changes to both homography and fundamental
estimation.

TODO:
- Need to document Ceres functors better.
- Need to support homogeneous coordinates (currently
  only euclidean coords are supported).
2013-09-30 09:35:04 +00:00
Joseph Mansfield
7114ab18a2 Code cleanup: spelling correction 2013-09-14 10:22:56 +00:00
Campbell Barton
29cbf93b07 correct error in libmv stub, also correct typo. 2013-09-13 03:49:11 +00:00
Jens Verwiebe
990e361a2c OSX/clang5: revert 59960, todo: make it global 2013-09-09 16:24:23 +00:00
Jens Verwiebe
0dfc9b1f00 OSX/clang5: fix broken compiling 2013-09-09 15:45:09 +00:00
Joseph Mansfield
9707bdfe75 Code cleanup: Minor function capitalization fix 2013-09-09 00:06:23 +00:00
Sergey Sharybin
4228463caa Update Ceres to 1.7.0 release
For Blender this release is interesting because of:

- Covariance estimation (not used in Blender yet, but now we
  might use it for keyframe selection instead of havingown
  implementation).

- Significant performance improvements to loss function and
  dense linear solvers and automatic differentiation.

  Unfortunately, didn't notice speedup of tracking itself,
  but camera reconstruction now happens around 2 times faster
  on my laptop,

- Better inner iteration step acceptance and stopping.
2013-09-05 10:48:44 +00:00
Sergey Sharybin
08c49d8a12 Use reentrant qsort() in particle codes
Particle system code used global variable to sort hair by orig index,
which is not safe for threading at all.

Replaced this with usage of reentrant version of qsort, which is
now implemented in BLI. It was moved from recast navigation code
to BLI, so more areas could use it (if needed).

--
svn merge -r59086:59087 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:40:47 +00:00
Thomas Dinges
d75e14b31e * Compile fix, so disabling libmw works again. 2013-08-16 12:43:37 +00:00
Sergey Sharybin
24ce60cfe4 Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.

Movie clip editor changes:

- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).

  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.

- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.

  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).

- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.

- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.

Compositor changes:

- Added new node called Plane Track Deform.

- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).

- Node gets an image input, which need to be warped into
  the plane.

- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.

Masking changes:

- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.

Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578

This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
Sergey Sharybin
cab2aef71a Add Procrustes PNP ("PPnP") resection algorithm to libmv
This adds a new Euclidean resection method, used to create the
initial reconstruction in the motion tracker, to libmv. The method
is based on the Procrustes PNP algorithm (aka "PPnP"). Currently
the algorithm is not connected with the motion tracker, but it
will be eventually since it supports initialization.

Having an initial guess when doing resection is important for
ambiguous cases where potentially the user could offer extra
guidance to the solver, in the form of "this point is in front of
that point".

--
svn merge -r58821:58822 ^/branches/soc-2011-tomato
2013-08-16 08:26:34 +00:00
Sergey Sharybin
43c21e91e1 Fix for uninitialized covariance matrix
This is likely a culptrit caused #36231: Motion tracker bug in 2.68
2013-08-14 05:30:35 +00:00
Sergey Sharybin
7eeaefb97c Potential fix for wrogn k3 value after solve 2013-08-01 16:34:55 +00:00
Joseph Mansfield
c15ae082bb Code cleanup: libmv C API
Clean up inconsistencies in the libmv C API:
- All type identifiers are libmv_TypeName
- All function identifiers libmv_functionName
- Prefer libmv_nounVerb function names (e.g. libmv_featuresDestroy)
- Match Blender code formatting rather than Google
- Spelling corrections

Code review: https://codereview.appspot.com/11494044/
2013-07-31 13:48:12 +00:00
Peter Schlaile
1c2ff55334 == libredcode / licence cleanup ==
Changed libredcode to GNU GPL v2 or later to make it more compatible
with additional libraries added to blender.
2013-07-14 20:38:55 +00:00
Sergey Sharybin
f32615653b Update libmv from own branch
Fixes compilation error on win32 and shall give few
cpu ticks boost by passing vectors by reference rather
than by value.
2013-06-01 10:30:46 +00:00
Sergey Sharybin
719c2f8163 Fixed compilation error after recent keyframes commit. 2013-05-30 12:05:28 +00:00
Sergey Sharybin
c5b4983eca Remove files unused by blender's tracker
They were giving compilation error with msvc2012,
and instead of having workaround in them let's
drop them away form blender (they're not used even).
2013-05-30 12:05:20 +00:00
Sergey Sharybin
cf5e979fb4 Motion tracking: automatic keyframe selection
Implements an automatic keyframe selection algorithm which uses
couple of approaches to find out best keyframes candidates:

- First, slightly modifier Pollefeys's criteria is used, which
  limits correspondence ration from 80% to 100%. This allows to
  reject keyframe candidate early without doing heavy math in
  cases there're not much common features with first keyframe.

- Second step is based on Geometric Robust Information Criteria
  (aka GRIC), which checks whether features motion between
  candidate keyframes is better defined by homography or
  fundamental matrices.

  To be a good keyframe candidate, fundamental matrix need to
  define motion better than homography (in this case F-GRIC will
  be smaller than H-GRIC).

  This two criteria are well described in this paper:
  http://www.cs.ait.ac.th/~mdailey/papers/Tahir-KeyFrame.pdf

- Final step is based on estimating reconstruction error of
  a full-scene solution using candidate keyframes. This part
  is based on the following paper:

  ftp://ftp.tnt.uni-hannover.de/pub/papers/2004/ECCV2004-TTHBAW.pdf

  This step requires reconstruction using candidate keyframes
  and obtaining covariance matrix of 3D points positions.
  Reconstruction was done pretty much straightforward using
  other simple pipeline routines, and for covariance estimation
  pseudo-inverse of Hessian is used, which is in this case
  (J^T * J)+, where + denotes pseudo-inverse.

  Jacobian matrix is estimating using Ceres evaluate API.

  This is also crucial to get rid of possible gauge ambiguity,
  which is in our case made by zero-ing 7 (by gauge freedoms
  number) eigen values in pseudo-inverse.

  There're still room for improving and optimizing the code,
  but we need some point to start with anyway :)

  Thanks to Keir Mierle and Sameer Agarwal who assisted a lot
  to make this feature working.
2013-05-30 09:03:49 +00:00
Campbell Barton
225c5fee6b move BLO_sys_types.h -> BLI_sys_types.h (it had nothing todo with loading)
remove MEM_sys_types.h which was a duplicate.
2013-05-28 19:35:26 +00:00
Campbell Barton
8982439383 quiet warnings from r56825
- using vars before checking they are defined
- /* within comment
2013-05-16 03:55:47 +00:00
Jürgen Herrmann
8a89d27b87 Libmv internal compiler error workaround for VC2012.
Will be reverted as soon as the x64 compiler is fixed.
For now it shouldn't have an impact on tracking performance. My test have shown no significant speed difference to official VC2008 build of 2.67.
2013-05-15 17:00:53 +00:00
Campbell Barton
ff1a587e1c update libmv stub. 2013-05-14 03:06:58 +00:00
Sergey Sharybin
d4c6ac9a60 Cleanup and small improvements to libmv
- Added const modifiers where it makes sense and
  helps keep code safe.
- Reshuffled argument to match <inputs>,<outputs>
  convention on parameters.
- Pass values to ApplyRadialDistortionCameraIntrinsics
  by a constant reference.
  This will save lots of CPU ticks passing relatively
  heavy jet objects to this function when running
  bundle adjustment.
2013-05-13 14:39:06 +00:00
Sergey Sharybin
4e5541a9a6 Headers cleanup. 2013-05-13 09:51:36 +00:00
Sergey Sharybin
91b659d174 Forgot this in one of previous commits
Idea here is to be able to have all files opened in IDE
and not confuse it by the same function implemented in
multiple files.
2013-05-12 22:40:12 +00:00
Sergey Sharybin
4dba8307f2 Compilation fix for recent commit. 2013-05-12 22:30:34 +00:00
Sergey Sharybin
32faec1a53 Remplace bunch of annoying ifdefs in tracking.c with a libmv-capi_stub.cc
Makes code in tracking.cc much easier to understand and modify,
without worring to breck compulation with Libmv disabled.

It is still possible compilation will break due to libmv-capi
changes, but that's not happening so much often.
2013-05-12 22:17:37 +00:00
Sergey Sharybin
5637b0d39b Update bundled version of libmv
- Ensures fix for msvc2012 is applying correct.
- Some code cleanup to match libmv's code style.
- Do not include points which were intersect
  behind the camera to a reconstruction.
- Includes changes needed for keyframe selection.
2013-05-12 17:06:00 +00:00
Sergey Sharybin
beb73831f6 Documentation for functions inside tracking.c
Additional changes:

- Cleaned up sources to reduce mess in some
  big functions.
- Removed unused function from libmv c-api.
- Made functions naming more consistent.
- Use bool for internal stuff in tracking.c.

Shall be no functional changes :)
2013-05-12 16:04:08 +00:00
Brecht Van Lommel
309db8032c Fix libmv build with visual studio 2012.
Patch #35158 by Jurgen Herrmann.
2013-05-11 13:10:39 +00:00
Sergey Sharybin
2cf1f1f4d6 Left extra logging print by accident. 2013-05-10 07:26:55 +00:00