2011-11-07 12:55:18 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2011 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation,
|
|
|
|
* Sergey Sharybin
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2013-05-12 22:40:12 +00:00
|
|
|
#ifdef WITH_LIBMV
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* define this to generate PNG images with content of search areas
|
|
|
|
tracking between which failed */
|
|
|
|
#undef DUMP_FAILURE
|
|
|
|
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
/* define this to generate PNG images with content of search areas
|
|
|
|
on every itteration of tracking */
|
|
|
|
#undef DUMP_ALWAYS
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "libmv-capi.h"
|
2014-02-20 13:41:05 +00:00
|
|
|
#include "libmv-util.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-05-13 09:51:36 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2013-10-09 20:02:02 +00:00
|
|
|
#include "libmv-capi_intern.h"
|
2013-10-09 08:46:02 +00:00
|
|
|
#include "libmv/logging/logging.h"
|
|
|
|
#include "libmv/multiview/homography.h"
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
#include "libmv/tracking/track_region.h"
|
2011-11-28 13:49:42 +00:00
|
|
|
#include "libmv/simple_pipeline/callbacks.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "libmv/simple_pipeline/tracks.h"
|
|
|
|
#include "libmv/simple_pipeline/initialize_reconstruction.h"
|
|
|
|
#include "libmv/simple_pipeline/bundle.h"
|
|
|
|
#include "libmv/simple_pipeline/detect.h"
|
|
|
|
#include "libmv/simple_pipeline/pipeline.h"
|
|
|
|
#include "libmv/simple_pipeline/camera_intrinsics.h"
|
2012-04-14 12:02:47 +00:00
|
|
|
#include "libmv/simple_pipeline/modal_solver.h"
|
2013-05-09 16:38:43 +00:00
|
|
|
#include "libmv/simple_pipeline/reconstruction_scale.h"
|
2013-05-30 09:03:49 +00:00
|
|
|
#include "libmv/simple_pipeline/keyframe_selection.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# define snprintf _snprintf
|
|
|
|
#endif
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
using libmv::CameraIntrinsics;
|
|
|
|
using libmv::DetectOptions;
|
|
|
|
using libmv::DivisionCameraIntrinsics;
|
|
|
|
using libmv::EuclideanCamera;
|
|
|
|
using libmv::EuclideanPoint;
|
|
|
|
using libmv::EuclideanReconstruction;
|
|
|
|
using libmv::EuclideanScaleToUnity;
|
|
|
|
using libmv::Feature;
|
|
|
|
using libmv::FloatImage;
|
|
|
|
using libmv::Marker;
|
|
|
|
using libmv::PolynomialCameraIntrinsics;
|
|
|
|
using libmv::ProgressUpdateCallback;
|
|
|
|
using libmv::Tracks;
|
|
|
|
using libmv::TrackRegionOptions;
|
|
|
|
using libmv::TrackRegionResult;
|
|
|
|
|
|
|
|
using libmv::Detect;
|
|
|
|
using libmv::EuclideanBundle;
|
|
|
|
using libmv::EuclideanCompleteReconstruction;
|
|
|
|
using libmv::EuclideanReconstructTwoFrames;
|
|
|
|
using libmv::EuclideanReprojectionError;
|
|
|
|
using libmv::TrackRegion;
|
|
|
|
using libmv::SamplePlanarPatch;
|
|
|
|
|
|
|
|
typedef struct libmv_Tracks libmv_Tracks;
|
|
|
|
typedef struct libmv_Reconstruction libmv_Reconstruction;
|
|
|
|
typedef struct libmv_Features libmv_Features;
|
|
|
|
typedef struct libmv_CameraIntrinsics libmv_CameraIntrinsics;
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
struct libmv_Reconstruction {
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanReconstruction reconstruction;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
/* used for per-track average error calculation after reconstruction */
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks tracks;
|
|
|
|
CameraIntrinsics *intrinsics;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
double error;
|
2013-07-31 13:48:12 +00:00
|
|
|
};
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
struct libmv_Features {
|
2013-10-08 13:53:59 +00:00
|
|
|
int count;
|
2014-02-20 13:41:05 +00:00
|
|
|
Feature *features;
|
2013-07-31 13:48:12 +00:00
|
|
|
};
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
/* ************ Logging ************ */
|
|
|
|
|
|
|
|
void libmv_initLogging(const char *argv0)
|
|
|
|
{
|
2013-04-15 10:02:33 +00:00
|
|
|
/* Make it so FATAL messages are always print into console */
|
|
|
|
char severity_fatal[32];
|
|
|
|
snprintf(severity_fatal, sizeof(severity_fatal), "%d",
|
|
|
|
google::GLOG_FATAL);
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
google::InitGoogleLogging(argv0);
|
|
|
|
google::SetCommandLineOption("logtostderr", "1");
|
|
|
|
google::SetCommandLineOption("v", "0");
|
2013-04-15 10:02:33 +00:00
|
|
|
google::SetCommandLineOption("stderrthreshold", severity_fatal);
|
|
|
|
google::SetCommandLineOption("minloglevel", severity_fatal);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void libmv_startDebugLogging(void)
|
|
|
|
{
|
|
|
|
google::SetCommandLineOption("logtostderr", "1");
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
google::SetCommandLineOption("v", "2");
|
2011-11-07 12:55:18 +00:00
|
|
|
google::SetCommandLineOption("stderrthreshold", "1");
|
|
|
|
google::SetCommandLineOption("minloglevel", "0");
|
|
|
|
}
|
|
|
|
|
|
|
|
void libmv_setLoggingVerbosity(int verbosity)
|
|
|
|
{
|
|
|
|
char val[10];
|
|
|
|
snprintf(val, sizeof(val), "%d", verbosity);
|
|
|
|
|
|
|
|
google::SetCommandLineOption("v", val);
|
|
|
|
}
|
|
|
|
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
/* ************ Planar tracker ************ */
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
/* TrackRegion */
|
|
|
|
int libmv_trackRegion(const libmv_TrackRegionOptions *options,
|
2012-06-11 11:40:54 +00:00
|
|
|
const float *image1, int image1_width, int image1_height,
|
|
|
|
const float *image2, int image2_width, int image2_height,
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
const double *x1, const double *y1,
|
2013-07-31 13:48:12 +00:00
|
|
|
libmv_TrackRegionResult *result,
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
double *x2, double *y2)
|
|
|
|
{
|
|
|
|
double xx1[5], yy1[5];
|
|
|
|
double xx2[5], yy2[5];
|
|
|
|
bool tracking_result = false;
|
|
|
|
|
|
|
|
/* Convert to doubles for the libmv api. The four corners and the center. */
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
xx1[i] = x1[i];
|
|
|
|
yy1[i] = y1[i];
|
|
|
|
xx2[i] = x2[i];
|
|
|
|
yy2[i] = y2[i];
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
TrackRegionOptions track_region_options;
|
|
|
|
FloatImage image1_mask;
|
2012-06-12 11:13:53 +00:00
|
|
|
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
switch (options->motion_model) {
|
|
|
|
#define LIBMV_CONVERT(the_model) \
|
2014-02-20 13:41:05 +00:00
|
|
|
case TrackRegionOptions::the_model: \
|
|
|
|
track_region_options.mode = TrackRegionOptions::the_model; \
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
break;
|
|
|
|
LIBMV_CONVERT(TRANSLATION)
|
|
|
|
LIBMV_CONVERT(TRANSLATION_ROTATION)
|
|
|
|
LIBMV_CONVERT(TRANSLATION_SCALE)
|
|
|
|
LIBMV_CONVERT(TRANSLATION_ROTATION_SCALE)
|
|
|
|
LIBMV_CONVERT(AFFINE)
|
|
|
|
LIBMV_CONVERT(HOMOGRAPHY)
|
|
|
|
#undef LIBMV_CONVERT
|
|
|
|
}
|
|
|
|
|
|
|
|
track_region_options.minimum_correlation = options->minimum_correlation;
|
|
|
|
track_region_options.max_iterations = options->num_iterations;
|
|
|
|
track_region_options.sigma = options->sigma;
|
|
|
|
track_region_options.num_extra_points = 1;
|
|
|
|
track_region_options.image1_mask = NULL;
|
|
|
|
track_region_options.use_brute_initialization = options->use_brute;
|
2013-10-29 01:06:50 +00:00
|
|
|
/* TODO(keir): This will make some cases better, but may be a regression until
|
2014-02-25 10:54:34 +00:00
|
|
|
* the motion model is in. Since this is on trunk, enable it for now.
|
|
|
|
*
|
|
|
|
* TODO(sergey): This gives much worse results on mango footage (see 04_2e)
|
|
|
|
* so disabling for now for until proper prediction model is landed.
|
|
|
|
*
|
|
|
|
* The thing is, currently blender sends input coordinates as the guess to
|
|
|
|
* region tracker and in case of fast motion such an early out ruins the track.
|
|
|
|
*/
|
|
|
|
track_region_options.attempt_refine_before_brute = false;
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
track_region_options.use_normalized_intensities = options->use_normalization;
|
|
|
|
|
2012-06-12 11:13:53 +00:00
|
|
|
if (options->image1_mask) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_floatBufferToImage(options->image1_mask,
|
|
|
|
image1_width, image1_height, 1,
|
|
|
|
&image1_mask);
|
2012-06-12 11:13:53 +00:00
|
|
|
|
|
|
|
track_region_options.image1_mask = &image1_mask;
|
|
|
|
}
|
|
|
|
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
/* Convert from raw float buffers to libmv's FloatImage. */
|
2014-02-20 13:41:05 +00:00
|
|
|
FloatImage old_patch, new_patch;
|
|
|
|
libmv_floatBufferToImage(image1,
|
|
|
|
image1_width, image1_height, 1,
|
|
|
|
&old_patch);
|
|
|
|
libmv_floatBufferToImage(image2,
|
|
|
|
image2_width, image2_height, 1,
|
|
|
|
&new_patch);
|
|
|
|
|
|
|
|
TrackRegionResult track_region_result;
|
|
|
|
TrackRegion(old_patch, new_patch,
|
|
|
|
xx1, yy1,
|
|
|
|
track_region_options,
|
|
|
|
xx2, yy2,
|
|
|
|
&track_region_result);
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
|
|
|
|
/* Convert to floats for the blender api. */
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
x2[i] = xx2[i];
|
|
|
|
y2[i] = yy2[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO(keir): Update the termination string with failure details. */
|
2014-02-20 13:41:05 +00:00
|
|
|
if (track_region_result.termination == TrackRegionResult::CONVERGENCE ||
|
|
|
|
track_region_result.termination == TrackRegionResult::NO_CONVERGENCE)
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
{
|
|
|
|
tracking_result = true;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
/* Debug dump of patches. */
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
#if defined(DUMP_FAILURE) || defined(DUMP_ALWAYS)
|
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
bool need_dump = !tracking_result;
|
|
|
|
|
|
|
|
# ifdef DUMP_ALWAYS
|
|
|
|
need_dump = true;
|
|
|
|
# endif
|
2012-12-10 15:18:00 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
if (need_dump) {
|
|
|
|
libmv_saveImage(old_patch, "old_patch", x1[4], y1[4]);
|
|
|
|
libmv_saveImage(new_patch, "new_patch", x2[4], y2[4]);
|
|
|
|
|
|
|
|
if (options->image1_mask) {
|
|
|
|
libmv_saveImage(image1_mask, "mask", x2[4], y2[4]);
|
|
|
|
}
|
|
|
|
}
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return tracking_result;
|
|
|
|
}
|
|
|
|
|
2014-04-10 15:14:36 +00:00
|
|
|
void libmv_samplePlanarPatch(const float *image,
|
|
|
|
int width, int height, int channels,
|
|
|
|
const double *xs, const double *ys,
|
2012-06-12 11:13:53 +00:00
|
|
|
int num_samples_x, int num_samples_y,
|
2014-04-10 15:14:36 +00:00
|
|
|
const float *mask,
|
|
|
|
float *patch,
|
2014-02-20 13:41:05 +00:00
|
|
|
double *warped_position_x,
|
|
|
|
double *warped_position_y)
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
FloatImage libmv_image, libmv_patch, libmv_mask;
|
|
|
|
FloatImage *libmv_mask_for_sample = NULL;
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_floatBufferToImage(image, width, height, channels, &libmv_image);
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
|
2012-06-12 11:13:53 +00:00
|
|
|
if (mask) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_floatBufferToImage(mask, width, height, 1, &libmv_mask);
|
2012-06-12 11:13:53 +00:00
|
|
|
|
|
|
|
libmv_mask_for_sample = &libmv_mask;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
SamplePlanarPatch(libmv_image,
|
|
|
|
xs, ys,
|
|
|
|
num_samples_x, num_samples_y,
|
|
|
|
libmv_mask_for_sample,
|
|
|
|
&libmv_patch,
|
|
|
|
warped_position_x,
|
|
|
|
warped_position_y);
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_imageToFloatBuffer(libmv_patch, patch);
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- 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 start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "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.
- Remove 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.
Not exposed into interface yet/
* 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.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
}
|
|
|
|
|
2014-04-10 15:14:36 +00:00
|
|
|
void libmv_samplePlanarPatchByte(const unsigned char *image,
|
|
|
|
int width, int height, int channels,
|
|
|
|
const double *xs, const double *ys,
|
|
|
|
int num_samples_x, int num_samples_y,
|
|
|
|
const float *mask,
|
|
|
|
unsigned char *patch,
|
|
|
|
double *warped_position_x, double *warped_position_y)
|
|
|
|
{
|
|
|
|
libmv::FloatImage libmv_image, libmv_patch, libmv_mask;
|
|
|
|
libmv::FloatImage *libmv_mask_for_sample = NULL;
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_byteBufferToImage(image, width, height, channels, &libmv_image);
|
2014-04-10 15:14:36 +00:00
|
|
|
|
|
|
|
if (mask) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_floatBufferToImage(mask, width, height, 1, &libmv_mask);
|
2014-04-10 15:14:36 +00:00
|
|
|
|
|
|
|
libmv_mask_for_sample = &libmv_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
libmv::SamplePlanarPatch(libmv_image, xs, ys,
|
|
|
|
num_samples_x, num_samples_y,
|
|
|
|
libmv_mask_for_sample,
|
|
|
|
&libmv_patch,
|
|
|
|
warped_position_x,
|
|
|
|
warped_position_y);
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_imageToByteBuffer(libmv_patch, patch);
|
2014-04-10 15:14:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* ************ Tracks ************ */
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Tracks *libmv_tracksNew(void)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks *libmv_tracks = LIBMV_OBJECT_NEW(Tracks);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_Tracks *) libmv_tracks;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2013-10-09 08:46:02 +00:00
|
|
|
LIBMV_OBJECT_DELETE(libmv_tracks, Tracks);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_tracksInsert(libmv_Tracks *libmv_tracks,
|
|
|
|
int image, int track,
|
|
|
|
double x, double y,
|
|
|
|
double weight)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
((Tracks *) libmv_tracks)->Insert(image, track, x, y, weight);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
/* ************ Reconstruction ************ */
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class ReconstructUpdateCallback : public ProgressUpdateCallback {
|
2011-11-28 13:49:42 +00:00
|
|
|
public:
|
2014-02-20 13:41:05 +00:00
|
|
|
ReconstructUpdateCallback(
|
|
|
|
reconstruct_progress_update_cb progress_update_callback,
|
|
|
|
void *callback_customdata)
|
2011-11-28 13:49:42 +00:00
|
|
|
{
|
|
|
|
progress_update_callback_ = progress_update_callback;
|
|
|
|
callback_customdata_ = callback_customdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
void invoke(double progress, const char *message)
|
|
|
|
{
|
2013-07-31 13:48:12 +00:00
|
|
|
if (progress_update_callback_) {
|
2011-11-28 13:49:42 +00:00
|
|
|
progress_update_callback_(callback_customdata_, progress, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
reconstruct_progress_update_cb progress_update_callback_;
|
|
|
|
void *callback_customdata_;
|
|
|
|
};
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_solveRefineIntrinsics(
|
|
|
|
const Tracks &tracks,
|
|
|
|
const int refine_intrinsics,
|
|
|
|
const int bundle_constraints,
|
|
|
|
reconstruct_progress_update_cb progress_update_callback,
|
|
|
|
void *callback_customdata,
|
|
|
|
EuclideanReconstruction *reconstruction,
|
|
|
|
CameraIntrinsics *intrinsics)
|
2012-04-14 12:02:47 +00:00
|
|
|
{
|
|
|
|
/* only a few combinations are supported but trust the caller */
|
2013-05-12 17:06:00 +00:00
|
|
|
int bundle_intrinsics = 0;
|
2012-04-14 12:02:47 +00:00
|
|
|
|
|
|
|
if (refine_intrinsics & LIBMV_REFINE_FOCAL_LENGTH) {
|
2013-05-12 17:06:00 +00:00
|
|
|
bundle_intrinsics |= libmv::BUNDLE_FOCAL_LENGTH;
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
|
|
|
if (refine_intrinsics & LIBMV_REFINE_PRINCIPAL_POINT) {
|
2013-05-12 17:06:00 +00:00
|
|
|
bundle_intrinsics |= libmv::BUNDLE_PRINCIPAL_POINT;
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
|
|
|
if (refine_intrinsics & LIBMV_REFINE_RADIAL_DISTORTION_K1) {
|
2013-05-12 17:06:00 +00:00
|
|
|
bundle_intrinsics |= libmv::BUNDLE_RADIAL_K1;
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
|
|
|
if (refine_intrinsics & LIBMV_REFINE_RADIAL_DISTORTION_K2) {
|
2013-05-12 17:06:00 +00:00
|
|
|
bundle_intrinsics |= libmv::BUNDLE_RADIAL_K2;
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
progress_update_callback(callback_customdata, 1.0, "Refining solution");
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanBundleCommonIntrinsics(tracks,
|
|
|
|
bundle_intrinsics,
|
|
|
|
bundle_constraints,
|
|
|
|
reconstruction,
|
|
|
|
intrinsics);
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
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
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void finishReconstruction(
|
|
|
|
const Tracks &tracks,
|
|
|
|
const CameraIntrinsics &camera_intrinsics,
|
|
|
|
libmv_Reconstruction *libmv_reconstruction,
|
|
|
|
reconstruct_progress_update_cb progress_update_callback,
|
|
|
|
void *callback_customdata)
|
2012-12-10 16:38:13 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanReconstruction &reconstruction =
|
|
|
|
libmv_reconstruction->reconstruction;
|
2012-12-10 16:38:13 +00:00
|
|
|
|
|
|
|
/* reprojection error calculation */
|
|
|
|
progress_update_callback(callback_customdata, 1.0, "Finishing solution");
|
2013-05-13 14:39:06 +00:00
|
|
|
libmv_reconstruction->tracks = tracks;
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_reconstruction->error = EuclideanReprojectionError(tracks,
|
|
|
|
reconstruction,
|
|
|
|
camera_intrinsics);
|
2012-12-10 16:38:13 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
bool selectTwoKeyframesBasedOnGRICAndVariance(
|
|
|
|
Tracks &tracks,
|
|
|
|
Tracks &normalized_tracks,
|
|
|
|
CameraIntrinsics &camera_intrinsics,
|
|
|
|
int &keyframe1,
|
|
|
|
int &keyframe2)
|
2013-05-30 09:03:49 +00:00
|
|
|
{
|
|
|
|
libmv::vector<int> keyframes;
|
|
|
|
|
|
|
|
/* Get list of all keyframe candidates first. */
|
2013-09-09 00:06:23 +00:00
|
|
|
SelectKeyframesBasedOnGRICAndVariance(normalized_tracks,
|
2013-05-30 09:03:49 +00:00
|
|
|
camera_intrinsics,
|
|
|
|
keyframes);
|
|
|
|
|
|
|
|
if (keyframes.size() < 2) {
|
|
|
|
LG << "Not enough keyframes detected by GRIC";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (keyframes.size() == 2) {
|
|
|
|
keyframe1 = keyframes[0];
|
|
|
|
keyframe2 = keyframes[1];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now choose two keyframes with minimal reprojection error after initial
|
|
|
|
* reconstruction choose keyframes with the least reprojection error after
|
|
|
|
* solving from two candidate keyframes.
|
|
|
|
*
|
|
|
|
* In fact, currently libmv returns single pair only, so this code will
|
|
|
|
* not actually run. But in the future this could change, so let's stay
|
|
|
|
* prepared.
|
|
|
|
*/
|
|
|
|
int previous_keyframe = keyframes[0];
|
|
|
|
double best_error = std::numeric_limits<double>::max();
|
|
|
|
for (int i = 1; i < keyframes.size(); i++) {
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanReconstruction reconstruction;
|
2013-05-30 09:03:49 +00:00
|
|
|
int current_keyframe = keyframes[i];
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv::vector<Marker> keyframe_markers =
|
2013-05-30 09:03:49 +00:00
|
|
|
normalized_tracks.MarkersForTracksInBothImages(previous_keyframe,
|
|
|
|
current_keyframe);
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks keyframe_tracks(keyframe_markers);
|
2013-05-30 09:03:49 +00:00
|
|
|
|
|
|
|
/* get a solution from two keyframes only */
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
|
|
|
|
EuclideanBundle(keyframe_tracks, &reconstruction);
|
|
|
|
EuclideanCompleteReconstruction(keyframe_tracks,
|
|
|
|
&reconstruction,
|
|
|
|
NULL);
|
2013-05-30 09:03:49 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
double current_error = EuclideanReprojectionError(tracks,
|
|
|
|
reconstruction,
|
|
|
|
camera_intrinsics);
|
2013-05-30 09:03:49 +00:00
|
|
|
|
|
|
|
LG << "Error between " << previous_keyframe
|
|
|
|
<< " and " << current_keyframe
|
|
|
|
<< ": " << current_error;
|
|
|
|
|
|
|
|
if (current_error < best_error) {
|
|
|
|
best_error = current_error;
|
|
|
|
keyframe1 = previous_keyframe;
|
|
|
|
keyframe2 = current_keyframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
previous_keyframe = current_keyframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
libmv_Reconstruction *libmv_solveReconstruction(
|
|
|
|
const libmv_Tracks *libmv_tracks,
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
|
|
|
|
libmv_ReconstructionOptions *libmv_reconstruction_options,
|
|
|
|
reconstruct_progress_update_cb progress_update_callback,
|
|
|
|
void *callback_customdata)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Reconstruction *libmv_reconstruction =
|
|
|
|
LIBMV_OBJECT_NEW(libmv_Reconstruction);
|
2012-12-10 16:38:13 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks &tracks = *((Tracks *) libmv_tracks);
|
|
|
|
EuclideanReconstruction &reconstruction =
|
|
|
|
libmv_reconstruction->reconstruction;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-11-28 13:49:42 +00:00
|
|
|
ReconstructUpdateCallback update_callback =
|
2014-02-20 13:41:05 +00:00
|
|
|
ReconstructUpdateCallback(progress_update_callback,
|
|
|
|
callback_customdata);
|
2011-11-28 13:49:42 +00:00
|
|
|
|
2013-05-30 09:03:49 +00:00
|
|
|
/* Retrieve reconstruction options from C-API to libmv API */
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics;
|
|
|
|
camera_intrinsics = libmv_reconstruction->intrinsics =
|
|
|
|
libmv_cameraIntrinsicsCreateFromOptions(
|
|
|
|
libmv_camera_intrinsics_options);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-05-30 09:03:49 +00:00
|
|
|
/* Invert the camera intrinsics */
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks normalized_tracks;
|
|
|
|
libmv_getNormalizedTracks(tracks, *camera_intrinsics, &normalized_tracks);
|
2013-05-30 09:03:49 +00:00
|
|
|
|
|
|
|
/* keyframe selection */
|
2012-12-10 16:38:13 +00:00
|
|
|
int keyframe1 = libmv_reconstruction_options->keyframe1,
|
|
|
|
keyframe2 = libmv_reconstruction_options->keyframe2;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-05-30 09:03:49 +00:00
|
|
|
if (libmv_reconstruction_options->select_keyframes) {
|
|
|
|
LG << "Using automatic keyframe selection";
|
|
|
|
|
|
|
|
update_callback.invoke(0, "Selecting keyframes");
|
|
|
|
|
|
|
|
selectTwoKeyframesBasedOnGRICAndVariance(tracks,
|
|
|
|
normalized_tracks,
|
2014-02-20 13:41:05 +00:00
|
|
|
*camera_intrinsics,
|
2013-05-30 09:03:49 +00:00
|
|
|
keyframe1,
|
|
|
|
keyframe2);
|
|
|
|
|
|
|
|
/* so keyframes in the interface would be updated */
|
|
|
|
libmv_reconstruction_options->keyframe1 = keyframe1;
|
|
|
|
libmv_reconstruction_options->keyframe2 = keyframe2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actual reconstruction */
|
2011-11-28 13:49:42 +00:00
|
|
|
LG << "frames to init from: " << keyframe1 << " " << keyframe2;
|
2012-12-10 16:38:13 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv::vector<Marker> keyframe_markers =
|
2011-11-07 12:55:18 +00:00
|
|
|
normalized_tracks.MarkersForTracksInBothImages(keyframe1, keyframe2);
|
2012-12-10 16:38:13 +00:00
|
|
|
|
2011-11-28 13:49:42 +00:00
|
|
|
LG << "number of markers for init: " << keyframe_markers.size();
|
|
|
|
|
|
|
|
update_callback.invoke(0, "Initial reconstruction");
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
|
|
|
|
EuclideanBundle(normalized_tracks, &reconstruction);
|
|
|
|
EuclideanCompleteReconstruction(normalized_tracks,
|
|
|
|
&reconstruction,
|
|
|
|
&update_callback);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-12-10 16:38:13 +00:00
|
|
|
/* refinement */
|
|
|
|
if (libmv_reconstruction_options->refine_intrinsics) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_solveRefineIntrinsics(
|
|
|
|
tracks,
|
|
|
|
libmv_reconstruction_options->refine_intrinsics,
|
|
|
|
libmv::BUNDLE_NO_CONSTRAINTS,
|
|
|
|
progress_update_callback,
|
|
|
|
callback_customdata,
|
|
|
|
&reconstruction,
|
|
|
|
camera_intrinsics);
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
2011-11-28 13:49:42 +00:00
|
|
|
|
2013-05-09 16:38:43 +00:00
|
|
|
/* set reconstruction scale to unity */
|
2014-02-20 13:41:05 +00:00
|
|
|
EuclideanScaleToUnity(&reconstruction);
|
2013-05-09 16:38:43 +00:00
|
|
|
|
2012-12-10 16:38:13 +00:00
|
|
|
/* finish reconstruction */
|
2014-02-20 13:41:05 +00:00
|
|
|
finishReconstruction(tracks,
|
|
|
|
*camera_intrinsics,
|
|
|
|
libmv_reconstruction,
|
|
|
|
progress_update_callback,
|
|
|
|
callback_customdata);
|
2012-04-14 12:02:47 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_Reconstruction *) libmv_reconstruction;
|
2012-04-14 12:02:47 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Reconstruction *libmv_solveModal(
|
|
|
|
const libmv_Tracks *libmv_tracks,
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
|
|
|
|
const libmv_ReconstructionOptions *libmv_reconstruction_options,
|
|
|
|
reconstruct_progress_update_cb progress_update_callback,
|
|
|
|
void *callback_customdata)
|
2012-04-14 12:02:47 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Reconstruction *libmv_reconstruction =
|
|
|
|
LIBMV_OBJECT_NEW(libmv_Reconstruction);
|
2012-12-10 16:38:13 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks &tracks = *((Tracks *) libmv_tracks);
|
|
|
|
EuclideanReconstruction &reconstruction =
|
|
|
|
libmv_reconstruction->reconstruction;
|
2012-04-14 12:02:47 +00:00
|
|
|
|
|
|
|
ReconstructUpdateCallback update_callback =
|
2014-02-20 13:41:05 +00:00
|
|
|
ReconstructUpdateCallback(progress_update_callback,
|
|
|
|
callback_customdata);
|
2012-04-14 12:02:47 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
/* Retrieve reconstruction options from C-API to libmv API */
|
|
|
|
CameraIntrinsics *camera_intrinsics;
|
|
|
|
camera_intrinsics = libmv_reconstruction->intrinsics =
|
|
|
|
libmv_cameraIntrinsicsCreateFromOptions(
|
|
|
|
libmv_camera_intrinsics_options);
|
2012-04-14 12:02:47 +00:00
|
|
|
|
2013-02-28 14:24:42 +00:00
|
|
|
/* Invert the camera intrinsics. */
|
2014-02-20 13:41:05 +00:00
|
|
|
Tracks normalized_tracks;
|
|
|
|
libmv_getNormalizedTracks(tracks, *camera_intrinsics, &normalized_tracks);
|
2012-04-14 12:02:47 +00:00
|
|
|
|
2013-02-28 14:24:42 +00:00
|
|
|
/* Actual reconstruction. */
|
2014-02-20 13:41:05 +00:00
|
|
|
ModalSolver(normalized_tracks, &reconstruction, &update_callback);
|
2011-11-28 13:49:42 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
PolynomialCameraIntrinsics empty_intrinsics;
|
|
|
|
EuclideanBundleCommonIntrinsics(normalized_tracks,
|
|
|
|
libmv::BUNDLE_NO_INTRINSICS,
|
|
|
|
libmv::BUNDLE_NO_TRANSLATION,
|
|
|
|
&reconstruction,
|
|
|
|
&empty_intrinsics);
|
2013-02-28 14:24:42 +00:00
|
|
|
|
|
|
|
/* Refinement. */
|
|
|
|
if (libmv_reconstruction_options->refine_intrinsics) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_solveRefineIntrinsics(
|
|
|
|
tracks,
|
|
|
|
libmv_reconstruction_options->refine_intrinsics,
|
|
|
|
libmv::BUNDLE_NO_TRANSLATION,
|
|
|
|
progress_update_callback, callback_customdata,
|
|
|
|
&reconstruction,
|
|
|
|
camera_intrinsics);
|
2013-02-28 14:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish reconstruction. */
|
2014-02-20 13:41:05 +00:00
|
|
|
finishReconstruction(tracks,
|
|
|
|
*camera_intrinsics,
|
|
|
|
libmv_reconstruction,
|
|
|
|
progress_update_callback,
|
|
|
|
callback_customdata);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_Reconstruction *) libmv_reconstruction;
|
2013-07-31 13:48:12 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_reconstructionDestroy(libmv_Reconstruction *libmv_reconstruction)
|
2013-07-31 13:48:12 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
LIBMV_OBJECT_DELETE(libmv_reconstruction->intrinsics, CameraIntrinsics);
|
2013-10-09 08:46:02 +00:00
|
|
|
LIBMV_OBJECT_DELETE(libmv_reconstruction, libmv_Reconstruction);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
int libmv_reprojectionPointForTrack(
|
|
|
|
const libmv_Reconstruction *libmv_reconstruction,
|
|
|
|
int track,
|
|
|
|
double pos[3])
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanReconstruction *reconstruction =
|
|
|
|
&libmv_reconstruction->reconstruction;
|
|
|
|
const EuclideanPoint *point =
|
|
|
|
reconstruction->PointForTrack(track);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
if (point) {
|
2011-11-07 12:55:18 +00:00
|
|
|
pos[0] = point->X[0];
|
|
|
|
pos[1] = point->X[2];
|
|
|
|
pos[2] = point->X[1];
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
double libmv_reprojectionErrorForTrack(
|
|
|
|
const libmv_Reconstruction *libmv_reconstruction,
|
|
|
|
int track)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanReconstruction *reconstruction =
|
|
|
|
&libmv_reconstruction->reconstruction;
|
|
|
|
const CameraIntrinsics *intrinsics = libmv_reconstruction->intrinsics;
|
|
|
|
libmv::vector<Marker> markers =
|
|
|
|
libmv_reconstruction->tracks.MarkersForTrack(track);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
int num_reprojected = 0;
|
|
|
|
double total_error = 0.0;
|
|
|
|
|
|
|
|
for (int i = 0; i < markers.size(); ++i) {
|
2014-01-28 12:01:03 +00:00
|
|
|
double weight = markers[i].weight;
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanCamera *camera =
|
|
|
|
reconstruction->CameraForImage(markers[i].image);
|
|
|
|
const EuclideanPoint *point =
|
|
|
|
reconstruction->PointForTrack(markers[i].track);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-01-28 12:01:03 +00:00
|
|
|
if (!camera || !point || weight == 0.0) {
|
2011-11-07 12:55:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_reprojected++;
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
Marker reprojected_marker =
|
|
|
|
libmv_projectMarker(*point, *camera, *intrinsics);
|
2014-01-28 12:01:03 +00:00
|
|
|
double ex = (reprojected_marker.x - markers[i].x) * weight;
|
|
|
|
double ey = (reprojected_marker.y - markers[i].y) * weight;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
total_error += sqrt(ex * ex + ey * ey);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return total_error / num_reprojected;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
double libmv_reprojectionErrorForImage(
|
|
|
|
const libmv_Reconstruction *libmv_reconstruction,
|
|
|
|
int image)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanReconstruction *reconstruction =
|
|
|
|
&libmv_reconstruction->reconstruction;
|
|
|
|
const CameraIntrinsics *intrinsics = libmv_reconstruction->intrinsics;
|
|
|
|
libmv::vector<Marker> markers =
|
|
|
|
libmv_reconstruction->tracks.MarkersInImage(image);
|
|
|
|
const EuclideanCamera *camera = reconstruction->CameraForImage(image);
|
2011-11-07 12:55:18 +00:00
|
|
|
int num_reprojected = 0;
|
|
|
|
double total_error = 0.0;
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
if (!camera) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < markers.size(); ++i) {
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanPoint *point =
|
|
|
|
reconstruction->PointForTrack(markers[i].track);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
if (!point) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_reprojected++;
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
Marker reprojected_marker =
|
|
|
|
libmv_projectMarker(*point, *camera, *intrinsics);
|
|
|
|
double ex = (reprojected_marker.x - markers[i].x) * markers[i].weight;
|
|
|
|
double ey = (reprojected_marker.y - markers[i].y) * markers[i].weight;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
total_error += sqrt(ex * ex + ey * ey);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return total_error / num_reprojected;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
int libmv_reprojectionCameraForImage(
|
|
|
|
const libmv_Reconstruction *libmv_reconstruction,
|
|
|
|
int image, double mat[4][4])
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const EuclideanReconstruction *reconstruction =
|
|
|
|
&libmv_reconstruction->reconstruction;
|
|
|
|
const EuclideanCamera *camera =
|
|
|
|
reconstruction->CameraForImage(image);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
if (camera) {
|
2011-11-07 12:55:18 +00:00
|
|
|
for (int j = 0; j < 3; ++j) {
|
|
|
|
for (int k = 0; k < 3; ++k) {
|
|
|
|
int l = k;
|
|
|
|
|
|
|
|
if (k == 1) l = 2;
|
|
|
|
else if (k == 2) l = 1;
|
|
|
|
|
|
|
|
if (j == 2) mat[j][l] = -camera->R(j,k);
|
|
|
|
else mat[j][l] = camera->R(j,k);
|
|
|
|
}
|
2013-07-31 13:48:12 +00:00
|
|
|
mat[j][3] = 0.0;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
libmv::Vec3 optical_center = -camera->R.transpose() * camera->t;
|
|
|
|
|
|
|
|
mat[3][0] = optical_center(0);
|
|
|
|
mat[3][1] = optical_center(2);
|
|
|
|
mat[3][2] = optical_center(1);
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
mat[3][3] = 1.0;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
double libmv_reprojectionError(
|
|
|
|
const libmv_Reconstruction *libmv_reconstruction)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
|
|
|
return libmv_reconstruction->error;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_CameraIntrinsics *libmv_reconstructionExtractIntrinsics(
|
|
|
|
libmv_Reconstruction *libmv_reconstruction)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_CameraIntrinsics *) libmv_reconstruction->intrinsics;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
/* ************ Feature detector ************ */
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
static libmv_Features *libmv_featuresFromVector(
|
2014-02-20 13:41:05 +00:00
|
|
|
const libmv::vector<Feature> &features)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Features *libmv_features = LIBMV_STRUCT_NEW(libmv_Features, 1);
|
2013-10-08 13:53:59 +00:00
|
|
|
int count = features.size();
|
2013-07-31 13:48:12 +00:00
|
|
|
if (count) {
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_features->features = LIBMV_STRUCT_NEW(Feature, count);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
libmv_features->features[i] = features.at(i);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-08 13:53:59 +00:00
|
|
|
else {
|
|
|
|
libmv_features->features = NULL;
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
libmv_features->count = count;
|
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
return libmv_features;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
static void libmv_convertDetectorOptions(libmv_DetectOptions *options,
|
2014-02-20 13:41:05 +00:00
|
|
|
DetectOptions *detector_options)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2013-10-08 13:53:59 +00:00
|
|
|
switch (options->detector) {
|
|
|
|
#define LIBMV_CONVERT(the_detector) \
|
|
|
|
case LIBMV_DETECTOR_ ## the_detector: \
|
2014-02-20 13:41:05 +00:00
|
|
|
detector_options->type = DetectOptions::the_detector; \
|
2013-10-08 13:53:59 +00:00
|
|
|
break;
|
|
|
|
LIBMV_CONVERT(FAST)
|
|
|
|
LIBMV_CONVERT(MORAVEC)
|
|
|
|
LIBMV_CONVERT(HARRIS)
|
|
|
|
#undef LIBMV_CONVERT
|
|
|
|
}
|
|
|
|
detector_options->margin = options->margin;
|
|
|
|
detector_options->min_distance = options->min_distance;
|
|
|
|
detector_options->fast_min_trackness = options->fast_min_trackness;
|
|
|
|
detector_options->moravec_max_count = options->moravec_max_count;
|
|
|
|
detector_options->moravec_pattern = options->moravec_pattern;
|
|
|
|
detector_options->harris_threshold = options->harris_threshold;
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Features *libmv_detectFeaturesByte(
|
|
|
|
const unsigned char *image_buffer,
|
|
|
|
int width, int height,
|
|
|
|
int channels,
|
|
|
|
libmv_DetectOptions *options)
|
2013-10-08 13:53:59 +00:00
|
|
|
{
|
|
|
|
// Prepare the image.
|
2014-02-20 13:41:05 +00:00
|
|
|
FloatImage image;
|
|
|
|
libmv_byteBufferToImage(image_buffer, width, height, channels, &image);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
// Configure detector.
|
2014-02-20 13:41:05 +00:00
|
|
|
DetectOptions detector_options;
|
2013-10-08 13:53:59 +00:00
|
|
|
libmv_convertDetectorOptions(options, &detector_options);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
// Run the detector.
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv::vector<Feature> detected_features;
|
|
|
|
Detect(image, detector_options, &detected_features);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
// Convert result to C-API.
|
|
|
|
libmv_Features *result = libmv_featuresFromVector(detected_features);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_Features *libmv_detectFeaturesFloat(const float *image_buffer,
|
|
|
|
int width, int height,
|
|
|
|
int channels,
|
|
|
|
libmv_DetectOptions *options)
|
2013-10-08 13:53:59 +00:00
|
|
|
{
|
|
|
|
// Prepare the image.
|
2014-02-20 13:41:05 +00:00
|
|
|
FloatImage image;
|
|
|
|
libmv_floatBufferToImage(image_buffer, width, height, channels, &image);
|
2013-10-08 13:53:59 +00:00
|
|
|
|
|
|
|
// Configure detector.
|
2014-02-20 13:41:05 +00:00
|
|
|
DetectOptions detector_options;
|
2013-10-08 13:53:59 +00:00
|
|
|
libmv_convertDetectorOptions(options, &detector_options);
|
|
|
|
|
|
|
|
// Run the detector.
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv::vector<Feature> detected_features;
|
|
|
|
Detect(image, detector_options, &detected_features);
|
2013-10-08 13:53:59 +00:00
|
|
|
|
|
|
|
// Convert result to C-API.
|
|
|
|
libmv_Features *result = libmv_featuresFromVector(detected_features);
|
|
|
|
return result;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_featuresDestroy(libmv_Features *libmv_features)
|
2013-07-31 13:48:12 +00:00
|
|
|
{
|
2013-10-09 08:46:02 +00:00
|
|
|
if (libmv_features->features) {
|
2013-10-09 19:49:09 +00:00
|
|
|
LIBMV_STRUCT_DELETE(libmv_features->features);
|
2013-10-09 08:46:02 +00:00
|
|
|
}
|
2013-07-31 13:48:12 +00:00
|
|
|
|
2013-10-09 19:49:09 +00:00
|
|
|
LIBMV_STRUCT_DELETE(libmv_features);
|
2013-07-31 13:48:12 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
int libmv_countFeatures(const libmv_Features *libmv_features)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
|
|
|
return libmv_features->count;
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_getFeature(const libmv_Features *libmv_features,
|
|
|
|
int number,
|
|
|
|
double *x, double *y, double *score, double *size)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
Feature &feature = libmv_features->features[number];
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-10-08 13:53:59 +00:00
|
|
|
*x = feature.x;
|
|
|
|
*y = feature.y;
|
2011-11-07 12:55:18 +00:00
|
|
|
*score = feature.score;
|
|
|
|
*size = feature.size;
|
|
|
|
}
|
|
|
|
|
2013-07-31 13:48:12 +00:00
|
|
|
/* ************ Camera intrinsics ************ */
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_CameraIntrinsics *libmv_cameraIntrinsicsNew(
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options)
|
2013-03-15 11:59:46 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics =
|
|
|
|
libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
|
2013-03-15 11:59:46 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_CameraIntrinsics *) camera_intrinsics;
|
2013-03-15 11:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv_CameraIntrinsics *libmv_cameraIntrinsicsCopy(
|
|
|
|
const libmv_CameraIntrinsics *libmvIntrinsics)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const CameraIntrinsics *orig_intrinsics =
|
|
|
|
(const CameraIntrinsics *) libmvIntrinsics;
|
|
|
|
|
|
|
|
CameraIntrinsics *new_intrinsics = NULL;
|
|
|
|
|
|
|
|
switch (orig_intrinsics->GetDistortionModelType()) {
|
|
|
|
case libmv::DISTORTION_MODEL_POLYNOMIAL:
|
|
|
|
{
|
|
|
|
const PolynomialCameraIntrinsics *polynomial_intrinsics =
|
|
|
|
static_cast<const PolynomialCameraIntrinsics*>(orig_intrinsics);
|
|
|
|
new_intrinsics = LIBMV_OBJECT_NEW(PolynomialCameraIntrinsics,
|
|
|
|
*polynomial_intrinsics);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case libmv::DISTORTION_MODEL_DIVISION:
|
|
|
|
{
|
|
|
|
const DivisionCameraIntrinsics *division_intrinsics =
|
|
|
|
static_cast<const DivisionCameraIntrinsics*>(orig_intrinsics);
|
|
|
|
new_intrinsics = LIBMV_OBJECT_NEW(DivisionCameraIntrinsics,
|
|
|
|
*division_intrinsics);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
assert(!"Unknown distortion model");
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
return (libmv_CameraIntrinsics *) new_intrinsics;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsDestroy(libmv_CameraIntrinsics *libmvIntrinsics)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2013-10-09 08:46:02 +00:00
|
|
|
LIBMV_OBJECT_DELETE(libmvIntrinsics, CameraIntrinsics);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsUpdate(
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
|
|
|
|
libmv_CameraIntrinsics *libmv_intrinsics)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-12-10 16:38:28 +00:00
|
|
|
double focal_length = libmv_camera_intrinsics_options->focal_length;
|
|
|
|
double principal_x = libmv_camera_intrinsics_options->principal_point_x;
|
|
|
|
double principal_y = libmv_camera_intrinsics_options->principal_point_y;
|
|
|
|
int image_width = libmv_camera_intrinsics_options->image_width;
|
|
|
|
int image_height = libmv_camera_intrinsics_options->image_height;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
/* Try avoid unnecessary updates,
|
|
|
|
* so pre-computed distortion grids are not freed.
|
|
|
|
*/
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-12-10 16:38:28 +00:00
|
|
|
if (camera_intrinsics->focal_length() != focal_length)
|
|
|
|
camera_intrinsics->SetFocalLength(focal_length, focal_length);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-12-10 16:38:28 +00:00
|
|
|
if (camera_intrinsics->principal_point_x() != principal_x ||
|
|
|
|
camera_intrinsics->principal_point_y() != principal_y)
|
|
|
|
{
|
|
|
|
camera_intrinsics->SetPrincipalPoint(principal_x, principal_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (camera_intrinsics->image_width() != image_width ||
|
|
|
|
camera_intrinsics->image_height() != image_height)
|
|
|
|
{
|
|
|
|
camera_intrinsics->SetImageSize(image_width, image_height);
|
|
|
|
}
|
2014-02-20 13:41:05 +00:00
|
|
|
|
|
|
|
switch (libmv_camera_intrinsics_options->distortion_model) {
|
|
|
|
case LIBMV_DISTORTION_MODEL_POLYNOMIAL:
|
|
|
|
{
|
|
|
|
assert(camera_intrinsics->GetDistortionModelType() ==
|
|
|
|
libmv::DISTORTION_MODEL_POLYNOMIAL);
|
|
|
|
|
|
|
|
PolynomialCameraIntrinsics *polynomial_intrinsics =
|
|
|
|
(PolynomialCameraIntrinsics *) camera_intrinsics;
|
|
|
|
|
|
|
|
double k1 = libmv_camera_intrinsics_options->polynomial_k1;
|
|
|
|
double k2 = libmv_camera_intrinsics_options->polynomial_k2;
|
|
|
|
double k3 = libmv_camera_intrinsics_options->polynomial_k3;
|
|
|
|
|
|
|
|
if (polynomial_intrinsics->k1() != k1 ||
|
|
|
|
polynomial_intrinsics->k2() != k2 ||
|
|
|
|
polynomial_intrinsics->k3() != k3)
|
|
|
|
{
|
|
|
|
polynomial_intrinsics->SetRadialDistortion(k1, k2, k3);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LIBMV_DISTORTION_MODEL_DIVISION:
|
|
|
|
{
|
|
|
|
assert(camera_intrinsics->GetDistortionModelType() ==
|
|
|
|
libmv::DISTORTION_MODEL_DIVISION);
|
|
|
|
|
|
|
|
DivisionCameraIntrinsics *division_intrinsics =
|
|
|
|
(DivisionCameraIntrinsics *) camera_intrinsics;
|
|
|
|
|
|
|
|
double k1 = libmv_camera_intrinsics_options->division_k1;
|
|
|
|
double k2 = libmv_camera_intrinsics_options->division_k2;
|
|
|
|
|
|
|
|
if (division_intrinsics->k1() != k1 ||
|
|
|
|
division_intrinsics->k2() != k2)
|
|
|
|
{
|
|
|
|
division_intrinsics->SetDistortion(k1, k2);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
assert(!"Unknown distortion model");
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsSetThreads(
|
|
|
|
libmv_CameraIntrinsics *libmv_intrinsics, int threads)
|
2013-03-15 11:59:46 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
|
2013-03-15 11:59:46 +00:00
|
|
|
|
|
|
|
camera_intrinsics->SetThreads(threads);
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsExtractOptions(
|
|
|
|
const libmv_CameraIntrinsics *libmv_intrinsics,
|
|
|
|
libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
|
2012-12-10 16:38:28 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
const CameraIntrinsics *camera_intrinsics =
|
|
|
|
(const CameraIntrinsics *) libmv_intrinsics;
|
|
|
|
|
|
|
|
// Fill in options which are common for all distortion models.
|
|
|
|
camera_intrinsics_options->focal_length = camera_intrinsics->focal_length();
|
|
|
|
camera_intrinsics_options->principal_point_x =
|
|
|
|
camera_intrinsics->principal_point_x();
|
|
|
|
camera_intrinsics_options->principal_point_y =
|
|
|
|
camera_intrinsics->principal_point_y();
|
|
|
|
|
|
|
|
camera_intrinsics_options->image_width = camera_intrinsics->image_width();
|
|
|
|
camera_intrinsics_options->image_height = camera_intrinsics->image_height();
|
|
|
|
|
|
|
|
switch (camera_intrinsics->GetDistortionModelType()) {
|
|
|
|
case libmv::DISTORTION_MODEL_POLYNOMIAL:
|
|
|
|
{
|
|
|
|
const PolynomialCameraIntrinsics *polynomial_intrinsics =
|
|
|
|
static_cast<const PolynomialCameraIntrinsics *>(camera_intrinsics);
|
|
|
|
camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_POLYNOMIAL;
|
|
|
|
camera_intrinsics_options->polynomial_k1 = polynomial_intrinsics->k1();
|
|
|
|
camera_intrinsics_options->polynomial_k2 = polynomial_intrinsics->k2();
|
|
|
|
camera_intrinsics_options->polynomial_k3 = polynomial_intrinsics->k3();
|
|
|
|
camera_intrinsics_options->polynomial_p1 = polynomial_intrinsics->p1();
|
|
|
|
camera_intrinsics_options->polynomial_p1 = polynomial_intrinsics->p2();
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
case libmv::DISTORTION_MODEL_DIVISION:
|
|
|
|
{
|
|
|
|
const DivisionCameraIntrinsics *division_intrinsics =
|
|
|
|
static_cast<const DivisionCameraIntrinsics *>(camera_intrinsics);
|
|
|
|
camera_intrinsics_options->distortion_model = LIBMV_DISTORTION_MODEL_DIVISION;
|
|
|
|
camera_intrinsics_options->division_k1 = division_intrinsics->k1();
|
|
|
|
camera_intrinsics_options->division_k2 = division_intrinsics->k2();
|
|
|
|
break;
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
default:
|
|
|
|
assert(!"Uknown distortion model");
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsUndistortByte(
|
|
|
|
const libmv_CameraIntrinsics *libmv_intrinsics,
|
|
|
|
unsigned char *src, unsigned char *dst, int width, int height,
|
|
|
|
float overscan, int channels)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics = (CameraIntrinsics *) libmv_intrinsics;
|
|
|
|
camera_intrinsics->UndistortBuffer(src,
|
|
|
|
width, height, overscan, channels,
|
|
|
|
dst);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsUndistortFloat(
|
|
|
|
const libmv_CameraIntrinsics *libmvIntrinsics,
|
|
|
|
float *src, float *dst, int width, int height,
|
|
|
|
float overscan, int channels)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
|
|
|
|
intrinsics->UndistortBuffer(src,
|
|
|
|
width, height, overscan, channels,
|
|
|
|
dst);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsDistortByte(
|
|
|
|
const libmv_CameraIntrinsics *libmvIntrinsics,
|
|
|
|
unsigned char *src, unsigned char *dst, int width, int height,
|
|
|
|
float overscan, int channels)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
|
|
|
|
intrinsics->DistortBuffer(src,
|
|
|
|
width, height, overscan, channels,
|
|
|
|
dst);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsDistortFloat(
|
|
|
|
const libmv_CameraIntrinsics *libmvIntrinsics,
|
|
|
|
float *src, float *dst, int width, int height,
|
|
|
|
float overscan, int channels)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmvIntrinsics;
|
|
|
|
intrinsics->DistortBuffer(src,
|
|
|
|
width, height, overscan, channels,
|
|
|
|
dst);
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsApply(
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
|
|
|
|
double x, double y, double *x1, double *y1)
|
|
|
|
{
|
|
|
|
/* do a lens undistortion if focal length is non-zero only */
|
2012-12-10 16:38:28 +00:00
|
|
|
if (libmv_camera_intrinsics_options->focal_length) {
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics =
|
|
|
|
libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
|
|
|
|
|
|
|
|
camera_intrinsics->ApplyIntrinsics(x, y, x1, y1);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_cameraIntrinsicsInvert(
|
|
|
|
const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
|
|
|
|
double x, double y, double *x1, double *y1)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-02-20 13:41:05 +00:00
|
|
|
/* do a lens distortion if focal length is non-zero only */
|
2012-12-10 16:38:28 +00:00
|
|
|
if (libmv_camera_intrinsics_options->focal_length) {
|
2014-02-20 13:41:05 +00:00
|
|
|
CameraIntrinsics *camera_intrinsics =
|
|
|
|
libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
|
|
|
|
|
|
|
|
camera_intrinsics->InvertIntrinsics(x, y, x1, y1);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-12 22:40:12 +00:00
|
|
|
|
2014-02-20 13:41:05 +00:00
|
|
|
void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2],
|
|
|
|
double (*x2)[2],
|
|
|
|
int num_points,
|
|
|
|
double H[3][3])
|
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
|
|
|
{
|
|
|
|
libmv::Mat x1_mat, x2_mat;
|
|
|
|
libmv::Mat3 H_mat;
|
|
|
|
|
|
|
|
x1_mat.resize(2, num_points);
|
|
|
|
x2_mat.resize(2, num_points);
|
|
|
|
|
|
|
|
for (int i = 0; i < num_points; i++) {
|
|
|
|
x1_mat.col(i) = libmv::Vec2(x1[i][0], x1[i][1]);
|
|
|
|
x2_mat.col(i) = libmv::Vec2(x2[i][0], x2[i][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
LG << "x1: " << x1_mat;
|
|
|
|
LG << "x2: " << x2_mat;
|
|
|
|
|
2013-11-20 09:19:43 +00:00
|
|
|
libmv::EstimateHomographyOptions options;
|
2014-02-20 13:41:05 +00:00
|
|
|
libmv::EstimateHomography2DFromCorrespondences(x1_mat,
|
|
|
|
x2_mat,
|
|
|
|
options,
|
|
|
|
&H_mat);
|
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
|
|
|
|
|
|
|
LG << "H: " << H_mat;
|
|
|
|
|
|
|
|
memcpy(H, H_mat.data(), 9 * sizeof(double));
|
|
|
|
}
|
|
|
|
|
2013-05-12 22:40:12 +00:00
|
|
|
#endif
|