Update Eigen to version 3.1.2

Mainly because of lots of warnings generating by gcc-4.7 which are
resolved in newer eigen version.
Initial Ceres integration

Currently only put sources to src/third_party/ceres and made sure they're
not giving compilation issues.

Used Ceres upstream version 1.3.0.

Needed to make some modifications to it's CMakeLists.txt also to glog and
fglags. They're described in README.libmv of this libraries.

Basically:

- Added -fPIC to glog/gflags, so shared ceres library could be linked
  statically against this libraries.

- Tweaked Ceres's build rules to use needed libraries from libmv's
  third_party folder.
Add a planar tracking implementation to libmv

This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.

The ESM tracker, also known as the KLT tracker in the UI, is
temporarily changed to use the new Ceres-based planar
tracker in translation-only mode. Currently it is a bit
slower than ESM and also doesn't have all the bells and
whistles implemented. Those will come soon. Longer term,
both trackers will remain since Ceres is unlikely to be as
fast as ESM for pure translation solving, due to its
generality.

The next step is to implement a new tracking UI. The current
UI assumes a translational motion model; the new one must
support arbitrary perspective transforms of the pattern
regions.

[1] http://code.google.com/p/ceres-solver
"Efficient Second-order Minimization" for the planar tracker

This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
Add new planar tracker features and use the new planar API

This commit removes the use of the legacy RegionTracker API from
Blender, and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:

- Do a brute-force initialization of tracking similar to "Hybrid"
  mode in the stable release, but using all floats. This is slower
  but more accurate. It is still necessary to evaluate if the
  performance loss is worth it. In particular, this change is
  necessary to support high bit depth imagery.

- Add support for masks over the search window. This is a step
  towards supporting user-defined tracker masks. The tracker masks
  will make it easy for users to make a mask for e.g. a ball.

- Add Pearson product moment correlation coefficient checking (aka
  "Correlation" in the UI. This causes tracking failure if the
  tracked patch is not linearly related to the template.

- Add support for warping a few points in addition to the supplied
  points. This is useful because the tracking code deliberately
  does not expose the underlying warp representation. Instead,
  warps are specified in an aparametric way via the correspondences.

- Remove the "num_samples_xy" concept and replace it with
  automatic determination of the number of samples. This makes the
  API easier for users.

- Fix various bugs in the parameterizations.

There remains a bug with subpixel precision tracking when in
"keyframe" mode; this will get fixed shortly.
Correction to region tracker options initialization.

Based on patch from Keir to Blender:
https://svn.blender.org/svnroot/bf-blender/branches/soc-2011-tomato@46743
For the planar tracker, initialize the warp from the four correspondences
after brute force translation search.
Implement support for affine tracking in the planar tracker; cleanups.
Add light-normalized tracking to the planar tracker

This commit adds the ability to normalize patterns by their
average value while tracking, to make them invariant to global
illumination changes.

To see this in action, check out the "Lobby" scene from Hollywood
VFX. If you track the markers that are shadowed by the actress,
previously they would not track. With the scale adaption on, the
tracker would shrink the area to compensate for the changed
illumination, losing the track. With "Normalize" turned on, the
patch is correctly tracked and scale is maintained.

A remaining problem is that only the Ceres cost function is
updated to handle the normalization. The brute translation search
does not take this into account. Perhaps "Prepass" (see below)
should get disabled if normalization is enabled until I fix the
prepass to normalize as well.

There are a few other changes:

- Bail out of the sampling loop early if the mask is zero; this
  saves expensive samples of the image derivatives.

- Fix a bug where the mask was ignored when sampling in the cost
  functor.
Support normalization in the tracking prepass

The last tracker commit added normalized tracking. This makes
tracking patches undergoing uniform illumination change easier.
However, the prepass which computes a quick translation-only
estimate of the warp did not take this into account. This commit
fixes that.

This works reasonably well but in some examples the brute
initialization fails. I suspect this is due to the warped template
estimate in the current  frame being too different from the
original, so there are multiple peaks in the normalized-SAD
correlation function.

The solution is to use the previous frame for the brute
initialization and the keyframe for refinement, but that requires
architecture changes.
Remove an unnecessary template<> line in libmv. Convert debug logs to LG.
Make planar tracking much faster.

- This makes planar tracking around 2-3x or more faster than
  before, by rearranging how the sampling is done.
  Previously, the source patch was sampled repeatedly on
  every optimizer iteration; this was done for
  implementation speed, but was wasteful in computation.

- This also contains some additions to Ceres to help
  deailing with mixed numeric / automatic differentation. In
  particular, there is now a "Chain::Rule" operator that
  facilitates calling a function that takes Jet arguments,
  yet does numeric derivatives internally. This is used to
  mix the numeric differentation of the images with the warp
  parameters, passed as jets by Ceres to the warp functor.

  There is also a new "JetOps" object for doing operations
  on types which may or may not be jets, such as scaling
  the derivative part only, or extracting the scalar part
  of a jet.

  This patche is aimed at Ceres upstream.

- A new function for sampling a patch is now part of the
  track_region.h API; this will get used to make the preview
  widget properly show what is getting tracked. Currently
  the preview widget does not handle perspective tracks.

Known issues:

  This patch introduces a bug such that the "Minimum
  Correlation" flag does not work; if it is enabled, tracking
  aborts immediately. The workaround for now is to disable the
  correlation checking, and examine your tracks carefully. A
  fix will get added shortly.
Planar tracker polish.

- Fixes the correlation checking code that was broken in the
  previous commit. The bug was a transpose error.
- Fixes a memory leak of the warp functor, found by Sameer.
- Various cleanups done at Sameer's suggestion.

Thanks to Sameer Agarwal for a code review.
Add new warp regularization scheme for planar tracking.

This adds a new term to the tracking cost function that
restricts how much the optimizer can warp the patch (as
opposed to merely adjusting the translation). This should
reduce the "jumpiness" that is sometimes seen when doing
non-"Loc" tracks.

It is disabled in this commit; a subsequent commit will add
controls to the tracking dialog for this.
Change libmv's bilinear sampling to assume the same
pixel conventions as Blender. This fixes the preview
widget in Blender, and should make tracking slightly
more accurate.
Changes to SamplePlanarPatch to support mask input and
added output for pattern center.
Code cleanup: silence some -Wnarrowing warnings from C++11
Resolved some compilation warnings (missed prototypes)

In some cases it was missed include of header file, in some other
cases symbol could be static.
Fix crash when tracking in planar motion model (and maybe some other)

It was an Abort() caused by check for solver result not equal to USER_ABORT.

In some cases solver returns USER_ABORT due to BoundaryCheckingCallback
detects coordinates does not belong to image.

Somehow this callback wasn't called in previous version of Ceres and
in the same case marker was jumping. Now when the callback is called
it seems we could simply return failure of tracking without aborting
Blender.

Probably this is in fact some issue somewhere else, would double
check with Keir about this.
Real fix for previous commit from Keir. He's comment;

Cleanup for when trackers fall out of the search window.

Sergey originally left a TODO() here, but his fix is the correct
one. I removed the TODO and fixed some comment issues.