3 years agoFix strict compiler warnings, unused variables master
Sergey Sharybin [Tue, 9 May 2017 08:16:42 +0000 (10:16 +0200)]
Fix strict compiler warnings, unused variables

3 years agoFix T50243: libmv_panography_test is broken
Sergey Sharybin [Wed, 14 Dec 2016 09:44:57 +0000 (10:44 +0100)]
Fix T50243: libmv_panography_test is broken

There was fully wrong logic in comparison: was actually accessing memory
past the array boundary. Run test manually and the figure seems correct
to me now.

Spotted by @LazyDodo, thanks!

3 years agoFix some strict compiler warnings
Sergey Sharybin [Thu, 14 Jul 2016 09:49:38 +0000 (11:49 +0200)]
Fix some strict compiler warnings

One of them was a real bug!

3 years agoEnable explicit schur complement for BA step
Sergey Sharybin [Wed, 31 May 2017 09:22:34 +0000 (11:22 +0200)]
Enable explicit schur complement for BA step

This is something we do in Blender and only reason it was not
enabled for standalone Libmv is because we did not have fresh
enough version of Ceres bundled.

3 years agoUpdate tests to make tests pass after recent Ceres update
Sergey Sharybin [Wed, 2 Nov 2016 14:32:11 +0000 (15:32 +0100)]
Update tests to make tests pass after recent Ceres update

Just a precision issue, difference is around 1e-7. Should be fine to
simply update expected value.

3 years agoUpdate Ceres to latest release 1.12.0
Sergey Sharybin [Wed, 31 May 2017 08:54:48 +0000 (10:54 +0200)]
Update Ceres to latest release 1.12.0

3 years agoFix crash of keyframe selection on 32bit linux
Sergey Sharybin [Fri, 7 Apr 2017 15:10:44 +0000 (17:10 +0200)]
Fix crash of keyframe selection on 32bit linux

3 years agoSolve some strict warnings in tests
Sergey Sharybin [Tue, 19 Jan 2016 09:00:53 +0000 (14:00 +0500)]
Solve some strict warnings in tests

3 years agoFix a few compiler warnings with macOS / clang.
Brecht Van Lommel [Sat, 18 Feb 2017 22:52:31 +0000 (23:52 +0100)]
Fix a few compiler warnings with macOS / clang.

3 years agoFix comparison of identicals
Mike Erwin [Wed, 31 May 2017 08:43:08 +0000 (10:43 +0200)]
Fix comparison of identicals

Some of these check that dimensions match before running code that
assumes they do match.

Found with PVS-Studio T48917.

3 years agoAdd basic track masking API in place
Sergey Sharybin [Wed, 31 May 2017 08:39:16 +0000 (10:39 +0200)]
Add basic track masking API in place

This brings back ability to mask non-interesting parts of
specific track (the feature got lost with new auto-track API).

Added it back by extending frame accessor class. This isn't really
a frame thing, but we don't have other type of accessor here.

Surely, we can use old-style API here and pass mask via region
tracker options for this particular case, but then it becomes much
less obvious how real auto-tracker will access this mask with old
style API.

So seems we do need an accessor for such data, just matter of
finding better place than frame accessor.

3 years agoTests: Tweak epsilon to avoid what looks a false-positive failure
Sergey Sharybin [Wed, 31 May 2017 08:36:26 +0000 (10:36 +0200)]
Tests: Tweak epsilon to avoid what looks a false-positive failure

3 years agoCMake: Fix mistake in closing branch
Sergey Sharybin [Wed, 31 May 2017 08:15:43 +0000 (10:15 +0200)]
CMake: Fix mistake in closing branch

4 years agoSet of fixes for MSVC215
Sergey Sharybin [Thu, 21 Jul 2016 10:52:33 +0000 (12:52 +0200)]
Set of fixes for MSVC215

- Move GLOG/GFLAGS defines to a more global scope,
  this way ANY of our own libraries will use proper

- Compile png/zlib/openexif on Windows as well since
  those are required for a correct linking.

4 years agoDisable unexisting Ceres option
Sergey Sharybin [Wed, 20 Jul 2016 16:14:46 +0000 (18:14 +0200)]
Disable unexisting Ceres option

Explicit Schur complement requires having
newer Ceres than we currently have bundled.

4 years agoVarious fixes for MSVC
Sergey Sharybin [Wed, 20 Jul 2016 16:04:57 +0000 (18:04 +0200)]
Various fixes for MSVC

- Update Eigen to 3.2.7 since this brings crucial
  fixes for MSVC 2015.

- Switch to STATIC build by default.

  There are issues building current sources as dynamic
  libraries with MSVC2015 and additionally building
  dynamic Ceres is not recommended anyway, so let's
  not do this for the time being.

If anyone finds a way to make this all working --
it'llsurely be a welcome addition.

4 years agoFix strict compiler warnings
Sergey Sharybin [Mon, 4 Jan 2016 13:30:12 +0000 (18:30 +0500)]
Fix strict compiler warnings

4 years agoGLog/GFlags: Reduce difference between upstream and bundled versions
Sergey Sharybin [Sun, 3 Jan 2016 09:17:10 +0000 (14:17 +0500)]
GLog/GFlags: Reduce difference between upstream and bundled versions

Several things here:

- Re-bundled sources using own fork with pull-requests applied on the sources.

- Got rid of changes around include "config.h", it was needed by Blender to
  make it's include directories configuration to work. This could be addressed
  differently from Blender side.

- Moved some customization to defines set by CMakeLists.

4 years agoGFlags linking errors fix for MSVC
Sergey Sharybin [Sat, 2 Jan 2016 07:42:55 +0000 (12:42 +0500)]
GFlags linking errors fix for MSVC

4 years agoAlternative fix for missing prototype for a couple of functions
Sergey Sharybin [Thu, 31 Dec 2015 12:56:12 +0000 (17:56 +0500)]
Alternative fix for missing prototype for a couple of functions

4 years agoUpdate GFlags to the latest upstream version
Sergey Sharybin [Thu, 31 Dec 2015 12:33:05 +0000 (17:33 +0500)]
Update GFlags to the latest upstream version

Makes it easier to synchronize some compiler/warning fixes.

4 years agoGLog: Solve some compilation warnings
Sergey Sharybin [Thu, 31 Dec 2015 11:15:59 +0000 (16:15 +0500)]
GLog: Solve some compilation warnings

Those are actually sent to a pull-request, see

4 years agoAdd Martijn Berger to the AUTHORS file
Sergey Sharybin [Thu, 31 Dec 2015 11:13:53 +0000 (16:13 +0500)]
Add Martijn Berger to the AUTHORS file

4 years agoFix compilation error of Glog and Gflags with MSVC2015
Martijn Berger [Thu, 31 Dec 2015 11:13:08 +0000 (16:13 +0500)]
Fix compilation error of Glog and Gflags with MSVC2015

4 years agoFix OS X (with 10.11 SDK) glog build errors due to using deprecated code.
Brecht Van Lommel [Thu, 31 Dec 2015 09:00:58 +0000 (14:00 +0500)]
Fix OS X (with 10.11 SDK) glog build errors due to using deprecated code.

Some values are now restored to the ones from before the upgrade today.

4 years agoTweaks to Glog to support building on all platforms
Sergey Sharybin [Wed, 30 Dec 2015 11:59:28 +0000 (16:59 +0500)]
Tweaks to Glog to support building on all platforms

This makes it possible to compile Libmv on all platforms,
amount of hacks is lower, which could bring some warnings
up, but those are better be addressed via upstream which
is now rather active.

4 years agoEnable explicit Schur complement matrix by default
Sergey Sharybin [Wed, 30 Dec 2015 11:15:47 +0000 (16:15 +0500)]
Enable explicit Schur complement matrix by default

Gives up to 2x speed up of camera solving process in average scene.
In the really huge one it might be slower, but that we need to investigate.

4 years agoFix one frame memory leak when tracking last frame
Sergey Sharybin [Wed, 30 Dec 2015 11:13:03 +0000 (16:13 +0500)]
Fix one frame memory leak when tracking last frame

4 years agoMotion tracking not workig with Xcode 7 on OS X.
Brecht Van Lommel [Wed, 30 Dec 2015 11:11:24 +0000 (16:11 +0500)]
Motion tracking not workig with Xcode 7 on OS X.

Caused by use of the uninitialized shape_ variable in Resize().

4 years agoUpdate GLog to latest upstream
Sergey Sharybin [Wed, 30 Dec 2015 10:56:40 +0000 (15:56 +0500)]
Update GLog to latest upstream

Should fix issues building with MSVC2015.

4 years agoFix wrong README file reference
Sergey Sharybin [Wed, 30 Dec 2015 11:01:10 +0000 (16:01 +0500)]
Fix wrong README file reference

5 years agoMake README more informative for GitHub viewers
Keir Mierle [Mon, 11 May 2015 09:16:53 +0000 (02:16 -0700)]
Make README more informative for GitHub viewers

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

5 years agoSimplify the modal solver Ceres cost function
Keir Mierle [Mon, 11 May 2015 08:54:09 +0000 (01:54 -0700)]
Simplify the modal solver Ceres cost function

Fix test by flipping the quaternion.

Reviewers: sergey

Reviewed By: sergey

Projects: #libmv

Differential Revision:

5 years agoSynchronize MSVC compilation fixes from Blender
Sergey Sharybin [Wed, 31 Dec 2014 14:05:51 +0000 (19:05 +0500)]
Synchronize MSVC compilation fixes from Blender

5 years agoUpdate GLog to latest upstream revision 143
Sergey Sharybin [Wed, 31 Dec 2014 10:32:07 +0000 (15:32 +0500)]
Update GLog to latest upstream revision 143

Mainly to solve compilation error with

5 years agoUpdate GFlags to latest release 2.1.1
Sergey Sharybin [Fri, 12 Dec 2014 09:59:55 +0000 (14:59 +0500)]
Update GFlags to latest release 2.1.1

Main purpose of this (andsome of upcoming) update is to check if the
upstream sources are useable without any modifications for us. And if
not, then we'll need to consider moving some changes into upstream.

This commit contains an one-to-one copy of the upstream GFlags library
and also changes namespace usage since it's changed in the upstream.

5 years agoLibmv: Code cleanup, mixed class/struct in declaration/definition
Sergey Sharybin [Fri, 31 Oct 2014 21:53:36 +0000 (02:53 +0500)]
Libmv: Code cleanup, mixed class/struct in declaration/definition

5 years agoLibmv: Support disabled color channels in tracking settings
Sergey Sharybin [Thu, 30 Oct 2014 18:13:53 +0000 (23:13 +0500)]
Libmv: Support disabled color channels in tracking settings

This was never ported to a new tracking pipeline and now it's done using
FrameAccessor::Transform routines. Quite striaghtforward, but i've changed
order of grayscale conversion in blender side with call of transform callback.

This way it's much easier to perform rescaling in libmv side.

5 years agoMinor keyframe selection cleanups
Keir Mierle [Sat, 23 Aug 2014 07:38:01 +0000 (00:38 -0700)]
Minor keyframe selection cleanups

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

5 years agoimplement backward prediction
Sergey Sharybin [Fri, 22 Aug 2014 19:55:32 +0000 (01:55 +0600)]
implement backward prediction

The title actually says it all, just extend current implementation
of PredictMarkerPosition() to cases when tracking happens in the reverse
order (from the end frame to start).

it's still doesn't solve all the ambiguity happening in the function
in cases when one tracks the feature and then re-tracks it in order
to refine the sliding. This is considered a separate TODO for now and
will likely be solved by passing tracking direction to the prediction

Reviewers: keir

Reviewed By: keir

Differential Revision:

5 years agoMake libmv compile on Ubuntu 14.04
Keir Mierle [Fri, 22 Aug 2014 05:45:22 +0000 (22:45 -0700)]
Make libmv compile on Ubuntu 14.04

Reviewers: fsiddi

Reviewed By: fsiddi

Subscribers: sergey

Differential Revision:

6 years agoFix wrong residual blocks counter
Sergey Sharybin [Tue, 22 Jul 2014 18:42:00 +0000 (00:42 +0600)]
Fix wrong residual blocks counter

This happened in cases when having zero-weighted tracks
and could lead to some assert failures on marking parameter
block constant.

6 years agoFix search area sliding issue
Sergey Sharybin [Fri, 18 Jul 2014 06:52:03 +0000 (12:52 +0600)]
Fix search area sliding issue

The only way to do this is to store search region in floats
and round when we need to sample it. Otherwise you'll always
have sliding effect caused by rounding the issues, especially
when doing incremental offset (thing which happens in the
prediction code).

Pretty much straightforward change apart from stuff to be kept
in mind: offset calculation int should happen relative to the
rounded search region. This is because tracker works in the space
of the search window image which get's rounded on the frame access,

This makes API a bit creepy because frame accessor uses the same
Region struct as the search window in Marker and ideally we would
need to have either IntRegion or Region<int> in order to make
Libmv fully track on what's getting rounded and when.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoStart the automatic 2D tracking code
Keir Mierle [Fri, 9 May 2014 21:00:03 +0000 (23:00 +0200)]
Start the automatic 2D tracking code

This starts the 2D automatic tracking code. It is totally unfinished.

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAlso shift the search window
Keir Mierle [Fri, 9 May 2014 12:36:04 +0000 (14:36 +0200)]
Also shift the search window

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoChange the search region to absolute frame coordinates
Keir Mierle [Fri, 9 May 2014 11:06:28 +0000 (13:06 +0200)]
Change the search region to absolute frame coordinates

Smarter Eigen usage

Better error logging

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoFirst cut at predictive tracing
Keir Mierle [Fri, 9 May 2014 10:02:47 +0000 (12:02 +0200)]
First cut at predictive tracing

This adds a Kalman filter-based approach to predict where a marker
will go in the next frame to track. Hopefully this will make the
tracker work faster by avoiding lengthy searches. This code
compiles, but is otherwise untested, and likely does not work.

Fix else branch

Add some tests

Update patch coordinates as well (and test)

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAdd constructor to AutoTrack
Keir Mierle [Thu, 8 May 2014 14:05:28 +0000 (16:05 +0200)]
Add constructor to AutoTrack

6 years agoFix GetMarker compilation issue
Keir Mierle [Thu, 8 May 2014 14:04:20 +0000 (16:04 +0200)]
Fix GetMarker compilation issue

6 years agoExpose GetMarker() in AutoTrack
Keir Mierle [Thu, 8 May 2014 13:50:26 +0000 (15:50 +0200)]
Expose GetMarker() in AutoTrack

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAdd public SetMarkers to AutoTrack
Keir Mierle [Thu, 8 May 2014 13:38:14 +0000 (15:38 +0200)]
Add public SetMarkers to AutoTrack

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoMake autotrack skeleton compile
Keir Mierle [Thu, 8 May 2014 13:17:48 +0000 (15:17 +0200)]
Make autotrack skeleton compile

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAdd preliminary TrackMarkerToFrame in autotrack
Keir Mierle [Wed, 7 May 2014 16:48:55 +0000 (18:48 +0200)]
Add preliminary TrackMarkerToFrame in autotrack

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoRemove assert from ArrayND Resize
Sergey Sharybin [Wed, 7 May 2014 15:59:11 +0000 (17:59 +0200)]
Remove assert from ArrayND Resize

That assert broke initialization of arrays which doesn't
own the data since constructor uses Resize to set shape
and strides.

Strides are still to be fixed, but that's for later.

6 years agoFix ArrayND freeing the data it doesn't own
Sergey Sharybin [Wed, 7 May 2014 15:42:21 +0000 (17:42 +0200)]
Fix ArrayND freeing the data it doesn't own

Can't really guarantee it works fully correct now,
but at least this check is needed anyway and compilation
works just fine.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoMinor changes
Keir Mierle [Wed, 7 May 2014 10:03:32 +0000 (12:03 +0200)]
Minor changes

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoFix compilation error in frame accessor
Sergey Sharybin [Wed, 7 May 2014 09:12:23 +0000 (11:12 +0200)]
Fix compilation error in frame accessor

- int64 is not a standard type, we've got int64_t defined in
  std int. We also have an msvc port of this header, so should
  not be an issue.

- Fixed inconsistency in usage of CacheKey and Key, used Key.

- Some functions weren't marked as virtual.

Additional change: added self to authors.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoStart new Tracks implementation
Keir Mierle [Tue, 6 May 2014 20:30:59 +0000 (22:30 +0200)]
Start new Tracks implementation

This adds the new Tracks implementation, as well as a
trivial test to show it compiles.

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAdd Reconstruction class for new API
Keir Mierle [Tue, 6 May 2014 17:10:51 +0000 (19:10 +0200)]
Add Reconstruction class for new API

This starts the new Reconstruction class (with support for e.g. planes). This
also starts the new namespace "mv" which will eventually have all the symbols
we wish to export.

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoAdd a new Tracks implementation
Keir Mierle [Tue, 6 May 2014 15:52:53 +0000 (17:52 +0200)]
Add a new Tracks implementation

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoInitial commit of unfinished AutoTrack API
Keir Mierle [Tue, 6 May 2014 15:01:39 +0000 (17:01 +0200)]
Initial commit of unfinished AutoTrack API

This starts the creating the new AutoTrack API. The new API will
make it possible for libmv to do full autotracking, including
predictive tracking and also support multiple motion models (3D
planes etc).

The first goal (not in this patch) is to convert Blender to use
the new API without adding any new functionality.

Note: This does not add any of the API to the build system!
It likely does not compile.

Reviewers: sergey

Reviewed By: sergey

Differential Revision:

6 years agoFix homography test failure
Sergey Sharybin [Tue, 6 May 2014 11:09:22 +0000 (13:09 +0200)]
Fix homography test failure

It was caused by assuming that reconstructed homography matrix
should look exactly the same as the matrix used to generate a
test case.

It's not actually valid assumption because different-looking
matrices could correspond to the same exact transform.

In this change we make it so actual "re-projected" vectors
are being checked, not the values in matrix. This makes it
more predictable verification.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoFix compilation on OSX after previous commit
Sergey Sharybin [Wed, 23 Apr 2014 13:14:55 +0000 (19:14 +0600)]
Fix compilation on OSX after previous commit

EXPECT_EQ wasn't defined in the scope.

6 years agoMove aligned malloc implementation into own file
Sergey Sharybin [Wed, 23 Apr 2014 09:08:16 +0000 (15:08 +0600)]
Move aligned malloc implementation into own file

It was rather stupid having it in brute region tracker,
now it is in own file in base library (which was also
added in this commit, before this it consist of header
files only).

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoOptimization of PearsonProductMomentCorrelation
Sergey Sharybin [Mon, 21 Apr 2014 08:14:03 +0000 (14:14 +0600)]
Optimization of PearsonProductMomentCorrelation

Pass the arrays by reference rather than by value,
should give some percent of speedup.

Also don't pass the dimensions to the function but
get them from the images themselves.

Hopefully this will give some %% of tracker speedup.

6 years agoFix wrong assert in ResizeImage()
Sergey Sharybin [Mon, 21 Apr 2014 08:10:43 +0000 (14:10 +0600)]
Fix wrong assert in ResizeImage()

The assert didn't make any sense because ComputeBoundingBox()
is intended to return bounding box in the following way:
(xmin, xmax, ymin, ymax).

6 years agoAdd unit tests for buffer (un)distortion
Sergey Sharybin [Thu, 17 Apr 2014 12:42:43 +0000 (18:42 +0600)]
Add unit tests for buffer (un)distortion

Currently only uses identity camera intrinsics just to
see whether lookup grids are properly allocated.

Should prevent accidents like that one happened recently
with crashing Blender after Libmv re-integration.

6 years agoFix offset array not being properly allocated
Sergey Sharybin [Thu, 17 Apr 2014 11:52:23 +0000 (17:52 +0600)]
Fix offset array not being properly allocated

We really do need unit test for buffer (un)distortion,
didn't notice this bug for until new Libmv has been
integrated into Blender.

6 years agoSupport multiple distortion models, including a new division model
Sergey Sharybin [Thu, 17 Apr 2014 10:26:12 +0000 (16:26 +0600)]
Support multiple distortion models, including a new division model

This commit makes it so CameraIntrinsics is no longer hardcoded
to use the traditional polynomial radial distortion model. Currently
the distortion code has generic logic which is shared between
different distortion models, but had no other models until now.

This moves everything specific to the polynomial radial distortion
to a subclass PolynomialDistortionCameraIntrinsics(), and adds a
new division distortion model suitable for cameras such as the
GoPro which have much stronger distortion due to their fisheye lens.

This also cleans up the internal API of CameraIntrinsics to make
it easier to understand and reduces old C-style code.

Reviewers: keir

Reviewed By: keir

CC: jta
Differential Revision:

6 years agoFix failure of the image transform linear test
Sergey Sharybin [Tue, 15 Apr 2014 12:23:38 +0000 (18:23 +0600)]
Fix failure of the image transform linear test

Mainly was caused by the flakyness of image rotation in cases
when image has even size. The test was expecting the transform
code to rotate the image around pixel corner, which isn't a
common behavior in image processing applications. Rotation
is usually done around the pixel center.

So now made it so RotateImage() rotates the image around the
pixel center which gives 100% proper result for odd sized images
(i.e. center pixel stays untouched).

Also made the tests to use odd image sizes which are more
predictable by the humans. We can use even sized images in the
tests as well but their result wouldn't be so much spectacular.

Another issue with the tests was caused by RescaleImageTranslation
test which did expect things which are not happening in the

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoUnit tests for feature detector
Sergey Sharybin [Sun, 13 Apr 2014 18:01:32 +0000 (00:01 +0600)]
Unit tests for feature detector

Currently covers only simplest cases with synthetic images.
Also at this point mainly Harris detector is being testes,
other detectors behaves a bit unexpected on synthetic images
and this is to be investigated further.

Tests will be extended further later.

Additional change:

- Added constructor to Feature structure
- Added operator << for feature for easier debug dumps.

TODO: Some tests are not giving the result which i was expected
to. This is to be investigated further by finding the reference
detector implementation. For until then keeping that tests
commented out.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoCompilation error fix
Sergey Sharybin [Fri, 4 Apr 2014 10:17:57 +0000 (16:17 +0600)]
Compilation error fix

Not totally sure why this is needed, but multiview indeed
uses V3D library still, so it needs to be linked against it.

Patc by Martijn Berger, thanks!

6 years agoUpgrade Eigen to 3.2.1 version
Sergey Sharybin [Fri, 4 Apr 2014 08:03:43 +0000 (14:03 +0600)]
Upgrade Eigen to 3.2.1 version

To main reasons for this:
- Probably this would solve strict compiler warnings
- It brings new stuff like sparse LU decomposition which
  might be useful in the future.

6 years agoFix compilation error when using make from the sources root
Sergey Sharybin [Thu, 3 Apr 2014 09:08:26 +0000 (15:08 +0600)]
Fix compilation error when using make from the sources root

- Don't force flann to be static. It's a general rule on linux
  to have dynamic libraries for all the bits instead of having
  statically-linked dynamic libraries.

- Some weirdo stuff was happening around OpenExif, it was only
  built on Apple, so don't link targets against this lib on
  other platforms.

- Some libraries were missing for qt-tracker.

6 years agoFix bad memory write in BA code when having zero-weighted tracks
Sergey Sharybin [Wed, 26 Mar 2014 11:44:09 +0000 (17:44 +0600)]
Fix bad memory write in BA code when having zero-weighted tracks

Issue was really stupid and caused by the wrong vector initialization.

6 years agoAttempt to fix compilation error with msvc2013
Sergey Sharybin [Fri, 21 Mar 2014 10:02:41 +0000 (16:02 +0600)]
Attempt to fix compilation error with msvc2013

6 years agoCompilation fixes for MinGW
Sergey Sharybin [Thu, 20 Mar 2014 17:07:34 +0000 (23:07 +0600)]
Compilation fixes for MinGW

Many thanks to Antony Riakiotakis for the patch!

6 years agoImplement separate BA step for tracks which have constant zero weight
Sergey Sharybin [Thu, 27 Feb 2014 10:21:19 +0000 (16:21 +0600)]
Implement separate BA step for tracks which have constant zero weight

This is needed to minimize their reprojection error over the footage.
Without this extra step positions of such tracks were calculated by
algebraic intersection code only, which doesn't give best precision.

6 years agoAvoid zero-sized problem when doing euclidean intersection
Sergey Sharybin [Thu, 27 Feb 2014 08:16:42 +0000 (14:16 +0600)]
Avoid zero-sized problem when doing euclidean intersection

Zero-sized problem might occur when intersecting track with
constant zero weight. For such tracks we'll just use result
of algebraic intersection.

TODO: We probably need to have a separate BA step to adjust
positions of tracks with constant zero weight.

6 years agoIgnore zero weighted markers in keyframe selection
Sergey Sharybin [Wed, 26 Feb 2014 12:00:40 +0000 (18:00 +0600)]
Ignore zero weighted markers in keyframe selection

It doesn't make sense to use zero-weighted tracks as a correspondences
in keyframe selection.

Such tracks are not guaranteed to be tracked accurately because their
purpose is to add reference points in 3D space without affecting the

6 years agoTweaks to make bundling into Blender warning-less
Sergey Sharybin [Wed, 26 Feb 2014 07:23:02 +0000 (13:23 +0600)]
Tweaks to make bundling into Blender warning-less

Mainly issue i caused by conflicts in include directories,
so glog used to include config.h from gflags. It might be
fixed by splitting gflags/glog from Libmv in Blender build
system but that's not something fun to work on. Fixed by
making include directories  bit more explicit.

Also solved no-previous-prototype warnings.

6 years agoRaise epsilon used for model solver test
Sergey Sharybin [Fri, 21 Feb 2014 08:55:13 +0000 (14:55 +0600)]
Raise epsilon used for model solver test

It was too much small leading to false failure triggering
caused simply by precision issues.

6 years agoMade it possible to link against Ceres installed on the system
Sergey Sharybin [Tue, 18 Feb 2014 17:35:52 +0000 (23:35 +0600)]
Made it possible to link against Ceres installed on the system

Main purpose of this is to get away from bundled Ceres library
which is not so trivial to re-bundle and takes some to do this
(not talking about CMake options conflicts and pollution).

Enabled by setting WITH_SYSTEM_CERES=ON. Default paths to search
Ceres library:

- /usr/local
- /sw
- /opt/local
- /opt/csw
- /opt/lib/ceres

You might also specify Ceres root directory using CERES_ROOT_DIR
variable (both CMake and environment variables are supported).

If your Ceres is build statically, you're to control all additional
libraries needed to link against using CMAKE_EXE_LINKER_FLAGS.

6 years agoRemove .orig file which was added by accident
Sergey Sharybin [Tue, 18 Feb 2014 13:38:22 +0000 (19:38 +0600)]
Remove .orig file which was added by accident

6 years agoUpgrade glog to latest svn r139
Sergey Sharybin [Thu, 2 Jan 2014 10:02:08 +0000 (16:02 +0600)]
Upgrade glog to latest svn r139

The intention of this upgrade is to get rid of custom patches
we've been having to support compilation on different platforms
and compilers.

6 years agoTweak Ceres CMake to detect uninstall target properly on Windows
Sergey Sharybin [Tue, 18 Feb 2014 12:46:08 +0000 (18:46 +0600)]
Tweak Ceres CMake to detect uninstall target properly on Windows

6 years agoFix order of third party libs compilation and options used by them
Sergey Sharybin [Thu, 13 Feb 2014 18:36:44 +0000 (00:36 +0600)]
Fix order of third party libs compilation and options used by them

WITH_FAST_DETECTOR was defined too late and third_party folder
didn't see this option.

6 years agoDisable Ceres unit tests and examples by default
Sergey Sharybin [Thu, 13 Feb 2014 17:55:03 +0000 (23:55 +0600)]
Disable Ceres unit tests and examples by default

Actually we're to switch to external Ceres rather than
bundled one, would make life much easier actually.

6 years agoMade FAST detector optional
Sergey Sharybin [Thu, 6 Feb 2014 12:01:58 +0000 (18:01 +0600)]
Made FAST detector optional

This way it's possible to bundle Libmv sources subset
to applications which doesn't need FAST detector.

Mainly this is done for Blender integration.

6 years agoImplemented scoped_array and use it in detector
Sergey Sharybin [Tue, 28 Jan 2014 12:32:39 +0000 (18:32 +0600)]
Implemented scoped_array and use it in detector

scoped_array is pretty much the same as scoped_ptr
with the only difference that it'll free memory using
delete[] operator.

It also gives some additional API functions to access
array elements.

Currently it only used to manage images denoted as byte
arrays in detector.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoImprovements to weighted tracks behavior
Sergey Sharybin [Tue, 28 Jan 2014 11:23:47 +0000 (17:23 +0600)]
Improvements to weighted tracks behavior

First thing changed by this commit is making it so
Euclidean intersection takes track weight into account
when solving minimization problem. This behaves the
same exact way as it is for BA step.

Second thing is related on how average reprojection error
is being calculated. It didn't take track weight into
account which could confuse users. Now average reprojection
error will give the same result as intersection/BA uses
during minimization which gives much more predictable

Reviewers: keir

Reviewed By: keir

CC: sebastian_k
Differential Revision:

6 years agoFixes for keyframe selection
Sergey Sharybin [Tue, 28 Jan 2014 10:39:14 +0000 (16:39 +0600)]
Fixes for keyframe selection

Using tracks with constant zero weight used to crash
keyframe selection since it was trying to use missing
parameter blocks for Jacobian evaluation,

Also fixed possible issues with wrong camera block being
marked as variable. This could technically happen when
having zero weighted tracks. Made it so all camera blocks
are marked as variable for now.

6 years agoStyle cleanup: wrong indentation of wrapped line
Sergey Sharybin [Tue, 28 Jan 2014 10:10:33 +0000 (16:10 +0600)]
Style cleanup: wrong indentation of wrapped line

6 years agoRework detector API and implement Harris detector
Sergey Sharybin [Tue, 28 Jan 2014 09:21:36 +0000 (15:21 +0600)]
Rework detector API and implement Harris detector

Switch the detector API to a single function which accepts
a float image and detector options. This makes usage of
feature detection more unified across different algorithms.

Options structure is pretty much straightforward and contains
detector to be used and all the detector-specific settings.

Also implemented Harris feature detection algorithm which
is not as fast as FAST one but is expected to detect more
robust feature points.

Reviewers: keir

Reviewed By: keir

Differential Revision:

6 years agoAdd arcanist configuration file
Sergey Sharybin [Fri, 24 Jan 2014 13:14:18 +0000 (19:14 +0600)]
Add arcanist configuration file

6 years agoFix compilation error on NetBSD
Sergey Sharybin [Thu, 9 Jan 2014 09:50:11 +0000 (15:50 +0600)]
Fix compilation error on NetBSD

- NetBSD doesn't provide sincos(3) in libm, so don't try to use it
- Use posix_memalign on NetBSD

Original patch is by Jeorg Sonnenberger to Blender patch tracker, thanks!

6 years agoFix build configuration warnings
Sergey Sharybin [Thu, 2 Jan 2014 09:12:18 +0000 (15:12 +0600)]
Fix build configuration warnings

Those warnings were mainly caused by installation
configuration of Ceres. Made some tweaks to make
CMake happy for now.

But for sure bigger cleanup here is needed.

6 years agoCode and style cleanup
Sergey Sharybin [Thu, 2 Jan 2014 09:04:05 +0000 (15:04 +0600)]
Code and style cleanup

Mainly fixed some style warnings reported by cpplint.

Also changed how camera (un)distortion happens internally
by replacing number of channels as a template argument
with number as channels passing as function argument.
Makes code easier to follow by eliminating loads checks
how much channels are used and which argument to pass to
the template.

6 years agoUpdate Ceres to the latest upstream
Sergey Sharybin [Tue, 31 Dec 2013 14:34:39 +0000 (20:34 +0600)]
Update Ceres to the latest upstream

This brings up much easier termination type usage,
which for us means we might use:


instead of doing manual funky enum values check.

6 years agoUpdate gtest to latest version 1.7.0
Sergey Sharybin [Tue, 31 Dec 2013 14:43:24 +0000 (20:43 +0600)]
Update gtest to latest version 1.7.0

Also reshuffled CMakeLists in order to avoid
conflicts happening between gflags bundled to
Ceres and third_party.