Commit Graph

65 Commits

Author SHA1 Message Date
Sergey Sharybin
0bdbddf3d3 Merging r41937 through r42061 from trunk into soc-2011-tomato 2011-11-22 14:04:34 +00:00
Sergey Sharybin
120c0659ed Camera tracking fixes:
- Fixed incorrect memory access on distoritons more than 128 pixels
- Do not use UNDO operators flags for delete proxy operator (files can't be restored form disk),
  and also do not use UNDO for set as background operator (background images are storing in
  3d viewport which isn't getting re-loaded on undo which can lead to incorrect users count
  of movie clip user).
2011-11-19 20:14:57 +00:00
Sergey Sharybin
6e9fd309b8 Merged trunk up to rev41928 2011-11-16 20:48:21 +00:00
Sergey Sharybin
01af54c464 Camera tracking: forbid focal length=0 and small code cleanup 2011-11-16 10:00:02 +00:00
Guillermo S. Romero
4f743dd0cc SVN maintenance. 2011-11-15 19:37:09 +00:00
Sergey Sharybin
ae046bc0eb Patch from nico_ga: libmv can be compiled with icc now 2011-11-15 08:43:28 +00:00
Sergey Sharybin
1a6d884018 Fixed compilation error with msvc caused by recent libmv commit 2011-11-14 10:47:34 +00:00
Sergey Sharybin
0f82384fd0 Camera tracking: code cleanup 2011-11-14 06:41:32 +00:00
Sergey Sharybin
6fbc4186fd Assorted camera tracker improvements
- Add support for refining the camera's intrinsic parameters
  during a solve. Currently, refining supports only the following
  combinations of intrinsic parameters:

    f
    f, cx, cy
    f, cx, cy, k1, k2
    f, k1
    f, k1, k2

  This is not the same as autocalibration, since the user must
  still make a reasonable initial guess about the focal length and
  other parameters, whereas true autocalibration would eliminate
  the need for the user specify intrinsic parameters at all.

  However, the solver works well with only rough guesses for the
  focal length, so perhaps full autocalibation is not that
  important.

  Adding support for the last two combinations, (f, k1) and (f,
  k1, k2) required changes to the library libmv depends on for
  bundle adjustment, SSBA. These changes should get ported
  upstream not just to libmv but to SSBA as well.

- Improved the region of convergence for bundle adjustment by
  increasing the number of Levenberg-Marquardt iterations from 50
  to 500. This way, the solver is able to crawl out of the bad
  local minima it gets stuck in when changing from, for example,
  bundling k1 and k2 to just k1 and resetting k2 to 0.

- Add several new region tracker implementations. A region tracker
  is a libmv concept, which refers to tracking a template image
  pattern through frames. The impact to end users is that tracking
  should "just work better". I am reserving a more detailed
  writeup, and maybe a paper, for later.

- Other libmv tweaks, such as detecting that a tracker is headed
  outside of the image bounds.

This includes several changes made directly to the libmv extern
code rather expecting to get those changes through normal libmv
channels, because I, the libmv BDFL, decided it was faster to work
on libmv directly in Blender, then later reverse-port the libmv
changes from Blender back into libmv trunk. The interesting part
is that I added a full Levenberg-Marquardt loop to the region
tracking code, which should lead to a more stable solutions. I
also added a hacky implementation of "Efficient Second-Order
Minimization" for tracking, which works nicely. A more detailed
quantitative evaluation will follow.

Original patch by Keir, cleaned a bit by myself.
2011-11-14 06:41:23 +00:00
Sergey Sharybin
d30987fd59 Camera tracking integration: more code cleanup 2011-11-10 11:16:40 +00:00
Sergey Sharybin
55d0cb04aa Camera tracking integration: cleanup and finish some parts of recent commit
- Replace set of booleans with menu, so now you'll simply be unable to choose
  unsupported refine combination
- Some internal code cleanup and minor refactor
2011-11-10 11:16:33 +00:00
Keir Mierle
d4fec9f19f Assorted camera tracker improvements
- Add support for refining the camera's intrinsic parameters
  during a solve. Currently, refining supports only the following
  combinations of intrinsic parameters:

    f
    f, cx, cy
    f, cx, cy, k1, k2
    f, k1
    f, k1, k2

  This is not the same as autocalibration, since the user must
  still make a reasonable initial guess about the focal length and
  other parameters, whereas true autocalibration would eliminate
  the need for the user specify intrinsic parameters at all.

  However, the solver works well with only rough guesses for the
  focal length, so perhaps full autocalibation is not that
  important.

  Adding support for the last two combinations, (f, k1) and (f,
  k1, k2) required changes to the library libmv depends on for
  bundle adjustment, SSBA. These changes should get ported
  upstream not just to libmv but to SSBA as well.

- Improved the region of convergence for bundle adjustment by
  increasing the number of Levenberg-Marquardt iterations from 50
  to 500. This way, the solver is able to crawl out of the bad
  local minima it gets stuck in when changing from, for example,
  bundling k1 and k2 to just k1 and resetting k2 to 0.

- Add several new region tracker implementations. A region tracker
  is a libmv concept, which refers to tracking a template image
  pattern through frames. The impact to end users is that tracking
  should "just work better". I am reserving a more detailed
  writeup, and maybe a paper, for later.

- Other libmv tweaks, such as detecting that a tracker is headed
  outside of the image bounds.

This includes several changes made directly to the libmv extern
code rather expecting to get those changes through normal libmv
channels, because I, the libmv BDFL, decided it was faster to work
on libmv directly in Blender, then later reverse-port the libmv
changes from Blender back into libmv trunk. The interesting part
is that I added a full Levenberg-Marquardt loop to the region
tracking code, which should lead to a more stable solutions. I
also added a hacky implementation of "Efficient Second-Order
Minimization" for tracking, which works nicely. A more detailed
quantitative evaluation will follow.
2011-11-09 10:07:43 +00:00
Campbell Barton
f086201518 cmake & pep8 tidy up, also some style edits.
remove unneeded collection length function.
2011-11-08 01:32:34 +00:00
Sergey Sharybin
ae06ebcd95 Hopefully compilation with MinGW will work again.
Tested with official MinGW and SCons, not sure how ti check it when using CMake.
2011-11-07 18:14:50 +00:00
Sergey Sharybin
27d42c63d9 Camera tracking integration
===========================

Commiting camera tracking integration gsoc project into trunk.

This commit includes:

- Bundled version of libmv library (with some changes against official repo,
  re-sync with libmv repo a bit later)
- New datatype ID called MovieClip which is optimized to work with movie
  clips (both of movie files and image sequences) and doing camera/motion
  tracking operations.
- New editor called Clip Editor which is currently used for motion/tracking
  stuff only, but which can be easily extended to work with masks too.

  This editor supports:
  * Loading movie files/image sequences
  * Build proxies with different size for loaded movie clip, also supports
    building undistorted proxies to increase speed of playback in
    undistorted mode.
  * Manual lens distortion mode calibration using grid and grease pencil
  * Supervised 2D tracking using two different algorithms KLT and SAD.
  * Basic algorithm for feature detection
  * Camera motion solving. scene orientation

- New constraints to "link" scene objects with solved motions from clip:

  * Follow Track (make object follow 2D motion of track with given name
    or parent object to reconstructed 3D position of track)
  * Camera Solver to make camera moving in the same way as reconstructed camera

This commit NOT includes changes from tomato branch:

- New nodes (they'll be commited as separated patch)
- Automatic image offset guessing for image input node and image editor
  (need to do more tests and gather more feedback)
- Code cleanup in libmv-capi. It's not so critical cleanup, just increasing
  readability and understanadability of code. Better to make this chaneg when
  Keir will finish his current patch.

More details about this project can be found on this page:
    http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011

Further development of small features would be done in trunk, bigger/experimental
features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
Sergey Sharybin
af5526e58c Camera tracking integration: Final pre-merge code clean-up 2011-11-07 12:50:26 +00:00
Keir Mierle
db86c6bcf8 Improve the KLT tracking behaviour and UI
- Remove the overly-conservative use of libmv's re-track tracker. The re-track
  tracker would take a normal tracker such as TRKLT or KLT or pyramid KLT, and
  track from frame 1 to 2, then back from the position found in 2 back to 1.
  Then, when the reverse-track doesn't match the original track with high
  precision, the track is considered "failed". This is a good approach for
  fully automatic reconstruction, but is too conservative for supervised
  tracking.

  The retrack-tracker will return when fully automatic tracking is added.

- Always solve for (dx, dy) in the TRKLT loop even if the linear system is
  ill-conditioned. The client (Blender in this case) can still use the solved
  position, even though it is less reliable.

- Expose the pyramid level setting to the tracking UI when in KLT tracking
  mode. While it was tempting to hide this detail from the user, in reality it
  does more harm than good, since the way tracking fails depends on the pyramid
  level. For now, exposing the pyramid details is a good compromise.

- Move the settings for the tracking algorithm, including search window,
  tracking algorithm, pyramid levels, etc, into the track object instead of a
  global movie clip object.
2011-10-30 12:42:56 +00:00
Sergey Sharybin
a19b0d358a Camera tracing integration
==========================

Fix for SAD tracking sliding marker.
2011-10-29 09:46:53 +00:00
Sergey Sharybin
9d2caba92e Camera tracking integration
===========================

DeBalie commit (main changes only):

- Code cleanup
- Selectable tracking graph curves and curve knots
- Graph curve and curve knots can be deleted now
- Fixed wrong write when linking libraries
  (error is caused by hardcoded cound of linkable ID blocks)
- Fixed for KLT tracker when using keyframe adjustment
2011-10-29 07:14:31 +00:00
Sergey Sharybin
d4be67f501 Camera tracking integration
===========================

Remove $Id$
2011-10-24 15:24:53 +00:00
Sergey Sharybin
3d3a449d95 Camera tracking integration
===========================

Initial implementation of graph view for movie tracking data.
Used the same UI-side approach as preview region for sequencer:
create region for graph-related information inside clip editor.

It's easier and nicer than trying to hack graph editor which is
currently designed to work with AnimData only. Trying to make it
more abstract to deal with any kind of data doesn't seem be real
benefit for now.

Currently supported displaying per-frame average error and
selected tracks' movement speed (pixels per frame).

Additional changes:
- Collect per-frame average error after solving.
- Split space clip drawing code into different files.
- Added per-frame average solving error.
2011-10-19 12:46:30 +00:00
Sergey Sharybin
8fb37629cd Camera tracking integration
===========================

Some improvements for feature detectors:

- Sort features by score when filtering features by
  distance using FAST library.
- Added option to place markers only in areas outlined
  by grease pencil.
2011-10-15 19:30:51 +00:00
Sergey Sharybin
594e9e0689 Camera tracking integration
===========================

Added option to choose which method to use for feature detector: FAST or Moravec

Moravec was supposed to be more "stable", but it collected worse feedback.
before returning back to FAST detector added option to easier toggle between
different detector to compare it's result and find out if we can leave only FAST.
2011-10-13 17:54:05 +00:00
Sergey Sharybin
6f42be1e70 Camera tracking integration
===========================

Support for (un)distortion of images with overscan. Needed for
easier keeping this up-to-date until proper overscan support is
implemented in renderer. Not exposed into UI yet at all.
2011-10-09 20:28:29 +00:00
Sergey Sharybin
92ddc03126 Camera tracking integration
===========================

Fixed threading issues used to happen when compositor tree
and rendering happened in the same time. Problem was caused
by cached camera intrinsics stored in MovieTracking structure
and access to which wasn't thread-safe.

Now each movie distoriton mode stores it's own camera intrinsics
in it's storage which makes compositor (un)distoriton be totally
thread-safe and this also makes compositor tree faster when
(un)distortion happens on images with different resolution.
2011-10-07 19:21:29 +00:00
Sergey Sharybin
424f6463c1 Camera tracking integration
===========================

MSVC should work fine now.
2011-09-28 16:46:16 +00:00
Sergey Sharybin
a36dd050ed Camera tracking integration
===========================

- Merge Movie Distort and Movie Undistort nodes into one node
  called Movie Distortion where action (distort/undistort is specified).
- Implemented more proper distortion/undistortion for scaled images.

NOTE: Please, delete distortion nodes with current blender first
      before opening files with blender versions from this commit/
2011-09-28 13:31:32 +00:00
Sergey Sharybin
13e63a82d2 Camera tracking integration
===========================

Fix for msvc2010 compilaiton. Patch by Nico Blends, thanks!
2011-09-26 20:16:43 +00:00
Sergey Sharybin
7505de5c59 Camera tracking integration
===========================

Attempt to fix MinGW compilaiton.
2011-09-26 20:03:07 +00:00
Sergey Sharybin
4bd96adbcf Camera tracking integration
===========================

Lookup grids used for image distortion/undistortion are now
caching and re-building if distortion settings are changing.

This speedups compositor node for cases distortion model isn't
changing, but first run and runs after changing distortion
coefficients is still slow.
2011-09-26 19:00:12 +00:00
Sergey Sharybin
8615218d57 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.
2011-09-26 15:07:06 +00:00
Sergey Sharybin
5a1665d64e Camera tracking integration
===========================

- Do not disable track when tracking frame-by-frame and tracking
  threshold became bad.
- Show anchored image in track preview widget.
- Do not show search area for non-selected and disabled markers.
- Keep anchor constant position when sliding offset parameters in panel.
- Re-enabled occasionally disabled openmp for tracking.
- Renamed clearing operator so now buttons are more clear.
- Updated eigen to the very recent version.

NOTE: I had to enable static aligning again due to it gave crashes
      when tracking on my new laptop. I'm not sure it'll work fine
      on another systems.
2011-09-15 19:01:32 +00:00
Sergey Sharybin
c37a32593b Camera tracking integration
===========================

Fix compilation for 32bit OSX.
2011-09-04 12:56:16 +00:00
Sergey Sharybin
62f553cc56 Camera tracking integration
===========================

Reverting commit 81613ee0cc94b315f333c9632b18b95d426aad05 from Matthias branch.
It destroyed lens distortion code.
2011-08-21 17:08:05 +00:00
Sergey Sharybin
3c9c5b3359 Camera tracking integration
===========================

Another fix for MSVC.
2011-08-19 15:38:11 +00:00
Sergey Sharybin
78a2086415 Camera tracking integration
===========================

Previous fix wasn't checked and it was typo there.
2011-08-19 15:17:26 +00:00
Sergey Sharybin
c15012e568 Camera tracking integration
===========================

Fixes for MSVC.
2011-08-19 14:23:09 +00:00
Sergey Sharybin
ed3e6aa972 Camera tracking integration
===========================

Bundle new libmv and add changes needed to support affine tracking.

Affine tracking itself would be added in next commit.
2011-08-19 13:41:11 +00:00
Sergey Sharybin
83b2be3749 Camera tracking integration
===========================

Bundle new libmv to fix crash caused by some errors in detector.

This commit makes SAD tracking much slower because now it supports
afgine tracking. Not implemented in Blender yet to keep commits
more clear.
2011-08-18 21:20:12 +00:00
Sergey Sharybin
b52502cd4e Camera tracking integration
===========================

Stop SAD tracker when error becomes too high.
Maximal allowed error value is controlled in Tracking Settings panel.
I haven't been able to find value which will work for most of cases
so it's now quite stupid value of 0. Currently values of 2-6 gives
quite nice result, but it depends on footage.
Upcoming changes from libmv side related on returning normalized SAD
would help here. Until this, please set max_sad manually.
2011-08-18 11:10:10 +00:00
Sergey Sharybin
07017db093 Camera tracking integration
===========================

Just another fix for MSVC.
2011-08-17 18:37:25 +00:00
Sergey Sharybin
9589668e9f Camera tracking integration
===========================

Another fix for msvc/osx. Hope it'll work now.
2011-08-17 17:44:38 +00:00
Sergey Sharybin
18f5322f7c Camera tracking integration
===========================

- Bundling new libmv, issues with undefined uint and C99 functions should gone.
- Changes to Detect operator to match new API.
2011-08-17 17:12:10 +00:00
Sergey Sharybin
8b4c115a58 Camera tracking integration
===========================

Additional code clean-up and fixed typo.
No functional changes.
2011-08-17 11:17:18 +00:00
Sergey Sharybin
90a2ac4228 Camera tracking integration
===========================

- Bundle new version of libmv.
- Use image from nearest track's keyframe as reference for tracking.
  This should reduce drifting.
- Added option to switch to new SAD tracker.
  This tracker doesn't support pattern with variable size (yet?)
  and always uses pattern 16x16px.
  Tracker could be choosed in Tracking Settings panel.
2011-08-17 07:16:11 +00:00
Sergey Sharybin
36c5f57616 Camera tracking integration
===========================

- Distortion/undistortion were accidentally swapped in both of grease
  pencil calibration and grid.

  This was fixed but distortion coefficients should be re-adjusted.

  There are some issues with high distortion coefficients but it
  came from libmv and until it'll be fixed there nothing really
  can be done here.

- Fixed displayed aspect ratio for muted footage when pixel/display
  aspect ratio is differ from 1.0 or proxy size is not Full Render,

- Added c-api for image distortion/undistortion, Not used yet.
2011-08-12 21:56:08 +00:00
Sergey Sharybin
2a5a5bcd5a Camera tracking integration
===========================

Bundling new version of libmv. It's repo is ready for
bundling again, some patches which were applied on our
side are in libmv repo now.

This new version of libmv also contains patch from John Carpenter
which makes reconstruciton a bit more "stable" -- some kind
of fallback algorithm.
2011-08-09 10:42:39 +00:00
Sergey Sharybin
8c0fb2ad64 Camera tracking integration
===========================

Expose parameters for feature detection into redo panel.
2011-08-07 08:58:03 +00:00
Sergey Sharybin
00fd8b59d1 Commiting patches needed for bundling libmv.
I've used git where patch files were in gitignore, that's why
this files were missed in repo.
2011-08-06 14:49:01 +00:00
Sergey Sharybin
1e7203ce07 Camera tracking integration
===========================

- Added function to calculate per-track average error.
  Made this in libmv c-api, probably should be ported
  to libmv pipeline.
- MovieTrackingTrack now holds average reprojection error
  which is displayed in Active Track panel and information
  text in clip editor (if displaying of names are enabled).
- Make "Clean Tracks" take average error on account.
2011-08-04 15:40:28 +00:00