forked from bartvdbraak/blender
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.
This commit is contained in:
parent
f75441014c
commit
f9e0ac4ced
50
extern/libmv/ChangeLog
vendored
50
extern/libmv/ChangeLog
vendored
@ -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
|
commit b9e467e7c077b58199c4110f6967b7c18d1e7bf7
|
||||||
Author: Sergey Sharybin <sergey.vfx@gmail.com>
|
Author: Sergey Sharybin <sergey.vfx@gmail.com>
|
||||||
Date: Tue Dec 31 20:34:39 2013 +0600
|
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.
|
Also moved own includes to the top of files.
|
||||||
|
|
||||||
Should be no functional changes :)
|
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.
|
|
||||||
|
@ -193,7 +193,8 @@ void CameraIntrinsics::ComputeLookupGrid(Grid* grid, int width, int height,
|
|||||||
double aspx = (double)w / image_width_;
|
double aspx = (double)w / image_width_;
|
||||||
double aspy = (double)h / image_height_;
|
double aspy = (double)h / image_height_;
|
||||||
#if defined(_OPENMP)
|
#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
|
#endif
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
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
|
// 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,
|
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
|
(void) threads; // Ignored if OpenMP is disabled
|
||||||
#if defined(_OPENMP)
|
#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
|
#endif
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
Offset offset = grid->offset[y*width+x];
|
Offset offset = grid->offset[y*width+x];
|
||||||
const T* s = &src[((y+offset.iy)*width+(x+offset.ix))*N];
|
const T* s = &src[((y + offset.iy) * width + (x + offset.ix)) * channels];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < channels; i++) {
|
||||||
dst[(y*width+x)*N+i] = ((s[ i] * (256-offset.fx) + s[ N+i] * offset.fx) * (256-offset.fy) // NOLINT
|
// TODO(sergey): Finally wrap this into ultiple lines nicely.
|
||||||
+(s[width*N+i] * (256-offset.fx) + s[width*N+N+i] * offset.fx) * offset.fy) / (256*256); // NOLINT
|
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,
|
int width, int height,
|
||||||
double overscan,
|
double overscan,
|
||||||
int channels) {
|
int channels) {
|
||||||
|
assert(channels >= 1);
|
||||||
|
assert(channels <= 4);
|
||||||
CheckDistortLookupGrid(width, height, overscan);
|
CheckDistortLookupGrid(width, height, overscan);
|
||||||
if (channels==1) Warp<float,1>(distort_, src, dst, width, height, threads_); // NOLINT
|
Warp<float>(distort_, src, dst, width, height, channels, threads_);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraIntrinsics::Distort(const unsigned char* src,
|
void CameraIntrinsics::Distort(const unsigned char* src,
|
||||||
@ -343,24 +346,20 @@ void CameraIntrinsics::Distort(const unsigned char* src,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
double overscan,
|
double overscan,
|
||||||
int channels) {
|
int channels) {
|
||||||
|
assert(channels >= 1);
|
||||||
|
assert(channels <= 4);
|
||||||
CheckDistortLookupGrid(width, height, overscan);
|
CheckDistortLookupGrid(width, height, overscan);
|
||||||
if (channels == 1) Warp<unsigned char,1>(distort_, src, dst, width, height, threads_); // NOLINT
|
Warp<unsigned char>(distort_, src, dst, width, height, channels, threads_);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraIntrinsics::Undistort(const float* src, float* dst,
|
void CameraIntrinsics::Undistort(const float* src, float* dst,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
double overscan,
|
double overscan,
|
||||||
int channels) {
|
int channels) {
|
||||||
|
assert(channels >= 1);
|
||||||
|
assert(channels <= 4);
|
||||||
CheckUndistortLookupGrid(width, height, overscan);
|
CheckUndistortLookupGrid(width, height, overscan);
|
||||||
if (channels == 1) Warp<float,1>(undistort_, src, dst, width, height, threads_); // NOLINT
|
Warp<float>(undistort_, src, dst, width, height, channels, threads_);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraIntrinsics::Undistort(const unsigned char* src,
|
void CameraIntrinsics::Undistort(const unsigned char* src,
|
||||||
@ -368,12 +367,10 @@ void CameraIntrinsics::Undistort(const unsigned char* src,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
double overscan,
|
double overscan,
|
||||||
int channels) {
|
int channels) {
|
||||||
|
assert(channels >= 1);
|
||||||
|
assert(channels <= 4);
|
||||||
CheckUndistortLookupGrid(width, height, overscan);
|
CheckUndistortLookupGrid(width, height, overscan);
|
||||||
if (channels == 1) Warp<unsigned char,1>(undistort_, src, dst, width, height, threads_); // NOLINT
|
Warp<unsigned char>(undistort_, src, dst, width, height, channels, threads_);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator <<(std::ostream &os,
|
std::ostream& operator <<(std::ostream &os,
|
||||||
|
3
extern/libmv/libmv/simple_pipeline/detect.cc
vendored
3
extern/libmv/libmv/simple_pipeline/detect.cc
vendored
@ -78,6 +78,7 @@ std::vector<Feature> DetectFAST(const unsigned char* data,
|
|||||||
features.reserve(num_features);
|
features.reserve(num_features);
|
||||||
|
|
||||||
int prev_score = all_features[0].score;
|
int prev_score = all_features[0].score;
|
||||||
|
const int min_distance_squared = min_distance * min_distance;
|
||||||
for (int i = 0; i < num_features; ++i) {
|
for (int i = 0; i < num_features; ++i) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
Feature a = all_features[i];
|
Feature a = all_features[i];
|
||||||
@ -88,7 +89,7 @@ std::vector<Feature> DetectFAST(const unsigned char* data,
|
|||||||
// compare each feature against filtered set
|
// compare each feature against filtered set
|
||||||
for (int j = 0; j < features.size(); j++) {
|
for (int j = 0; j < features.size(); j++) {
|
||||||
Feature& b = features[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
|
// already a nearby feature
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
|
@ -114,7 +114,7 @@ struct FundamentalSampsonCostFunction {
|
|||||||
typedef Vec9 XMatrixType;
|
typedef Vec9 XMatrixType;
|
||||||
|
|
||||||
// Assumes markers are ordered by track.
|
// Assumes markers are ordered by track.
|
||||||
FundamentalSampsonCostFunction(const vector<Marker> &markers)
|
explicit FundamentalSampsonCostFunction(const vector<Marker> &markers)
|
||||||
: markers(markers) {}
|
: markers(markers) {}
|
||||||
|
|
||||||
Vec operator()(const Vec9 &encoded_F) const {
|
Vec operator()(const Vec9 &encoded_F) const {
|
||||||
|
2
extern/libmv/libmv/simple_pipeline/tracks.h
vendored
2
extern/libmv/libmv/simple_pipeline/tracks.h
vendored
@ -68,7 +68,7 @@ class Tracks {
|
|||||||
Tracks(const Tracks &other);
|
Tracks(const Tracks &other);
|
||||||
|
|
||||||
/// Construct a new tracks object using the given markers to start.
|
/// 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
|
Inserts a marker into the set. If there is already a marker for the given
|
||||||
|
Loading…
Reference in New Issue
Block a user