diff options
Diffstat (limited to 'extern/libmv/patches')
-rw-r--r-- | extern/libmv/patches/bundle_tweaks.patch | 36 | ||||
-rw-r--r-- | extern/libmv/patches/config_mac.patch | 13 | ||||
-rw-r--r-- | extern/libmv/patches/detect.patch | 181 | ||||
-rw-r--r-- | extern/libmv/patches/fast.patch | 24 | ||||
-rw-r--r-- | extern/libmv/patches/function_derivative.patch | 21 | ||||
-rw-r--r-- | extern/libmv/patches/high_distortion_crash_fix.patch | 21 | ||||
-rw-r--r-- | extern/libmv/patches/levenberg_marquardt.patch | 71 | ||||
-rw-r--r-- | extern/libmv/patches/mingw.patch | 171 | ||||
-rw-r--r-- | extern/libmv/patches/msvc2010.patch | 12 | ||||
-rw-r--r-- | extern/libmv/patches/overscan.patch | 182 | ||||
-rw-r--r-- | extern/libmv/patches/scaled_distortion.patch | 261 | ||||
-rw-r--r-- | extern/libmv/patches/series | 11 | ||||
-rw-r--r-- | extern/libmv/patches/snrptinf_fix.patch | 15 | ||||
-rw-r--r-- | extern/libmv/patches/v3d_verbosity.patch | 12 |
14 files changed, 39 insertions, 992 deletions
diff --git a/extern/libmv/patches/bundle_tweaks.patch b/extern/libmv/patches/bundle_tweaks.patch index f7b06b0a2dd..aebc257f7f9 100644 --- a/extern/libmv/patches/bundle_tweaks.patch +++ b/extern/libmv/patches/bundle_tweaks.patch @@ -11,6 +11,36 @@ index 067da52..af86c4b 100644 #define LG LOG(INFO) #define V0 LOG(INFO) +diff --git a/src/libmv/simple_pipeline/pipeline.cc b/src/libmv/simple_pipeline/pipeline.cc +index 2459d05..2e4e5a6 100644 +--- a/src/libmv/simple_pipeline/pipeline.cc ++++ b/src/libmv/simple_pipeline/pipeline.cc +@@ -280,25 +280,6 @@ double InternalReprojectionError(const Tracks &image_tracks, + double ex = reprojected_marker.x - markers[i].x; + double ey = reprojected_marker.y - markers[i].y; + +- const int N = 100; +- char line[N]; +- snprintf(line, N, +- "image %-3d track %-3d " +- "x %7.1f y %7.1f " +- "rx %7.1f ry %7.1f " +- "ex %7.1f ey %7.1f" +- " e %7.1f", +- markers[i].image, +- markers[i].track, +- markers[i].x, +- markers[i].y, +- reprojected_marker.x, +- reprojected_marker.y, +- ex, +- ey, +- sqrt(ex*ex + ey*ey)); +- LG << line; +- + total_error += sqrt(ex*ex + ey*ey); + } + LG << "Skipped " << num_skipped << " markers."; diff --git a/src/third_party/glog/src/glog/logging.h b/src/third_party/glog/src/glog/logging.h index 57615ef..a58d478 100644 --- a/src/third_party/glog/src/glog/logging.h @@ -65,7 +95,7 @@ index 50c6a71..b179a1e 100644 #ifdef HAVE_STACKTRACE diff --git a/src/third_party/glog/src/utilities.h b/src/third_party/glog/src/utilities.h -index ee54f94..2d4e99e 100644 +index c4ae256..5c841a0 100644 --- a/src/third_party/glog/src/utilities.h +++ b/src/third_party/glog/src/utilities.h @@ -79,7 +79,7 @@ @@ -106,7 +136,7 @@ index 114762e..682a1b9 100755 /* define if you have libunwind */ #undef HAVE_LIB_UNWIND diff --git a/src/third_party/glog/src/windows/glog/logging.h b/src/third_party/glog/src/windows/glog/logging.h -index 7a6df74..de51586 100755 +index 4257375..2f41681 100755 --- a/src/third_party/glog/src/windows/glog/logging.h +++ b/src/third_party/glog/src/windows/glog/logging.h @@ -82,8 +82,8 @@ @@ -119,4 +149,4 @@ index 7a6df74..de51586 100755 +#include "third_party/gflags/gflags.h" #endif - namespace google { + #ifdef __MINGW32__ diff --git a/extern/libmv/patches/config_mac.patch b/extern/libmv/patches/config_mac.patch deleted file mode 100644 index 5a880155bfa..00000000000 --- a/extern/libmv/patches/config_mac.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/third_party/glog/src/config_mac.h b/src/third_party/glog/src/config_mac.h -index a45575b..5f953d1 100644 ---- a/src/third_party/glog/src/config_mac.h -+++ b/src/third_party/glog/src/config_mac.h -@@ -131,7 +131,7 @@ - #define PACKAGE_VERSION "0.3.1" - - /* How to access the PC from a struct ucontext */ --#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip -+#undef PC_FROM_UCONTEXT - - /* Define to necessary symbol if this constant uses a non-standard name on - your system. */ diff --git a/extern/libmv/patches/detect.patch b/extern/libmv/patches/detect.patch deleted file mode 100644 index 36fea8427db..00000000000 --- a/extern/libmv/patches/detect.patch +++ /dev/null @@ -1,181 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/detect.cc b/src/libmv/simple_pipeline/detect.cc -index 6fc0cdd..8ac42ab 100644 ---- a/src/libmv/simple_pipeline/detect.cc -+++ b/src/libmv/simple_pipeline/detect.cc -@@ -23,15 +23,89 @@ - ****************************************************************************/ - - #include "libmv/simple_pipeline/detect.h" -+#include <third_party/fast/fast.h> - #include <stdlib.h> --#include <string.h> -+#include <memory.h> -+ -+#ifdef __SSE2__ -+#include <emmintrin.h> -+#endif - - namespace libmv { - - typedef unsigned int uint; - -+int featurecmp(const void *a_v, const void *b_v) -+{ -+ Feature *a = (Feature*)a_v; -+ Feature *b = (Feature*)b_v; -+ -+ return b->score - a->score; -+} -+ -+std::vector<Feature> DetectFAST(const unsigned char* data, int width, int height, int stride, -+ int min_trackness, int min_distance) { -+ std::vector<Feature> features; -+ // TODO(MatthiasF): Support targetting a feature count (binary search trackness) -+ int num_features; -+ xy* all = fast9_detect(data, width, height, -+ stride, min_trackness, &num_features); -+ if(num_features == 0) { -+ free(all); -+ return features; -+ } -+ int* scores = fast9_score(data, stride, all, num_features, min_trackness); -+ // TODO: merge with close feature suppression -+ xy* nonmax = nonmax_suppression(all, scores, num_features, &num_features); -+ free(all); -+ // Remove too close features -+ // TODO(MatthiasF): A resolution independent parameter would be better than distance -+ // e.g. a coefficient going from 0 (no minimal distance) to 1 (optimal circle packing) -+ // FIXME(MatthiasF): this method will not necessarily give all maximum markers -+ if(num_features) { -+ Feature *all_features = new Feature[num_features]; -+ -+ for(int i = 0; i < num_features; ++i) { -+ Feature a = { nonmax[i].x, nonmax[i].y, scores[i], 0 }; -+ all_features[i] = a; -+ } -+ -+ qsort((void *)all_features, num_features, sizeof(Feature), featurecmp); -+ -+ features.reserve(num_features); -+ -+ int prev_score = all_features[0].score; -+ for(int i = 0; i < num_features; ++i) { -+ bool ok = true; -+ Feature a = all_features[i]; -+ if(a.score>prev_score) -+ abort(); -+ prev_score = a.score; -+ -+ // compare each feature against filtered set -+ for(int j = 0; j < features.size(); j++) { -+ Feature& b = features[j]; -+ if ( (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) < min_distance*min_distance ) { -+ // already a nearby feature -+ ok = false; -+ break; -+ } -+ } -+ -+ if(ok) { -+ // add the new feature -+ features.push_back(a); -+ } -+ } -+ -+ delete [] all_features; -+ } -+ free(scores); -+ free(nonmax); -+ return features; -+} -+ - #ifdef __SSE2__ --#include <emmintrin.h> - static uint SAD(const ubyte* imageA, const ubyte* imageB, int strideA, int strideB) { - __m128i a = _mm_setzero_si128(); - for(int i = 0; i < 16; i++) { -@@ -52,7 +126,7 @@ static uint SAD(const ubyte* imageA, const ubyte* imageB, int strideA, int strid - } - #endif - --void Detect(ubyte* image, int stride, int width, int height, Feature* detected, int* count, int distance, ubyte* pattern) { -+void DetectMORAVEC(ubyte* image, int stride, int width, int height, Feature* detected, int* count, int distance, ubyte* pattern) { - unsigned short histogram[256]; - memset(histogram,0,sizeof(histogram)); - ubyte* scores = new ubyte[width*height]; -diff --git a/src/libmv/simple_pipeline/detect.h b/src/libmv/simple_pipeline/detect.h -index 23b239b..bbe7aed 100644 ---- a/src/libmv/simple_pipeline/detect.h -+++ b/src/libmv/simple_pipeline/detect.h -@@ -25,27 +25,52 @@ - #ifndef LIBMV_SIMPLE_PIPELINE_DETECT_H_ - #define LIBMV_SIMPLE_PIPELINE_DETECT_H_ - --#ifdef __cplusplus -+#include <vector> -+ - namespace libmv { --#endif - - typedef unsigned char ubyte; - - /*! -- \a Feature is the 2D location of a detected feature in an image. -+ A Feature is the 2D location of a detected feature in an image. - -- \a x, \a y is the position of the center in pixels (from image top-left). -- \a score is an estimate of how well the pattern will be tracked. -- \a size can be used as an initial size to track the pattern. -+ \a x, \a y is the position of the feature in pixels from the top left corner. -+ \a score is an estimate of how well the feature will be tracked. -+ \a size can be used as an initial pattern size to track the feature. - - \sa Detect - */ - struct Feature { -+ /// Position in pixels (from top-left corner) -+ /// \note libmv might eventually support subpixel precision. - float x, y; -+ /// Trackness of the feature - float score; -+ /// Size of the feature in pixels - float size; - }; -- //radius for non maximal suppression -+ -+/*! -+ Detect features in an image. -+ -+ You need to input a single channel 8-bit image using pointer to image \a data, -+ \a width, \a height and \a stride (i.e bytes per line). -+ -+ You can tweak the count of detected features using \a min_trackness, which is -+ the minimum score to add a feature, and \a min_distance which is the minimal -+ distance accepted between two featuress. -+ -+ \note You can binary search over \a min_trackness to get a given feature count. -+ -+ \note a way to get an uniform distribution of a given feature count is: -+ \a min_distance = \a width * \a height / desired_feature_count ^ 2 -+ -+ \return All detected feartures matching given parameters -+*/ -+std::vector<Feature> DetectFAST(const unsigned char* data, int width, int height, -+ int stride, int min_trackness = 128, -+ int min_distance = 120); -+ - /*! - Detect features in an image. - -@@ -63,10 +88,8 @@ struct Feature { - \note \a You can crop the image (to avoid detecting markers near the borders) without copying: - image += marginY*stride+marginX, width -= 2*marginX, height -= 2*marginY; - */ --void Detect(ubyte* image, int stride, int width, int height, Feature* detected, int* count, int distance /*=32*/, ubyte* pattern /*=0*/); -+void DetectMORAVEC(ubyte* image, int stride, int width, int height, Feature* detected, int* count, int distance /*=32*/, ubyte* pattern /*=0*/); - --#ifdef __cplusplus - } --#endif - - #endif diff --git a/extern/libmv/patches/fast.patch b/extern/libmv/patches/fast.patch deleted file mode 100644 index 8e0aeb7e721..00000000000 --- a/extern/libmv/patches/fast.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/src/third_party/fast/fast.h b/src/third_party/fast/fast.h -index 2b3825a..06fa90e 100644 ---- a/src/third_party/fast/fast.h -+++ b/src/third_party/fast/fast.h -@@ -1,6 +1,10 @@ - #ifndef FAST_H - #define FAST_H - -+#ifdef __cplusplus -+extern "C" { -+#endif -+ - typedef struct { int x, y; } xy; - typedef unsigned char byte; - -@@ -28,4 +32,8 @@ xy* fast12_detect_nonmax(const byte* im, int xsize, int ysize, int stride, int b - xy* nonmax_suppression(const xy* corners, const int* scores, int num_corners, int* ret_num_nonmax); - - -+#ifdef __cplusplus -+} -+#endif -+ - #endif diff --git a/extern/libmv/patches/function_derivative.patch b/extern/libmv/patches/function_derivative.patch deleted file mode 100644 index be7ccfc911a..00000000000 --- a/extern/libmv/patches/function_derivative.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/src/libmv/numeric/function_derivative.h b/src/libmv/numeric/function_derivative.h -index 0075d23..d7bc437 100644 ---- a/src/libmv/numeric/function_derivative.h -+++ b/src/libmv/numeric/function_derivative.h -@@ -24,6 +24,7 @@ - #include <cmath> - - #include "libmv/numeric/numeric.h" -+#include "libmv/logging/logging.h" - - namespace libmv { - -@@ -97,7 +98,7 @@ bool CheckJacobian(const Function &f, const typename Function::XMatrixType &x) { - - typename NumericJacobian<Function>::JMatrixType J_numeric = j_numeric(x); - typename NumericJacobian<Function>::JMatrixType J_analytic = j_analytic(x); -- //LG << J_numeric - J_analytic; -+ LG << J_numeric - J_analytic; - return true; - } - diff --git a/extern/libmv/patches/high_distortion_crash_fix.patch b/extern/libmv/patches/high_distortion_crash_fix.patch deleted file mode 100644 index 54ab66fa27c..00000000000 --- a/extern/libmv/patches/high_distortion_crash_fix.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/camera_intrinsics.cc b/src/libmv/simple_pipeline/camera_intrinsics.cc -index 4e88e1f..f9888ff 100644 ---- a/src/libmv/simple_pipeline/camera_intrinsics.cc -+++ b/src/libmv/simple_pipeline/camera_intrinsics.cc -@@ -160,9 +160,13 @@ void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { - if( iy < 0 ) { iy = 0, fy = 0; } - if( ix >= width-2 ) ix = width-2; - if( iy >= height-2 ) iy = height-2; -- //assert( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 ); -- Offset offset = { ix-x, iy-y, fx, fy }; -- grid[y*width+x] = offset; -+ if ( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 ) { -+ Offset offset = { ix-x, iy-y, fx, fy }; -+ grid[y*width+x] = offset; -+ } else { -+ Offset offset = { 0, 0, 0, 0 }; -+ grid[y*width+x] = offset; -+ } - } - } - } diff --git a/extern/libmv/patches/levenberg_marquardt.patch b/extern/libmv/patches/levenberg_marquardt.patch deleted file mode 100644 index 49ef82d73d2..00000000000 --- a/extern/libmv/patches/levenberg_marquardt.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff --git a/src/libmv/numeric/levenberg_marquardt.h b/src/libmv/numeric/levenberg_marquardt.h -index 6a54f66..4473b72 100644 ---- a/src/libmv/numeric/levenberg_marquardt.h -+++ b/src/libmv/numeric/levenberg_marquardt.h -@@ -33,6 +33,7 @@ - - #include "libmv/numeric/numeric.h" - #include "libmv/numeric/function_derivative.h" -+#include "libmv/logging/logging.h" - - namespace libmv { - -@@ -123,26 +124,40 @@ class LevenbergMarquardt { - Parameters dx, x_new; - int i; - for (i = 0; results.status == RUNNING && i < params.max_iterations; ++i) { -- if (dx.norm() <= params.relative_step_threshold * x.norm()) { -+ VLOG(1) << "iteration: " << i; -+ VLOG(1) << "||f(x)||: " << f_(x).norm(); -+ VLOG(1) << "max(g): " << g.array().abs().maxCoeff(); -+ VLOG(1) << "u: " << u; -+ VLOG(1) << "v: " << v; -+ -+ AMatrixType A_augmented = A + u*AMatrixType::Identity(J.cols(), J.cols()); -+ Solver solver(A_augmented); -+ dx = solver.solve(g); -+ bool solved = (A_augmented * dx).isApprox(g); -+ if (!solved) { -+ LOG(ERROR) << "Failed to solve"; -+ } -+ if (solved && dx.norm() <= params.relative_step_threshold * x.norm()) { - results.status = RELATIVE_STEP_SIZE_TOO_SMALL; - break; -- } -- x_new = x + dx; -- // Rho is the ratio of the actual reduction in error to the reduction -- // in error that would be obtained if the problem was linear. -- // See [1] for details. -- Scalar rho((error.squaredNorm() - f_(x_new).squaredNorm()) -- / dx.dot(u*dx + g)); -- if (rho > 0) { -- // Accept the Gauss-Newton step because the linear model fits well. -- x = x_new; -- results.status = Update(x, params, &J, &A, &error, &g); -- Scalar tmp = Scalar(2*rho-1); -- u = u*std::max(1/3., 1 - (tmp*tmp*tmp)); -- v = 2; -- continue; -- } -- -+ } -+ if (solved) { -+ x_new = x + dx; -+ // Rho is the ratio of the actual reduction in error to the reduction -+ // in error that would be obtained if the problem was linear. -+ // See [1] for details. -+ Scalar rho((error.squaredNorm() - f_(x_new).squaredNorm()) -+ / dx.dot(u*dx + g)); -+ if (rho > 0) { -+ // Accept the Gauss-Newton step because the linear model fits well. -+ x = x_new; -+ results.status = Update(x, params, &J, &A, &error, &g); -+ Scalar tmp = Scalar(2*rho-1); -+ u = u*std::max(1/3., 1 - (tmp*tmp*tmp)); -+ v = 2; -+ continue; -+ } -+ } - // Reject the update because either the normal equations failed to solve - // or the local linear model was not good (rho < 0). Instead, increase u - // to move closer to gradient descent. diff --git a/extern/libmv/patches/mingw.patch b/extern/libmv/patches/mingw.patch deleted file mode 100644 index 029e7d7f979..00000000000 --- a/extern/libmv/patches/mingw.patch +++ /dev/null @@ -1,171 +0,0 @@ -diff --git a/src/libmv/multiview/euclidean_resection.cc b/src/libmv/multiview/euclidean_resection.cc -index 6d918a1..9286251 100644 ---- a/src/libmv/multiview/euclidean_resection.cc -+++ b/src/libmv/multiview/euclidean_resection.cc -@@ -32,6 +32,8 @@ - namespace libmv { - namespace euclidean_resection { - -+typedef unsigned int uint; -+ - bool EuclideanResection(const Mat2X &x_camera, - const Mat3X &X_world, - Mat3 *R, Vec3 *t, -diff --git a/src/libmv/numeric/numeric.h b/src/libmv/numeric/numeric.h -index f39d126..21e0f06 100644 ---- a/src/libmv/numeric/numeric.h -+++ b/src/libmv/numeric/numeric.h -@@ -40,7 +40,7 @@ - } - #endif //_WIN32 || __APPLE__ - --#if _WIN32 -+#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) - inline long lround(double d) { - return (long)(d>0 ? d+0.5 : ceil(d-0.5)); - } -diff --git a/src/third_party/glog/src/config.h b/src/third_party/glog/src/config.h -index ed8d56e..06ed686 100644 ---- a/src/third_party/glog/src/config.h -+++ b/src/third_party/glog/src/config.h -@@ -4,6 +4,8 @@ - /* Namespace for Google classes */ - #ifdef __APPLE__ - #include "config_mac.h" -+#elif __MINGW32__ -+ #include "windows/config.h" - #elif __GNUC__ - #include "config_linux.h" - #elif _MSC_VER -diff --git a/src/third_party/glog/src/utilities.h b/src/third_party/glog/src/utilities.h -index ee54f94..c4ae256 100644 ---- a/src/third_party/glog/src/utilities.h -+++ b/src/third_party/glog/src/utilities.h -@@ -101,7 +101,9 @@ - // correctly when GetStackTrace() is called with max_depth == 0. - // Some code may do that. - --#if defined(HAVE_LIB_UNWIND) -+#if __MINGW32__ -+# undef STACKTRACE_H -+#elif defined(HAVE_LIB_UNWIND) - # define STACKTRACE_H "stacktrace_libunwind-inl.h" - #elif !defined(NO_FRAME_POINTER) - # if defined(__i386__) && __GNUC__ >= 2 -diff --git a/src/third_party/glog/src/windows/glog/logging.h b/src/third_party/glog/src/windows/glog/logging.h -index 7a6df74..4257375 100755 ---- a/src/third_party/glog/src/windows/glog/logging.h -+++ b/src/third_party/glog/src/windows/glog/logging.h -@@ -59,7 +59,7 @@ - - // Annoying stuff for windows -- makes sure clients can import these functions - #ifndef GOOGLE_GLOG_DLL_DECL --# if defined(_WIN32) && !defined(__CYGWIN__) -+# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) - # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) - # else - # define GOOGLE_GLOG_DLL_DECL -@@ -86,6 +86,15 @@ - #include <gflags/gflags.h> - #endif - -+#ifdef __MINGW32__ -+# include <stdlib.h> -+# include <unistd.h> -+# include <stdint.h> // the normal place uint16_t is defined -+# include <sys/types.h> // the normal place u_int16_t is defined -+# include <inttypes.h> // a third place for uint16_t or u_int16_t -+# define _exit(x) exit(x) -+#endif -+ - namespace google { - - #if 0 // the C99 format -@@ -98,11 +107,16 @@ typedef int32_t int32; - typedef u_int32_t uint32; - typedef int64_t int64; - typedef u_int64_t uint64; --#elif 1 // the windows (vc7) format -+#elif defined(_MSC_VER) - typedef __int32 int32; - typedef unsigned __int32 uint32; - typedef __int64 int64; - typedef unsigned __int64 uint64; -+#elif defined(__MINGW32__) -+typedef int32_t int32; -+typedef uint32_t uint32; -+typedef int64_t int64; -+typedef uint64_t uint64; - #else - #error Do not know how to define a 32-bit integer quantity on your system - #endif -diff --git a/src/third_party/glog/src/windows/port.h b/src/third_party/glog/src/windows/port.h -index d093bf5..d507812 100755 ---- a/src/third_party/glog/src/windows/port.h -+++ b/src/third_party/glog/src/windows/port.h -@@ -59,14 +59,16 @@ - * used by both C and C++ code, so we put all the C++ together. - */ - --/* 4244: otherwise we get problems when substracting two size_t's to an int -- * 4251: it's complaining about a private struct I've chosen not to dllexport -- * 4355: we use this in a constructor, but we do it safely -- * 4715: for some reason VC++ stopped realizing you can't return after abort() -- * 4800: we know we're casting ints/char*'s to bools, and we're ok with that -- * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() -- */ --#pragma warning(disable:4244 4251 4355 4715 4800 4996) -+#if _MSC_VER -+ /* 4244: otherwise we get problems when substracting two size_t's to an int -+ * 4251: it's complaining about a private struct I've chosen not to dllexport -+ * 4355: we use this in a constructor, but we do it safely -+ * 4715: for some reason VC++ stopped realizing you can't return after abort() -+ * 4800: we know we're casting ints/char*'s to bools, and we're ok with that -+ * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() -+ */ -+# pragma warning(disable:4244 4251 4355 4715 4800 4996) -+#endif - - /* file I/O */ - #define PATH_MAX 1024 -@@ -108,7 +110,9 @@ extern int snprintf(char *str, size_t size, - extern int safe_vsnprintf(char *str, size_t size, - const char *format, va_list ap); - #define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) -+#if !defined(__MINGW32__) - #define va_copy(dst, src) (dst) = (src) -+#endif - - /* Windows doesn't support specifying the number of buckets as a - * hash_map constructor arg, so we leave this blank. -@@ -130,13 +134,30 @@ enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock - #define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2)) - - inline struct tm* localtime_r(const time_t* timep, struct tm* result) { -+#if __MINGW32__ -+ struct tm *local_result; -+ local_result = localtime (timep); -+ -+ if (local_result == NULL || result == NULL) -+ return NULL; -+ -+ memcpy (result, local_result, sizeof (result)); -+ -+ return result; -+#else - localtime_s(result, timep); - return result; -+#endif - } - - inline char* strerror_r(int errnum, char* buf, size_t buflen) { -+#if __MINGW32__ -+ strncpy(buf, "Not implemented yet", buflen); -+ return buf; -+#else - strerror_s(buf, buflen, errnum); - return buf; -+#endif - } - - #ifndef __cplusplus diff --git a/extern/libmv/patches/msvc2010.patch b/extern/libmv/patches/msvc2010.patch deleted file mode 100644 index c090b070628..00000000000 --- a/extern/libmv/patches/msvc2010.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/tracks.cc b/src/libmv/simple_pipeline/tracks.cc -index 0e2a1b6..3fb8ddb 100644 ---- a/src/libmv/simple_pipeline/tracks.cc -+++ b/src/libmv/simple_pipeline/tracks.cc -@@ -20,6 +20,7 @@ - - #include <algorithm> - #include <vector> -+#include <iterator> - - #include "libmv/numeric/numeric.h" - #include "libmv/simple_pipeline/tracks.h" diff --git a/extern/libmv/patches/overscan.patch b/extern/libmv/patches/overscan.patch deleted file mode 100644 index c68f36804ec..00000000000 --- a/extern/libmv/patches/overscan.patch +++ /dev/null @@ -1,182 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/camera_intrinsics.cc b/src/libmv/simple_pipeline/camera_intrinsics.cc -index 110a16d..366129d 100644 ---- a/src/libmv/simple_pipeline/camera_intrinsics.cc -+++ b/src/libmv/simple_pipeline/camera_intrinsics.cc -@@ -31,6 +31,7 @@ struct Offset { - struct Grid { - struct Offset *offset; - int width, height; -+ double overscan; - }; - - static struct Grid *copyGrid(struct Grid *from) -@@ -42,6 +43,7 @@ static struct Grid *copyGrid(struct Grid *from) - - to->width = from->width; - to->height = from->height; -+ to->overscan = from->overscan; - - to->offset = new Offset[to->width*to->height]; - memcpy(to->offset, from->offset, sizeof(struct Offset)*to->width*to->height); -@@ -184,17 +186,19 @@ void CameraIntrinsics::InvertIntrinsics(double image_x, - - // TODO(MatthiasF): downsample lookup - template<typename WarpFunction> --void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height) { -- double aspx = (double)width / image_width_; -- double aspy = (double)height / image_height_; -+void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height, double overscan) { -+ double w = (double)width / (1 + overscan); -+ double h = (double)height / (1 + overscan); -+ double aspx = (double)w / image_width_; -+ double aspy = (double)h / image_height_; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { -- double src_x = x / aspx, src_y = y / aspy; -+ double src_x = (x - 0.5 * overscan * w) / aspx, src_y = (y - 0.5 * overscan * h) / aspy; - double warp_x, warp_y; - WarpFunction(this,src_x,src_y,&warp_x,&warp_y); -- warp_x = warp_x*aspx; -- warp_y = warp_y*aspy; -+ warp_x = warp_x*aspx + 0.5 * overscan * w; -+ warp_y = warp_y*aspy + 0.5 * overscan * h; - int ix = int(warp_x), iy = int(warp_y); - int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256); - if(fx == 256) { fx=0; ix++; } -@@ -264,10 +268,10 @@ struct InvertIntrinsicsFunction { - } - }; - --void CameraIntrinsics::CheckDistortLookupGrid(int width, int height) -+void CameraIntrinsics::CheckDistortLookupGrid(int width, int height, double overscan) - { - if(distort_) { -- if(distort_->width != width || distort_->height != height) { -+ if(distort_->width != width || distort_->height != height || distort_->overscan != overscan) { - delete [] distort_->offset; - distort_->offset = NULL; - } -@@ -278,17 +282,18 @@ void CameraIntrinsics::CheckDistortLookupGrid(int width, int height) - - if(!distort_->offset) { - distort_->offset = new Offset[width*height]; -- ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); -+ ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height,overscan); - } - - distort_->width = width; - distort_->height = height; -+ distort_->overscan = overscan; - } - --void CameraIntrinsics::CheckUndistortLookupGrid(int width, int height) -+void CameraIntrinsics::CheckUndistortLookupGrid(int width, int height, double overscan) - { - if(undistort_) { -- if(undistort_->width != width || undistort_->height != height) { -+ if(undistort_->width != width || undistort_->height != height || undistort_->overscan != overscan) { - delete [] undistort_->offset; - undistort_->offset = NULL; - } -@@ -299,15 +304,16 @@ void CameraIntrinsics::CheckUndistortLookupGrid(int width, int height) - - if(!undistort_->offset) { - undistort_->offset = new Offset[width*height]; -- ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); -+ ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height,overscan); - } - - undistort_->width = width; - undistort_->height = height; -+ undistort_->overscan = overscan; - } - --void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, int channels) { -- CheckDistortLookupGrid(width, height); -+void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, double overscan, int channels) { -+ CheckDistortLookupGrid(width, height, overscan); - if(channels==1) Warp<float,1>(distort_,src,dst,width,height); - else if(channels==2) Warp<float,2>(distort_,src,dst,width,height); - else if(channels==3) Warp<float,3>(distort_,src,dst,width,height); -@@ -315,8 +321,8 @@ void CameraIntrinsics::Distort(const float* src, float* dst, int width, int heig - //else assert("channels must be between 1 and 4"); - } - --void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { -- CheckDistortLookupGrid(width, height); -+void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int width, int height, double overscan, int channels) { -+ CheckDistortLookupGrid(width, height, overscan); - if(channels==1) Warp<unsigned char,1>(distort_,src,dst,width,height); - else if(channels==2) Warp<unsigned char,2>(distort_,src,dst,width,height); - else if(channels==3) Warp<unsigned char,3>(distort_,src,dst,width,height); -@@ -324,8 +330,8 @@ void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int - //else assert("channels must be between 1 and 4"); - } - --void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, int channels) { -- CheckUndistortLookupGrid(width, height); -+void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, double overscan, int channels) { -+ CheckUndistortLookupGrid(width, height, overscan); - if(channels==1) Warp<float,1>(undistort_,src,dst,width,height); - else if(channels==2) Warp<float,2>(undistort_,src,dst,width,height); - else if(channels==3) Warp<float,3>(undistort_,src,dst,width,height); -@@ -333,8 +339,8 @@ void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int he - //else assert("channels must be between 1 and 4"); - } - --void CameraIntrinsics::Undistort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { -- CheckUndistortLookupGrid(width, height); -+void CameraIntrinsics::Undistort(const unsigned char* src, unsigned char* dst, int width, int height, double overscan, int channels) { -+ CheckUndistortLookupGrid(width, height, overscan); - if(channels==1) Warp<unsigned char,1>(undistort_,src,dst,width,height); - else if(channels==2) Warp<unsigned char,2>(undistort_,src,dst,width,height); - else if(channels==3) Warp<unsigned char,3>(undistort_,src,dst,width,height); -diff --git a/src/libmv/simple_pipeline/camera_intrinsics.h b/src/libmv/simple_pipeline/camera_intrinsics.h -index f525571..f4bf903 100644 ---- a/src/libmv/simple_pipeline/camera_intrinsics.h -+++ b/src/libmv/simple_pipeline/camera_intrinsics.h -@@ -91,7 +91,7 @@ class CameraIntrinsics { - \note This is the reference implementation using floating point images. - */ - void Distort(const float* src, float* dst, -- int width, int height, int channels); -+ int width, int height, double overscan, int channels); - /*! - Distort an image using the current camera instrinsics - -@@ -101,7 +101,7 @@ class CameraIntrinsics { - \note This version is much faster. - */ - void Distort(const unsigned char* src, unsigned char* dst, -- int width, int height, int channels); -+ int width, int height, double overscan, int channels); - /*! - Undistort an image using the current camera instrinsics - -@@ -111,7 +111,7 @@ class CameraIntrinsics { - \note This is the reference implementation using floating point images. - */ - void Undistort(const float* src, float* dst, -- int width, int height, int channels); -+ int width, int height, double overscan, int channels); - /*! - Undistort an image using the current camera instrinsics - -@@ -121,12 +121,12 @@ class CameraIntrinsics { - \note This version is much faster. - */ - void Undistort(const unsigned char* src, unsigned char* dst, -- int width, int height, int channels); -+ int width, int height, double overscan, int channels); - - private: -- template<typename WarpFunction> void ComputeLookupGrid(struct Grid* grid, int width, int height); -- void CheckUndistortLookupGrid(int width, int height); -- void CheckDistortLookupGrid(int width, int height); -+ template<typename WarpFunction> void ComputeLookupGrid(struct Grid* grid, int width, int height, double overscan); -+ void CheckUndistortLookupGrid(int width, int height, double overscan); -+ void CheckDistortLookupGrid(int width, int height, double overscan); - void FreeLookupGrid(); - - // The traditional intrinsics matrix from x = K[R|t]X. diff --git a/extern/libmv/patches/scaled_distortion.patch b/extern/libmv/patches/scaled_distortion.patch deleted file mode 100644 index 2da832931d1..00000000000 --- a/extern/libmv/patches/scaled_distortion.patch +++ /dev/null @@ -1,261 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/camera_intrinsics.cc b/src/libmv/simple_pipeline/camera_intrinsics.cc -index f9888ff..110a16d 100644 ---- a/src/libmv/simple_pipeline/camera_intrinsics.cc -+++ b/src/libmv/simple_pipeline/camera_intrinsics.cc -@@ -23,7 +23,32 @@ - - namespace libmv { - --struct Offset { signed char ix,iy; unsigned char fx,fy; }; -+struct Offset { -+ signed char ix, iy; -+ unsigned char fx,fy; -+}; -+ -+struct Grid { -+ struct Offset *offset; -+ int width, height; -+}; -+ -+static struct Grid *copyGrid(struct Grid *from) -+{ -+ struct Grid *to = NULL; -+ -+ if (from) { -+ to = new Grid; -+ -+ to->width = from->width; -+ to->height = from->height; -+ -+ to->offset = new Offset[to->width*to->height]; -+ memcpy(to->offset, from->offset, sizeof(struct Offset)*to->width*to->height); -+ } -+ -+ return to; -+} - - CameraIntrinsics::CameraIntrinsics() - : K_(Mat3::Identity()), -@@ -37,9 +62,22 @@ CameraIntrinsics::CameraIntrinsics() - distort_(0), - undistort_(0) {} - -+CameraIntrinsics::CameraIntrinsics(const CameraIntrinsics &from) -+ : K_(from.K_), -+ image_width_(from.image_width_), -+ image_height_(from.image_height_), -+ k1_(from.k1_), -+ k2_(from.k2_), -+ k3_(from.k3_), -+ p1_(from.p1_), -+ p2_(from.p2_) -+{ -+ distort_ = copyGrid(from.distort_); -+ undistort_ = copyGrid(from.undistort_); -+} -+ - CameraIntrinsics::~CameraIntrinsics() { -- if(distort_) delete[] distort_; -- if(undistort_) delete[] undistort_; -+ FreeLookupGrid(); - } - - /// Set the entire calibration matrix at once. -@@ -146,11 +184,17 @@ void CameraIntrinsics::InvertIntrinsics(double image_x, - - // TODO(MatthiasF): downsample lookup - template<typename WarpFunction> --void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { -+void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height) { -+ double aspx = (double)width / image_width_; -+ double aspy = (double)height / image_height_; -+ - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { -+ double src_x = x / aspx, src_y = y / aspy; - double warp_x, warp_y; -- WarpFunction(this,x,y,&warp_x,&warp_y); -+ WarpFunction(this,src_x,src_y,&warp_x,&warp_y); -+ warp_x = warp_x*aspx; -+ warp_y = warp_y*aspy; - int ix = int(warp_x), iy = int(warp_y); - int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256); - if(fx == 256) { fx=0; ix++; } -@@ -162,10 +206,10 @@ void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { - if( iy >= height-2 ) iy = height-2; - if ( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 ) { - Offset offset = { ix-x, iy-y, fx, fy }; -- grid[y*width+x] = offset; -+ grid->offset[y*width+x] = offset; - } else { - Offset offset = { 0, 0, 0, 0 }; -- grid[y*width+x] = offset; -+ grid->offset[y*width+x] = offset; - } - } - } -@@ -173,11 +217,11 @@ void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { - - // TODO(MatthiasF): cubic B-Spline image sampling, bilinear lookup - template<typename T,int N> --static void Warp(const Offset* grid, const T* src, T* dst, -+static void Warp(const Grid* grid, const T* src, T* dst, - int width, int height) { - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { -- Offset offset = grid[y*width+x]; -+ Offset offset = grid->offset[y*width+x]; - const T* s = &src[((y+offset.iy)*width+(x+offset.ix))*N]; - for (int i = 0; i < N; i++) { - dst[(y*width+x)*N+i] = ((s[ i] * (256-offset.fx) + s[ N+i] * offset.fx) * (256-offset.fy) -@@ -188,8 +232,17 @@ static void Warp(const Offset* grid, const T* src, T* dst, - } - - void CameraIntrinsics::FreeLookupGrid() { -- if(distort_) delete distort_, distort_=0; -- if(undistort_) delete undistort_, undistort_=0; -+ if(distort_) { -+ delete distort_->offset; -+ delete distort_; -+ distort_ = NULL; -+ } -+ -+ if(undistort_) { -+ delete undistort_->offset; -+ delete undistort_; -+ undistort_ = NULL; -+ } - } - - // FIXME: C++ templates limitations makes thing complicated, but maybe there is a simpler method. -@@ -211,11 +264,50 @@ struct InvertIntrinsicsFunction { - } - }; - --void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, int channels) { -- if(!distort_) { -- distort_ = new Offset[width*height]; -- ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); -+void CameraIntrinsics::CheckDistortLookupGrid(int width, int height) -+{ -+ if(distort_) { -+ if(distort_->width != width || distort_->height != height) { -+ delete [] distort_->offset; -+ distort_->offset = NULL; -+ } -+ } else { -+ distort_ = new Grid; -+ distort_->offset = NULL; -+ } -+ -+ if(!distort_->offset) { -+ distort_->offset = new Offset[width*height]; -+ ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); - } -+ -+ distort_->width = width; -+ distort_->height = height; -+} -+ -+void CameraIntrinsics::CheckUndistortLookupGrid(int width, int height) -+{ -+ if(undistort_) { -+ if(undistort_->width != width || undistort_->height != height) { -+ delete [] undistort_->offset; -+ undistort_->offset = NULL; -+ } -+ } else { -+ undistort_ = new Grid; -+ undistort_->offset = NULL; -+ } -+ -+ if(!undistort_->offset) { -+ undistort_->offset = new Offset[width*height]; -+ ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); -+ } -+ -+ undistort_->width = width; -+ undistort_->height = height; -+} -+ -+void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, int channels) { -+ CheckDistortLookupGrid(width, height); - if(channels==1) Warp<float,1>(distort_,src,dst,width,height); - else if(channels==2) Warp<float,2>(distort_,src,dst,width,height); - else if(channels==3) Warp<float,3>(distort_,src,dst,width,height); -@@ -224,10 +316,7 @@ void CameraIntrinsics::Distort(const float* src, float* dst, int width, int heig - } - - void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { -- if(!distort_) { -- distort_ = new Offset[width*height]; -- ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); -- } -+ CheckDistortLookupGrid(width, height); - if(channels==1) Warp<unsigned char,1>(distort_,src,dst,width,height); - else if(channels==2) Warp<unsigned char,2>(distort_,src,dst,width,height); - else if(channels==3) Warp<unsigned char,3>(distort_,src,dst,width,height); -@@ -236,10 +325,7 @@ void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int - } - - void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, int channels) { -- if(!undistort_) { -- undistort_ = new Offset[width*height]; -- ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); -- } -+ CheckUndistortLookupGrid(width, height); - if(channels==1) Warp<float,1>(undistort_,src,dst,width,height); - else if(channels==2) Warp<float,2>(undistort_,src,dst,width,height); - else if(channels==3) Warp<float,3>(undistort_,src,dst,width,height); -@@ -248,10 +334,7 @@ void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int he - } - - void CameraIntrinsics::Undistort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { -- if(!undistort_) { -- undistort_ = new Offset[width*height]; -- ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); -- } -+ CheckUndistortLookupGrid(width, height); - if(channels==1) Warp<unsigned char,1>(undistort_,src,dst,width,height); - else if(channels==2) Warp<unsigned char,2>(undistort_,src,dst,width,height); - else if(channels==3) Warp<unsigned char,3>(undistort_,src,dst,width,height); -diff --git a/src/libmv/simple_pipeline/camera_intrinsics.h b/src/libmv/simple_pipeline/camera_intrinsics.h -index 29bc8a1..f525571 100644 ---- a/src/libmv/simple_pipeline/camera_intrinsics.h -+++ b/src/libmv/simple_pipeline/camera_intrinsics.h -@@ -26,11 +26,12 @@ typedef Eigen::Matrix<double, 3, 3> Mat3; - - namespace libmv { - --struct Offset; -+struct Grid; - - class CameraIntrinsics { - public: - CameraIntrinsics(); -+ CameraIntrinsics(const CameraIntrinsics &from); - ~CameraIntrinsics(); - - const Mat3 &K() const { return K_; } -@@ -123,7 +124,9 @@ class CameraIntrinsics { - int width, int height, int channels); - - private: -- template<typename WarpFunction> void ComputeLookupGrid(Offset* grid, int width, int height); -+ template<typename WarpFunction> void ComputeLookupGrid(struct Grid* grid, int width, int height); -+ void CheckUndistortLookupGrid(int width, int height); -+ void CheckDistortLookupGrid(int width, int height); - void FreeLookupGrid(); - - // The traditional intrinsics matrix from x = K[R|t]X. -@@ -140,8 +143,8 @@ class CameraIntrinsics { - // independent of image size. - double k1_, k2_, k3_, p1_, p2_; - -- Offset* distort_; -- Offset* undistort_; -+ struct Grid *distort_; -+ struct Grid *undistort_; - }; - - } // namespace libmv diff --git a/extern/libmv/patches/series b/extern/libmv/patches/series index 00a52c1cfaa..ca671122a61 100644 --- a/extern/libmv/patches/series +++ b/extern/libmv/patches/series @@ -1,13 +1,2 @@ v3d_verbosity.patch -snrptinf_fix.patch bundle_tweaks.patch -fast.patch -config_mac.patch -levenberg_marquardt.patch -function_derivative.patch -high_distortion_crash_fix.patch -mingw.patch -msvc2010.patch -scaled_distortion.patch -overscan.patch -detect.patch diff --git a/extern/libmv/patches/snrptinf_fix.patch b/extern/libmv/patches/snrptinf_fix.patch deleted file mode 100644 index e886a671de0..00000000000 --- a/extern/libmv/patches/snrptinf_fix.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/src/libmv/simple_pipeline/pipeline.cc b/src/libmv/simple_pipeline/pipeline.cc -index 652d70c..25cd2c2 100644 ---- a/src/libmv/simple_pipeline/pipeline.cc -+++ b/src/libmv/simple_pipeline/pipeline.cc -@@ -28,6 +28,10 @@ - #include "libmv/simple_pipeline/tracks.h" - #include "libmv/simple_pipeline/camera_intrinsics.h" - -+#ifdef _MSC_VER -+# define snprintf _snprintf -+#endif -+ - namespace libmv { - - void CompleteReconstruction(const Tracks &tracks, diff --git a/extern/libmv/patches/v3d_verbosity.patch b/extern/libmv/patches/v3d_verbosity.patch index a54f3dc44be..f5c6afbd0b5 100644 --- a/extern/libmv/patches/v3d_verbosity.patch +++ b/extern/libmv/patches/v3d_verbosity.patch @@ -1,12 +1,12 @@ diff --git a/src/libmv/simple_pipeline/bundle.cc b/src/libmv/simple_pipeline/bundle.cc -index 310660d..f819603 100644 +index fa0b6cc..d382cd5 100644 --- a/src/libmv/simple_pipeline/bundle.cc +++ b/src/libmv/simple_pipeline/bundle.cc -@@ -141,7 +141,6 @@ void Bundle(const Tracks &tracks, Reconstruction *reconstruction) { - v3d_distortion.p2 = 0; +@@ -194,7 +194,6 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks, + double v3d_inlier_threshold = 500000.0; // Finally, run the bundle adjustment. - V3D::optimizerVerbosenessLevel = 1; - double const inlierThreshold = 500000.0; - V3D::CommonInternalsMetricBundleOptimizer opt(V3D::FULL_BUNDLE_METRIC, - inlierThreshold, + V3D::CommonInternalsMetricBundleOptimizer opt(v3d_bundle_intrinsics, + v3d_inlier_threshold, + v3d_K, |