Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-01-02 13:14:47 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-02 13:24:46 +0400
commitf9e0ac4ced7ff1d247019f529317eb04f01c6601 (patch)
treef3ece2be06e96cdcda1db2fd407d9bb1f53d5ed6 /extern
parentf75441014cc90afab46ec2d9872e1261263a43b5 (diff)
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.
Diffstat (limited to 'extern')
-rw-r--r--extern/libmv/ChangeLog50
-rw-r--r--extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc53
-rw-r--r--extern/libmv/libmv/simple_pipeline/detect.cc3
-rw-r--r--extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc2
-rw-r--r--extern/libmv/libmv/simple_pipeline/tracks.h2
5 files changed, 56 insertions, 54 deletions
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 <sergey.vfx@gmail.com>
+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 <sergey.vfx@gmail.com>
+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 <sergey.vfx@gmail.com>
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 <sergey.vfx@gmail.com>
-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 <sergey.vfx@gmail.com>
-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<typename T, int N>
+template<typename T>
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<float,1>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels==2) Warp<float,2>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels==3) Warp<float,3>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels==4) Warp<float,4>(distort_, src, dst, width, height, threads_); // NOLINT
- //else assert("channels must be between 1 and 4");
+ Warp<float>(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<unsigned char,1>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 2) Warp<unsigned char,2>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 3) Warp<unsigned char,3>(distort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 4) Warp<unsigned char,4>(distort_, src, dst, width, height, threads_); // NOLINT
- //else assert("channels must be between 1 and 4");
+ Warp<unsigned char>(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<float,1>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 2) Warp<float,2>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 3) Warp<float,3>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 4) Warp<float,4>(undistort_, src, dst, width, height, threads_); // NOLINT
- //else assert("channels must be between 1 and 4");
+ Warp<float>(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<unsigned char,1>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 2) Warp<unsigned char,2>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 3) Warp<unsigned char,3>(undistort_, src, dst, width, height, threads_); // NOLINT
- else if (channels == 4) Warp<unsigned char,4>(undistort_, src, dst, width, height, threads_); // NOLINT
- //else assert("channels must be between 1 and 4");
+ Warp<unsigned char>(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<Feature> 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<Feature> 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<Marker> &markers)
+ explicit FundamentalSampsonCostFunction(const vector<Marker> &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<Marker> &markers);
+ explicit Tracks(const vector<Marker> &markers);
/*!
Inserts a marker into the set. If there is already a marker for the given