diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog index c4abfae462c..66688c347aa 100644 --- a/extern/libmv/ChangeLog +++ b/extern/libmv/ChangeLog @@ -1,3 +1,30 @@ +commit b0df3e291e6c85f791658be04334efafc41989f5 +Author: Sergey Sharybin +Date: Thu Jan 2 15:12:18 2014 +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. + +commit b68de6acd20f3ffab92e0cd450198a700cd109ab +Author: Sergey Sharybin +Date: Thu Jan 2 15:04:05 2014 +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. + commit b9e467e7c077b58199c4110f6967b7c18d1e7bf7 Author: Sergey Sharybin Date: Tue Dec 31 20:34:39 2013 +0600 @@ -657,26 +684,3 @@ Date: Thu Apr 4 01:20:18 2013 +0600 Also moved own includes to the top of files. Should be no functional changes :) - -commit ecbbf9ebacc1cc98a2ecfe5ff90f7d5c66b8a605 -Author: Sergey Sharybin -Date: Fri Mar 29 00:20:29 2013 +0600 - - Fix for TransformTracks in uncalibrated pipeline - - Transformation matrix was completely ignored by - TransformTracks() and final marker coordinate - exactly matched it's source coordinates. - - Seems to be just a typo in vector usage: need to - use "b" (which is transformed one) instead of "a" - when converting projective coordinate to 2D space. - -commit 319657d68d6533177bfa4811985fd0d9d161c725 -Author: Sergey Sharybin -Date: Fri Mar 29 00:19:11 2013 +0600 - - Revert part of e2eb58c4230f94ef0c72fb4005e5434088d52e80 - - That commit included one change which shall have been - go as separate commit with more detailed description. diff --git a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc index aee2ecb5882..ddbbec58def 100644 --- a/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc +++ b/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc @@ -193,7 +193,8 @@ void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height, double aspx = (double)w / image_width_; double aspy = (double)h / image_height_; #if defined(_OPENMP) - #pragma omp parallel for schedule(dynamic) num_threads(threads_) if (threads_ > 1 && height > 100) +# pragma omp parallel for schedule(dynamic) num_threads(threads_) \ + if (threads_ > 1 && height > 100) #endif for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { @@ -221,20 +222,24 @@ void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height, } // TODO(MatthiasF): cubic B-Spline image sampling, bilinear lookup -template +template static void Warp(const Grid* grid, const T* src, T* dst, - int width, int height, int threads) { + const int width, const int height, const int channels, + const int threads) { (void) threads; // Ignored if OpenMP is disabled #if defined(_OPENMP) - #pragma omp parallel for schedule(dynamic) num_threads(threads) if (threads > 1 && height > 100) +# pragma omp parallel for schedule(dynamic) num_threads(threads) \ + if (threads > 1 && height > 100) #endif for (int y = 0; y < height; y++) { for (int x = 0; x < 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) // NOLINT - +(s[width*N+i] * (256-offset.fx) + s[width*N+N+i] * offset.fx) * offset.fy) / (256*256); // NOLINT + const T* s = &src[((y + offset.iy) * width + (x + offset.ix)) * channels]; + for (int i = 0; i < channels; i++) { + // TODO(sergey): Finally wrap this into ultiple lines nicely. + dst[(y*width+x)*channels+i] = + ((s[ i] * (256-offset.fx) + s[ channels+i] * offset.fx) * (256-offset.fy) // NOLINT + +(s[width*channels+i] * (256-offset.fx) + s[width*channels+channels+i] * offset.fx) * offset.fy) / (256*256); // NOLINT } } } @@ -330,12 +335,10 @@ void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, double overscan, int channels) { + assert(channels >= 1); + assert(channels <= 4); CheckDistortLookupGrid(width, height, overscan); - if (channels==1) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels==2) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels==3) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels==4) Warp(distort_, src, dst, width, height, threads_); // NOLINT - //else assert("channels must be between 1 and 4"); + Warp(distort_, src, dst, width, height, channels, threads_); } void CameraIntrinsics::Distort(const unsigned char* src, @@ -343,24 +346,20 @@ void CameraIntrinsics::Distort(const unsigned char* src, int width, int height, double overscan, int channels) { + assert(channels >= 1); + assert(channels <= 4); CheckDistortLookupGrid(width, height, overscan); - if (channels == 1) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 2) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 3) Warp(distort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 4) Warp(distort_, src, dst, width, height, threads_); // NOLINT - //else assert("channels must be between 1 and 4"); + Warp(distort_, src, dst, width, height, channels, threads_); } void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, double overscan, int channels) { + assert(channels >= 1); + assert(channels <= 4); CheckUndistortLookupGrid(width, height, overscan); - if (channels == 1) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 2) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 3) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 4) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - //else assert("channels must be between 1 and 4"); + Warp(undistort_, src, dst, width, height, channels, threads_); } void CameraIntrinsics::Undistort(const unsigned char* src, @@ -368,12 +367,10 @@ void CameraIntrinsics::Undistort(const unsigned char* src, int width, int height, double overscan, int channels) { + assert(channels >= 1); + assert(channels <= 4); CheckUndistortLookupGrid(width, height, overscan); - if (channels == 1) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 2) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 3) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - else if (channels == 4) Warp(undistort_, src, dst, width, height, threads_); // NOLINT - //else assert("channels must be between 1 and 4"); + Warp(undistort_, src, dst, width, height, channels, threads_); } std::ostream& operator <<(std::ostream &os, diff --git a/extern/libmv/libmv/simple_pipeline/detect.cc b/extern/libmv/libmv/simple_pipeline/detect.cc index 627fa541974..27639e958a0 100644 --- a/extern/libmv/libmv/simple_pipeline/detect.cc +++ b/extern/libmv/libmv/simple_pipeline/detect.cc @@ -78,6 +78,7 @@ std::vector DetectFAST(const unsigned char* data, features.reserve(num_features); int prev_score = all_features[0].score; + const int min_distance_squared = min_distance * min_distance; for (int i = 0; i < num_features; ++i) { bool ok = true; Feature a = all_features[i]; @@ -88,7 +89,7 @@ std::vector DetectFAST(const unsigned char* data, // 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 ) { + if ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) < min_distance_squared) { // already a nearby feature ok = false; break; diff --git a/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc b/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc index 14030da6315..7a086c375d5 100644 --- a/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc +++ b/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc @@ -114,7 +114,7 @@ struct FundamentalSampsonCostFunction { typedef Vec9 XMatrixType; // Assumes markers are ordered by track. - FundamentalSampsonCostFunction(const vector &markers) + explicit FundamentalSampsonCostFunction(const vector &markers) : markers(markers) {} Vec operator()(const Vec9 &encoded_F) const { diff --git a/extern/libmv/libmv/simple_pipeline/tracks.h b/extern/libmv/libmv/simple_pipeline/tracks.h index e2f8cf6b459..a54a43659b7 100644 --- a/extern/libmv/libmv/simple_pipeline/tracks.h +++ b/extern/libmv/libmv/simple_pipeline/tracks.h @@ -68,7 +68,7 @@ class Tracks { Tracks(const Tracks &other); /// Construct a new tracks object using the given markers to start. - Tracks(const vector &markers); + explicit Tracks(const vector &markers); /*! Inserts a marker into the set. If there is already a marker for the given