Commit Graph

120 Commits

Author SHA1 Message Date
Sergey Sharybin fdeca277fd Camera tracking: run aspect correction before stabilizing shot
This commit fixes image stopped being an orthogonal rectangle because of horizontal
scaling caused by pixel aspect ratio happening after rotating image which used to
make orthogonal angles from footage not actually orthogonal.

--
svn merge -r44150:44151 ^/branches/soc-2011-tomato
2012-02-17 08:23:42 +00:00
Sergey Sharybin bce89860f5 Various fixes for camera tracking stuff
- Fixed tooltip displaying for track sequence forwards in clip editor
- Corrected detection of 8 tracks so it wouldn't count tracks disabled
  on keyframes.
- Scale track preview to actual track widget size instead of scaling the
  whole preview image with given zoom ratio, so no extra memory needed to
  store zoomed margin would be used.
- Track's statistics text will fit pattern position instead of search if
  marker is disabled on current frame.
- Fixed toggle selection operator if selected track is hidden due to
  "Hide Disabled" policy.
2012-01-25 13:37:11 +00:00
Sergey Sharybin f37d1b7b4e Color channels now can be disabled for the whole frame in clip editor 2012-01-15 13:31:58 +00:00
Sergey Sharybin 5bf5d5a844 Camera tracking: tracks copy/paste operator
This commit implements basic clipboard support for movie tracking data
int clip editor. Used own implementation of clipboard like it's done
for sequencer.
Ideally it needed to be switched to more general clipboard system, but
currently this system is designed for text data only and it need to
be re-designed itself. But this feature is quite useful since object
tracking is implemented, so it should be OK to live with such own
implementation for a while.
2012-01-09 20:18:48 +00:00
Sergey Sharybin a69904aefe Camera tracking: improvements of python api
- marker_find_frame moved to MovieTrack.markers and called find_frame
- Added MovieTrack.markers.insert_frame to insert marker at specified frame
- Added MovieTrack.markers.delete_frame to delete marker from specified frame
2012-01-09 20:18:28 +00:00
Sergey Sharybin 792452a7e5 Disable markers when doing frame-by-frame tracking and tracker library returns failure 2011-12-30 18:15:44 +00:00
Sergey Sharybin 3c6e818b22 Object tracking integration
This commits merges object tracking implementation from tomato branch.

Summarized changes from branch:

- Added list of objects to be tracked. Default there's only one object called
  "Camera" which is used for solving camera motion. Other objects can be added
  and each of them will have it;s own list of tracks. Only one object can be used
  for camera solving at this moment.
- Added new constraint called "Object Tracking" which makes oriented object be
  moving in the save way as solved object motion.
- Scene orientation tools can be used for orienting object to bundles.
- Object has got scale to define "depth" in camera space.
- All tools which works with list of tracks or reconstruction data now
  gets that lists from active editing object.
- All objects and their tracking data are available via python api.
- Improvements in witness cameras workflow,
2011-12-30 18:06:02 +00:00
Sergey Sharybin e534af906a Object tracking: various fixes and improvements
- Bundles selection is now available for object's bundles
- If bundles selection wasn't changed in 3D viewport, fallback to regular
  object selection, so objects behind bundles can be selected
- Snap cursor to selection now respects object's bundle selection
- Object and rack name now can be selected from list in constraint settings
- Added preset for tracks used for object tracking
2011-12-15 16:10:49 +00:00
Sergey Sharybin 535aee820b Merging r42602 through r42620 from trunk into soc-2011-tomato 2011-12-14 06:12:20 +00:00
Sergey Sharybin 6c90a192c6 Do not switch to safe malloc if tracking sequence
Malloc is getting to be safe on sequence tracking by the jobs system,
so no additional set up are necessary.

This hopefully fixes crash on OSX with OpenMP enabled when compiling by older gcc
2011-12-13 16:37:52 +00:00
Sergey Sharybin dbc9227a32 Disable markers when doing frame-by-frame tracking and tracker library returns failure 2011-12-07 11:02:34 +00:00
Sergey Sharybin 9355cc5c39 Object tracking; initial commit
This commit implements basis stuff needed for object tracking,
use case isn't perfect now, interface also should be cleaned a bit.

- Added list of objects to be tracked. Default there's only one object called
  "Camera" which is used for solving camera motion. Other objects can be added
  and each of them will have it;s own list of tracks. Only one object can be used
  for camera solving at this moment.
- Added new constraint called "Object Tracking" which makes oriented object be
  moving in the save way as solved object motion.
- Scene orientation tools can be used for orienting object to bundles.
- All tools which works with list of tracks or reconstruction data now
  gets that lists from active editing object.
- All objects and their tracking data are available via python api.
2011-12-05 18:57:17 +00:00
Sergey Sharybin 9f3c921957 Camera tracking: moved camera solver into it's own job
In some cases solving can take a while (especially when refining is used)
and keeping interface locked is a bit annoying. Now camera solver is moved
to job system and interface isn't locking.

Reporting progress isn't really accurate, but trying to make it more linear
can lead to spending more effort on it than having benefit. Also, changing
status in the information line helps to understand that blender isn't hang
up and solving is till working nicely.

Main changes in code:
- libmv_solveReconstruction now accepts additional parameters:
  * progress_update_callback - a function which is getting called
    from solver algorithm to report progress back to Blender.
  * callback_customdata - a user-defined context which is passing
    to progress_update_callback so progress can be updated in needed
    blender-side data structures.

  This parameters are optional.

- Added structure MovieTrackingStats which is placed in MovieTracking
  structure. It's supposed to be used for displaying information about
  different operations (currently it's only camera solver, but can be
  easily used for something else in the future) in clip editor.
  This statistics structure is getting allocated for time operator is
  working and not saving into .blend file.

- Clip Editor now displays statistics stored in MovieTrackingStats structure
  like it's done for rendering.
2011-11-28 13:49:42 +00:00
Sergey Sharybin a3623a046b Camera tracking: merging tracking presets stuff from tomato branch
This commit implements:

- Configurable settings for newly creating tracks
  Now it's possible to set tracking algorithm and it's settings for
  all newly creating tracks including manual tracks creation and
  tracks creation by "Detect Features" operator.
- Moves margin, frames limit and adjust frame inside per-track
  settings.
  Was request from Francois for this.
- Adjust Frames replaced with menu called Pattern Match where it's
  possible to choose between matching pattern from keyframe frame
  or from previously tracked frame.
  Didn't see somebody used adjust frames values differ from 0 and 1,
  and this menu should make things more clear here/
2011-11-28 13:26:46 +00:00
Sergey Sharybin 5bac67956c Camera tracking: refactor of tracks synchronization stuff
Currently this stuff is used for 2d tracking job only, but the same
thing would necessary for camera solver job, so moved it into more
general utility stuff.
2011-11-27 19:17:59 +00:00
Sergey Sharybin f5f4348e10 Camera tracking: presets for default tracking settings
Internal changes are almost finished, changes in the interface need to be discussed.
2011-11-26 21:09:29 +00:00
Sergey Sharybin e228849666 Camera tracking: expose progress and status from camera solver into interface
Reporting progress isn't really accurate, but trying to make it more linear
can lead to spending more effort on it than having benefit. Also, changing
status in the information line helps to understand that blender isn't hang
up and solving is till working nicely.

Main changes in code:
- libmv_solveReconstruction now accepts additional parameters:

  * progress_update_callback - a function which is getting called
    from solver algorithm to report progress back to Blender.
  * callback_customdata - a user-defined context which is passing
    to progress_update_callback so progress can be updated in needed
    blender-side data structures.

  This parameters are optional.

- Added structure MovieTrackingStats which is placed in MovieTracking
  structure. It's supposed to be used for displaying information about
  different operations (currently it's only camera solver, but can be
  easily used for something else in the future) in clip editor.
  This statistics structure is getting allocated for time operator is
  working and not saving into .blend file.

- Clip Editor now displays statistics stored in MovieTrackingStats structure
  like it's done for rendering.
2011-11-22 14:45:22 +00:00
Sergey Sharybin f48e1b5572 Camera tracking: moved camera solver into it's own job
In some cases solving can take a while (especially when refining is used)
and keeping interface locked is a bit annoying. Now camera solver is moved
to job system and interface isn't locking.

Currently, no progress is displaying in the interface and solving can't
be canceled. It'll be implemented separately (need some changes in libmv).
2011-11-22 14:45:11 +00:00
Sergey Sharybin eef4b0eb19 Camera tracking: refactor of tracks synchronization stuff
Currently this stuff is used for 2d tracking job only, but the same
thing would necessary for camera solver job, so moved it into more
general utility stuff.
2011-11-22 14:45:04 +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 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
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 8c461466f3 Camera tracking integration
===========================

Code cleanup and minor refactor. Moved some functions from movieclip.c
to tracking.c due to they're operating on tracking data only.
2011-11-05 16:32:06 +00:00
Sergey Sharybin dea3b348e5 Camera tracking integration
===========================

- Set as Background button will enable displaying background images in 3d space.
- Move options in Display panel to column. Saves some space.
- Camera solving now should deal fine with non-centered principal.
2011-11-05 14:37:43 +00:00
Sergey Sharybin c3b2b00232 Camera tracking integration
===========================

Remove moravec detector. It doesn't work really fine and it's times slower than fast detector.
2011-10-31 14:27:32 +00:00
Sergey Sharybin 8e42433f02 Camera tracking integration
===========================

- Changed 3D viewport reconstruction settings to more usable defaults
- Some code clean-up
- Option to place markers for detected features across the whole frame,
  inside grease pencil areas or outside of grease pencil areas.
2011-10-31 14:01:40 +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 4735554087 Camera tracking integration
===========================

More fixes for reports from codereview.
2011-10-25 19:06:53 +00:00
Sergey Sharybin d4be67f501 Camera tracking integration
===========================

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

Naming refactor: avoid using acquire from movie clip related functions.
This stuff doesn't need releasing, all locks happens in getters,
so using get instead of acquire makes more sense here.
2011-10-20 09:52:13 +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 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 f90fdd6e8b Camera tracking integration
===========================

- Bundles and camera path should be displayed correct
  when there are several solved cameras in the same scene.
- Added option to use clip from active camera as background
  in 3d viewport.
2011-09-27 13:23:50 +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 e2db9a9ee1 Camera tracking integration
===========================

- Added python method MovieClip.tracking.tracs.add() to add new track.
  Marker for this track is getting created on position (0, 0) and it's
  keyframed to specified frame number.

- Implemented rotation 2D stabilization. It's supposed to be used in the
  following workflow:

  * Set tracks which defines location stabilization.
  * Choose one track which defines orientation.
  * Vector which connects median point of location and track used for
    rotation would have the same orientation along all frames.

  2D stabilization with rotation can be a bit slow.

- Some internal refactor and code clean-up.
2011-09-07 08:09:50 +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 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 dda38732d1 Camera tracking integration
===========================

Changes into sensor size use case.

There was problem with vertical sensor size which can't actually
affect on things due to we've got fixed image resolution. So
as soon horizontal size gets defined, both of sensor height
and vertical FOV is known and exposing it into UI makes things
difficult to understand.

That's why vertical sensor size was dropped.

Also added pixel aspect to camera settings fo clip editor.
Solver will sue this value rather than value from display
aspect ratio.

This pixel aspect would be copied to render settings after solving
so things should match now between footage, solving anf footage.
2011-08-09 15:12:20 +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 da7851aabc Camera tracking integration
===========================

Interpolate camera location and orientation for frames
where's no reconstruction data.

This fixes motion blur compositor node (first and last camera's
position was at origin, so motion vector was totally incorrect).
2011-08-05 17:50:21 +00:00
Sergey Sharybin 6cc4952ca3 Camera tracking integration
===========================

- Fixed bug with resetting marker's flag for non-transforming
  tracks when canceling transformation.
- Fixed bug with keyframing non-selected tracks when initializing
  tracking tools.
- Changed selection policy: now invisible parts of marker
  can be selected.
- Added operator redo panel to Clip Editor.
- Set Scale operator now uses operator property for scale.
- Added operator "Clean Tracks" which currently checks if tracks
  are tracked long enough and can select bad tracks, delete them
  or delete tracking segments which are too short.
2011-08-04 14:39:37 +00:00
Sergey Sharybin a28867e172 Camera tracking integration
===========================

- Made naming in libmv-api more uniform.
- Move aspect ration detection of clip to movieclip.c.
- Remove unused width and height from camera intrinsics function.
- Reconstruction should now deal correct with aspect ratio.
2011-08-03 18:28:40 +00:00
Sergey Sharybin cf6c261cc8 Camera tracking integration
===========================

- Fixed some silly things ni DNA design. Now all
  reconstruction data is stored in Tracking->Reconstruction.
  Please, re-solve your cameras -- reconstruction data
  wouldn't be read from files saved in blender below this
  commit.
- RNA accessors for reconstruction data.
- Store average reconstruction error in new reconstruction
  structure and show it in clip editor header after
  reconstruction.
- Highlight failed to reconstruct frames with red in cache line.
- Added "group" "Failed Tracks" in Select Grouped operator,
  Meant to be used for selecting tracks bundles from which
  failed to to be solved.
- Hotkey to delete marker: Shift-X.
- Jump to next/prev failed frame operator. Hotkeys are
  Ctrl-Shift-Left/Right Arrow.
2011-08-02 18:25:18 +00:00
Sergey Sharybin b5716beef0 Camera tracking integration
===========================

- Do not show frame boundary border when stabilization isn't enabled.
- Separate stabilization settings from display in clip editor.
  Now clip can contain stabilization data but still be displayed
  un-stabilized in clip editor.
- Internal changes in stabilization:
  * Use separated location/scale parameters rather than 4x4 matrix.
    In some ares "decomposed" data is needed (text draw functions, i.e.).
    Also such decomposed data could be used in compositor.
  * MovieClip now uses own structure for cache where additional data
    can be stored. MovieCache structure now one of properties in
    this new structure.
  * Get rid of stable image buffer stored in MovieClipStabilization
    structure. Pre-created buffer for scaling still stored there.
    This helps to keep playback realtime -- re-creating this buffer
    introduces ~15% slowdown.
- Added sliders to 2D stabilization panel which controls intensity
  of translation/scale which applies on shot.
- Added filter type to Stabilize2D compositor node. Supports nearest,
  bilinear and bicubic interpolation.
- After discussion with Sebastian and Francois added new node called
  Transformation. It can apply translation, rotation and scale. It's
  not the same thing as applying this components separately -- all
  transformation is happening inside "canvas". And it should be more
  accurate on interpolation and sub-pixel translation.
  Need to check order of applying translation/scale/rotation btw.
- Added output sockets to movie clip compositor node. They holds
  stabilization data which can be used by Translate or Transform
  nodes.
- Minor fix of UI issues in Display panel.
2011-08-01 15:28:19 +00:00
Sergey Sharybin 197595125f Camera tracking integration
===========================

- Fixed occasional crash caused by conflicting access
  to non-threadsafe moviecache. Added lock on movie clip
  ibuf acquire level.
- A bit nicer feedback from libmv when doing reconstruction.
  Now if all tracks and frames were reconstructed average
  error would be reported in "notification area".
  If there's something failed to be reconstructed warning
  message would appear and failed items would be printed to
  the console.
2011-07-30 17:14:07 +00:00
Sergey Sharybin 09a19c8b37 Camera tracking integration
===========================

Changed behavior of 2D stabilization:

- Fixed epic spelling error.
- Neither 3d viewport nor MovieClip compositor input node
  are using stable footage now.
- Now one thread lock can be avoided -- stable shot
  isn't acquiring from several threads.
- Added compositor noe Distort->Stabilize 2D which is
  supposed to stabilize "incoming" image using movie clip
  block as reference.

Probably it could be useful to define MAT4 socket type and
use it in MovieClip node as output for stabilization and
as input socket for Stabilization node so relation could be
easily visible on "graph".
2011-07-29 20:55:23 +00:00
Sergey Sharybin 6745e45c48 Camera tracking integration
===========================

Implemented 2D stabilization:

- Based on average point of several tracks.
- Tracks for stabilization are controllable from
  "2D stabilization" panel.
- Implemented autoscaling. Could fail if average point is
  too close to frame boundary.
- Background clip in 3D viewport and MovieClip input
  compositor nodes are using stable shot.

Some internal weak things:
- Stable shots aren't cached in moviecache. There is
  only one "slot" for stable shot inside stabilization
  structure.
- This could fail if several threads are requested different
  frames (for example when starting playback, pause to make
  Nodes Editor trigger refresh, continue playback).
- Due to it shouldn't crash i decided to implement better
  caching for stable shots a bit later.
2011-07-29 15:25:00 +00:00
Sergey Sharybin 478e42970c Camera tracking integration
===========================

- Operator "Join Selected Tracks".
  This operator joins all selected tracks to active track.
  Hotkey is Ctrl-J.
- Operator "Select Grouped".
  Now it's easy to select all locked/keyframes/etc markers.
  Hotkey is Shit-G.
- Operator to jump to beginning/end of active path.
  Hotkeys are Shift+Ctrl+Arrow Left/Right.
- Operator to copy color from active track to all tracks.
2011-07-22 16:18:51 +00:00
Sergey Sharybin ac57527895 Camera tracking integration
===========================

- Fixed crash when holding down S and R keys.
- Fixed deleting of first marker.
- Tracking should now work fine with float buffers.
- Added option to show distortion grid. It's most probably
  temporary solution until [auto]calibration tools aren't
  merged.
  This grid defines straight lines on the image.
2011-07-20 20:31:25 +00:00
Sergey Sharybin 0fec30a35f Camera tracking integration
===========================

- Internal change: do not use maroses for checking the only
  one bit of track/marker flags.
- Do not display track name for disabled markers when
  "Show Disabled" is turned off.
- Option to lock tracks. Locked tracks can't be be moved,
  scaled, re-tracked and so.
2011-07-20 10:51:47 +00:00
Sergey Sharybin a53fc2d306 Camera tracking integration
===========================

- Selected bundles are now highlighted with outline.
  It looks more Blender-way of highlighting selected items.
- Added option to show bundles names in 3D viewport.
- Bundles now coudl be selected from 3D viewport.
2011-07-19 20:22:03 +00:00
Sergey Sharybin 864071a512 Camera tracking integration
===========================

- Bundle re-newed libmv library.
- Update API in libmv-capi to match new library.
- Initial implementaition of feature detection.
- Fixed bug with incorrect user sync when tracking
  for first frame.
2011-07-15 20:44:19 +00:00
Sergey Sharybin be73c3bd4c Camera tracking integration
===========================

Small fixes and features:
- Fixed broken toolshelf for empty space clip.
- Added option to hide disabled tracks.
- Do not send disabled markers to tracking job.
- Fixed bug with disabling marker when tracking backwards.
- Fixed bug with unset principal point by default.
- Hide bundle projection for disabled markers.
- Flip orientation when hitting "Set Axis" when bundle is
  already defines axis.
2011-07-14 12:05:40 +00:00
Sergey Sharybin 08bd300f0e Camera tracking integration
===========================

- Changed libmv api to use doubles instead of floats.
  No real benefit rather than keeping API uniform.
- Optimized reconstructed camera search. It's optimized for
  playback, not random access.
- Added option to show projection of bundles into footage.
  To see bundles "Show Bundles" from Display panel should
  be enabled. Used very rough limit of 3 px to consider projection
  is fine. Colors are still hard-coded. Not sure it could be useful
  to make them configurable.
- Added option to mute footage. It could be useful to check
  if markers/bundles are moving smoothly.
- Added selector for focal length units.
2011-07-11 09:04:00 +00:00
Sergey Sharybin 964c3cb0fa Camera tracking integration
===========================

- Implemented hide/show track functionality.
- Small re-exposing Marker menu into UI.
  Now it's called "Track". Added new operators there.
- Set reconstructed clip as active to scene.
2011-07-09 19:51:23 +00:00
Sergey Sharybin c3d2e13a49 Camera tracking integration
===========================

- Made settings for tracking non-animatable.
- Fixed crash when enabling/disabling markers from
  "Specials" menu.
- Translate all coords to make first reconstructed camera
  be at position (0,0,0).
- Blender's camera now affects on reconstructed data.
  Bundles are "parented" to active scene camera. So now
  bundles' could could be scaled and rotated when camera
  is rotating/scaling.
2011-07-08 17:42:13 +00:00
Sergey Sharybin d279e8891f Camera tracking integration
===========================

- ColaMD moved from OpenNL to extern/.
  It'll be needed for libmv. Also, it's a bit updated from
  year 1999 to 2007.
  Need to be tested for regressions.
- Updated bundling script for libmv. Now it uses fuller
  subset of this library.
- Bundled new libmv.
- Request from Keir: add command line argument to toggle logging
  stuff on. Currently, if Blender is launched with -d argument
  libmv would start printing logging messages. There's no
  argument to increase verbosity, but there's API in libmv-capi,
  so it'll be easy to add.
- Finally fixed crash when ibuf is acquiring with user=NULL.
- Added ActiveClip property to the scene. This clip is used
  as default value for new match-moving constraints.
- Added some flags to Display panel of View3D. Related on
  displaying match-moving stuff.
- Internal change: bundles data moved inside to MovieTrackingTrack.
- Initial implementation of 3d reconstruction.
- Added constraint "Camera Solver". This constraint is supposed
  to be used to make camera follow the reconstructed camera path.
- Added "reference" property to "Follow Track" constraint.
  Now object could be "parented" to 2D track position or to
  3D bundle position.

The very quick guide:

To use reconstruction you should have footage with tracked markers,
choose two keyframes in "Tracking settings" panel. There should be
quite noticeable parallax effect between this two frames. This
is used to initialize reconstruction stuff.
Camera data (focal length and optical center) should be filled in
"Camera Data" panel. Optical center is often the center of image,
so it'll be filled in automatically.
You should also set values for undistortion (K1, K2 and K3). Currently,
there's no any visualization for this parameters and approach of
"change value -> reconstruct -> see what've changed" is the only way
for now.
Libmv team is working on auto-calibration tool, so it should be
easier to gather this coefficients in nearest (i hope) future.
There's also no scene orientation stuff.

Basic workflow:
- Open footage.
- Set markers and track them.
- Fill in camera data and keyframes.
- Hit "Solve Camera" button.
- Add "Camera Solver" constraint to camera in scene.
- Choose movieclip in that constraint.
- To see bundles in 3D viewport active clip should be set
  in scene buttons.
2011-07-07 17:58:33 +00:00
Sergey Sharybin 9cabee006b Camera tracking integration
===========================

- Fixed bug with swapped width/height used for per-pixel cycle
  when disabling color channel to be used for tracking.
- Marker preview is now using sub-pixel precision.
- Tracking stuff uses the same imbug generation function
  as preview area does. Sub-pixel precision should be ok
  now here too.
2011-07-02 11:06:30 +00:00
Sergey Sharybin ed4d973da3 Camera tracking integration
===========================

- Removed unneeded checking of marker==NULL
- Tracks could be named now.
- Implemented "Follow Track" constraint to "parent"
  objects to tracks from movie clip.
- Added operator to create such constraint for active object
  using clip and track from current context.
2011-07-01 17:12:08 +00:00
Sergey Sharybin 7ece1ef63e Camera tracking integration
===========================

- Internal changes:
  * Fixed bundle.sh script to bundle libmv: it was generating
    incorrect CMakeLists header.
  * Rename CLIP_OP_delete to CLIP_OT_delete_track.
  * Fixed crash when BKE_movieclip_acquire_ibuf is called
    with NULL user.
  * Made MovieTrackingMarker structure 8-bytes aligned
  * Use writestruct rather than writedata for track markers.
    This allows to change MovieTrackingMarker safely.
- Added "Delete Marker" operator which deletes marker for
  current frame only. Hotkey is Shift-Del.
- Added MovieClip.size and MovieClip.resolution RNA properties.
  Use last accessed frame number to get ImBuf from sequence.
- Added different actions for "Clear Path" operator:
  * Clear path up to current frame.
  * Clear the whole path.
  * Cleat remained part of path (for frames after current).
- Changed buttons order and icons for tracking. New order is:
  * Track frame backwards.
  * Track sequence backwards.
  * Track sequence forwards.
  * Track frame forwards.

NOTE: this breaks compatibility with existing .blend files again,
      but it should be much easier to change data structures without
      breackaged in the future.
2011-06-29 18:05:07 +00:00
Sergey Sharybin 08407e79ea Camera tracking integration
===========================

- Fixed "sliding" when panning footage in high zoom.
  This was most noticeable near right top corner of footage.
- Fixed 1px flickering of marker during playback with
  "Lock to Selection" toggled on. This was caused by
  precision errors. Used UI_view2d_to_region_no_clip-like
  offsets calculations, but in float values. Maybe there
  could be something smarter..
- Implemented tarcking along single frame.
  Hotkey is ALT+left/right array. Also changed a bit
  tracking tools buttons in Tools panel.
- Fixed "Lock to Selection" during tracking -- tracks
  synchronization should happen before centering view.
- Approximate marker's position for frames, which haven't
  got marker for them.
  Use the nearest marker from left side for approximation.
  For frames above  first marker's framenr sue first marker
  position.
- Markers now could be disabled. Added checkbox to
  "Active Marker" panel.
- Changes in cache line:
  * Bright line means active track has marker for frame.
  * Dark line means marker's position is approximated.
  * Yellow-less line means marker is disabled for that frames.

NOTE: .blend files which are saved with previous tomato version
      would fail to work properly. I don't want to spend time
      on making that files work properly atm, so don't blame on this.
2011-06-27 14:24:23 +00:00
Sergey Sharybin 0bb215eece Camera tracking integraiton
===========================

- Corrected copyrights in my new files header.
- Added debug option to dump as PNG image content of search
  areas tracking between which was failed.
- Removed internal tracking settings like pyramid level and
  tolerance. Weren't useful neither for me nor for artists.
- Fixed bug in BKE_tracking_get_marker which could lead
  to failure of getting marker for current frame when
  there's marker for requested frame.
- Fixed bug with disappearing markers after tracking for
  cases when marker was added at frame different from
  tracking start frame and tracking start frame is
  equal to tracking end frame.
- Stop tracking when no markers could be tracked.
- Changed marker selection rules:
  * If marker isn't selected, all it's areas are getting
    selected with mouse.
  * If marker is selected and selection type doesn't have
    "extend" mode (SHIFT isn't holded down) the nearest
    to mouse cursor area would be selected. All the reast areas
    would loose selection.
- Limit number of frames which would be used in "Track Markers"
  operator. So now you could easily track along 10/20/etc frames.
- Change scene current frame after "Track Markers" operator.
- Implemented speed limitors. Now tracking could happen:
  * As fast as possible
  * With reatime speed (scene FPS)
  * With half of realtime speed
  * With quarter of realtime speed.
- Got rid of orig_user in MovieTrackingContext and user
  in TrackMarkersJob. This prevents crashes when user
  joins some space to SpaceClip from which tracking was started.
- Made keyframes on path bigger and do not draw keyframes for
  non-selected markers.

TODO: need to get rid of storing main, scene and screen
      in TrackMarkersJob. This is needed to set scene's
      current frame after tracking (such behavior is comfortable
      for artists) but this could lead to crash if scene is
      getting removed when tracking job is running.

      Render animation operator also stores scene and main,
      so such solution could be fine for first time before
      we've got something smarter.
2011-06-22 14:54:53 +00:00
Sergey Sharybin 4cd25c1886 Camera tracking integration
===========================

- libmv's sources would now be added to qtcreator project.
- Fixed compilation with blenderplayer enabled and cmake.
- Fixed bug when tracking was done from frame different from
  initial marker's frame number.
- Implemented backwards tracking.
- Added option to draw track's path. Would be enabled by default
  for new scenes. Could be enabled on "Display" panel for
  files saved in previous version.
- Added operator to clean track path so it could be
  easily tracked form scratch.
- Added hotkeys for tracking, backwards tracking and
  cleaning track path (Ctrl-T, Ctrl-Shift-T and Alt-T).
- Fixed crash when setting clip as a footage.
- Small optimization when trying to track without
  selected markers.
2011-06-17 14:47:04 +00:00
Sergey Sharybin 02ace953a9 Camera tracking integration
===========================

- itasc adopted for Eigen3 library.
  It compiles well, but need deeper testing for regressions.
- Removed Eigen2 library.
- Added settings to tracker which could be changed from UI.
- Pattern area is now affects on tracker.
  Currently libmv supports square patterns which are centered
  to marker's position. Maximal pattern dimensions is sending
  to libmv as pattern size. Would be changed when libmv would
  support non-centered and non-square patterns.
- Fixed bug with syncing pattern's flags when tracking.
- Current frame in cache line became a bit more visible.
  It's useful for me to when debugging.
- Changed behaviour of "Add Marekr" operator: not it's non-modal
  and places marker on mouse position at click.
- Added macro "Add Marekr and Move" which is used to place
  markers from toolbar button.
- Added some utility functions to get image buffer under search
  and pattern area which also returns relative position of
  marker center for this images.
  Generated images are more "correct" from coords rounding
  POV, but  re-calculation of marker position back to
  frame coords is more complicated and not implemented yet,
  so old not very accurate logic is still used.
- Added preview widget with content of pattern area.

NOTE: files saved in previous versions of this branch could
      easily crash on tracking. Use "Reset To Settings" button
      from Tracking Settings before tracking selected markers
      for such files.

TODO:
- Implement adjusting marker position from marker's
  preview widget.
- We've got an idea of sliding marker after click before
  releasing mouse button.
2011-06-14 16:22:06 +00:00
Sergey Sharybin 084040acf4 Camera tracking integration
===========================

- Added missed stub for blenderplayer, so it should
  compile again fine.
- libmv is added to extern/.
  Script for bundling needed subset of sourcses from
  libmv repo is included there.
- Eigen3 is also added to extern/.
  libmv depends on Eigen3 (which isnt't compatible with Eigen2
  from API point of view). So both of versions are going to
  be in worktree for time (until code which used Eigen2 would be
  ported to Eigen3).
- Added some functions to libmv-capi, so some things from
  this library could already be used.
- Added the very basic implementation of 2D tracking.
  It should be treated as draft for tracking architecture
  which probably would be cleaned up, changed or whatever else.
  Current implementation was supposed to demonstrate that our
  structures and understading is correct to interact with libmv easily.
2011-06-10 17:17:25 +00:00
Sergey Sharybin 6e0332fd40 Camera tracking integration
===========================

- Disallow moving pattern/search area in way when marker position is
  outside of pattern area.
- MoiveClip could be set as background for 3D view.
  Added background source property to BGPic to switch between image
  and movie. Movie is a bit more complicaated entity than clip (due to
  displaying bundles, test objects and so) that's why i've sliptted
  background into two sources.
- Added Layout.template_movieclip to display general clip settings.
  Used in Footage panel of SpaceClip and background image properties
  in 3d view.
- Display bundles in 3D view as spheres. Selection is synchronized to
  markers associated with this bundle.
  Bundle can't be selected in 3D view.
- Recoded internal DNA structures, RNA and operators to match libmv entities.
  Tracking data now consists of Tracks, each tracks consists of markers
  which are associated with frame number. Markers holds position only,
  pattern and search areas settings are stored in track. Such settings should
  be unified for all markers in track and marker should hold position and
  frame number only.
2011-06-10 17:06:37 +00:00
Sergey Sharybin c4849aee1c Camera tracking integration
===========================

Implemented basic structures and operators for markers manipulaiton.

Markers contains:
- Position of marker at frame in unified 0..1 coordinates
- Relative positions of left-bottom and right-top corners of pattern area
- Relative positions of left-bottom and right-top corners of search area
- Selection flags

New operators:
- Create new maerker. It's a modal operator which creates markers
  at mouse position when LMB is clicking.
- Delete selected markers.
- Select marker using RMB. Some parts of marker (point, patter, search)
  could be deselected.
- Select markers using rectangular selection.
- Select markers using circle selection.
- Marker translation (G-key).
- Marker scaling (S-key).

UI changes:
- Added mode to space clip. Currently supported modes are:
    * View mode
    * Tracking mode
  This was intended to separate different categories of tools,
  so interface shouldn't be overheaded with plenty of tools
  which aren't actually using in the same time.
- Created new panel when actiev tool is 'MARKER' and there's
  active marker where positions could be adjusted in pixel space.

Internal changes:
- Splitted DNA/RNA movieclip files to make separation of
  tracking data and movie data more clear. This could be useful
  in the future when we'll want to support multiplie moies
  for single camera tracking (to make tracking more accurate).
- Added new file in blenkernel, where all tracking-related function
  would be stored. Not very much function here at this moment,
  but in the future all stuff related on converting DNA to external
  tracking data would be stored here.
2011-06-03 15:39:53 +00:00