Permalink
Browse files

Add various video reconstruction improvements.

More precisely, this commit concerns mainly the reconstruction lib. It
- adds 2 new functions in mapping for calibrated/uncalibrated traingulation
- improves the keyframe selection using a method based on the number of shared tracks
- adds two functions for processing keyframes and non keyframes in the euclidean reconstruction file
and also
- updates nview and some tools
- the 'end of lines' of several files are updated (to UNIX). 
- the warning occuring in the RGB image conversion to gray function is solved.
- updates License and Readme 
- removes CMakeLists.txt, we should use the one in src/.
  • Loading branch information...
1 parent be8faa9 commit a72b293969c0f15ae21fb9702897a0ee7a72432d @JulienMichot JulienMichot committed Mar 18, 2011
Showing with 2,474 additions and 2,300 deletions.
  1. +0 −23 CMakeLists.txt
  2. +1 −1 LICENSE
  3. +3 −3 README
  4. +1 −1 src/libmv/correspondence/ArrayMatcher_Kdtree_Flann.h
  5. +2 −2 src/libmv/correspondence/robust_tracker.cc
  6. +1 −1 src/libmv/image/image_converter.h
  7. +13 −13 src/libmv/multiview/bundle.cc
  8. +8 −8 src/libmv/multiview/euclidean_resection.cc
  9. +4 −4 src/libmv/multiview/robust_estimation.h
  10. +5 −4 src/libmv/reconstruction/CMakeLists.txt
  11. +424 −182 src/libmv/reconstruction/euclidean_reconstruction.cc
  12. +94 −32 src/libmv/reconstruction/euclidean_reconstruction.h
  13. +181 −0 src/libmv/reconstruction/euclidean_reconstruction_test.cc
  14. +148 −148 src/libmv/reconstruction/export_blender.cc
  15. +80 −80 src/libmv/reconstruction/export_ply.cc
  16. +0 −240 src/libmv/reconstruction/image_order_selection.cc
  17. +0 −43 src/libmv/reconstruction/image_order_selection.h
  18. +186 −0 src/libmv/reconstruction/image_selection.cc
  19. +38 −0 src/libmv/reconstruction/image_selection.h
  20. +131 −0 src/libmv/reconstruction/keyframe_selection.cc
  21. +43 −0 src/libmv/reconstruction/keyframe_selection.h
  22. +363 −195 src/libmv/reconstruction/mapping.cc
  23. +45 −9 src/libmv/reconstruction/mapping.h
  24. +213 −213 src/libmv/reconstruction/optimization.cc
  25. +213 −213 src/libmv/reconstruction/projective_reconstruction.cc
  26. +25 −240 src/libmv/reconstruction/reconstruction.cc
  27. +0 −17 src/libmv/reconstruction/reconstruction.h
  28. +0 −266 src/libmv/reconstruction/reconstruction_test.cc
  29. +99 −99 src/libmv/reconstruction/tools.cc
  30. +5 −5 src/libmv/reconstruction/tools.h
  31. +2 −3 src/tools/reconstruct_video.cc
  32. +36 −83 src/tools/tracker.cc
  33. +100 −163 src/ui/nvr/nview.cpp
  34. +10 −9 src/ui/nvr/nview.h
View
@@ -1,23 +0,0 @@
-# Copyright (c) 2010 libmv authors.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
-
-ADD_SUBDIRECTORY(src)
View
@@ -1,4 +1,4 @@
-Copyright (c) 2007, 2008 libmv authors.
+Copyright (c) 2007-2011 libmv authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
View
6 README
@@ -52,9 +52,9 @@ Instead do this:
$ ls
AUTHORS contrib doc LICENSE Makefile README src
- $ mkdir alternate_build
- $ cd alternate_build
- $ cmake ../ # Your options here
+ $ mkdir build
+ $ cd build
+ $ cmake ../src # Your options here
$ make
$ make test
$ ...
@@ -54,7 +54,7 @@ class ArrayMatcher_Kdtree_Flann : public ArrayMatcher<Scalar>
bool build( const Scalar * dataset, int nbRows, int dimension) {
_p.log_destination = NULL;
- _p.log_level = LOG_INFO;
+ _p.log_level = LOG_WARN;//LOG_INFO;
// Force KDTREE matching
_p.algorithm = KDTREE;
@@ -142,8 +142,8 @@ bool RobustTracker::Track(const Image &image,
rms_threshold_inlier_,
&F,
&inliers);
- LOG(INFO) << "#inliers = "<< inliers.size() << std::endl;
- LOG(INFO) << "#outliers = "<< tracks.size()-inliers.size() << std::endl;
+ VLOG(2) << "#inliers = "<< inliers.size() << std::endl;
+ VLOG(2) << "#outliers = "<< tracks.size()-inliers.size() << std::endl;
// We remove correspondences that are not inliers
size_t max_num_track = 1 +
std::max(new_features_graph->matches_.GetMaxTrackID(),
@@ -31,7 +31,7 @@ template<typename T>
// var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722
inline T RGB2GRAY(const T r,const T g, const T b)
{
- return r * 0.2126 + g * 0.7152 + b * 0.0722;
+ return static_cast<T>(r * 0.2126 + g * 0.7152 + b * 0.0722);
}
/*
// Specialization for the uchar type. (that do not want to work...)
@@ -49,7 +49,7 @@ showErrorStatistics(double const f0,
Vector2d p = cams[i].projectPoint(distortion, Xs[j]);
meanReprojectionError += Square(norm_L2(f0 * (p - measurements[k])));
}
- VLOG(2) << "mean reprojection error (in pixels): "
+ VLOG(3) << "mean reprojection error (in pixels): "
<< sqrt(meanReprojectionError/K) << std::endl;
return sqrt(meanReprojectionError/K);
}
@@ -108,7 +108,7 @@ void EuclideanBAFull(const vector<Mat2X> &x,
distortion.p2 = 0;
double const f0 = KMat[0][0];
- VLOG(2) << "intrinsic before bundle = "; displayMatrix(KMat);
+ VLOG(3) << "intrinsic before bundle = "; displayMatrix(KMat);
Matrix3x3d Knorm = KMat;
// Normalize the intrinsic to have unit focal length.
scaleMatrixIP(1.0/f0, Knorm);
@@ -170,7 +170,7 @@ void EuclideanBAFull(const vector<Mat2X> &x,
double const inlierThreshold = 2.0 / f0;
Matrix3x3d K0 = cams[0].getIntrinsic();
- VLOG(2) << "K0 = "; displayMatrix(K0);
+ VLOG(3) << "K0 = "; displayMatrix(K0);
CommonInternalsMetricBundleOptimizer opt(mode, inlierThreshold,
K0, distortion,
@@ -179,17 +179,17 @@ void EuclideanBAFull(const vector<Mat2X> &x,
correspondingPoint);
opt.maxIterations = 50;
opt.minimize();
- VLOG(2) << "optimizer status = " << opt.status << endl;
- VLOG(2) << "refined K = "; displayMatrix(K0);
- VLOG(2) << "distortion = " << distortion.k1 << " " << distortion.k2 << " "
+ VLOG(3) << "optimizer status = " << opt.status << endl;
+ VLOG(3) << "refined K = "; displayMatrix(K0);
+ VLOG(3) << "distortion = " << distortion.k1 << " " << distortion.k2 << " "
<< distortion.p1 << " " << distortion.p2 << endl;
for (int i = 0; i < num_camsN; ++i) cams[i].setIntrinsic(K0);
Matrix3x3d Knew = K0;
scaleMatrixIP(f0, Knew);
Knew[2][2] = 1.0;
- VLOG(2) << "Knew = "; displayMatrix(Knew);
+ VLOG(3) << "Knew = "; displayMatrix(Knew);
showErrorStatistics(f0, distortion, cams, Xs, measurements, correspondingView,
correspondingPoint);
@@ -268,7 +268,7 @@ double EuclideanBA(const vector<Mat2X> &x,
distortion.p2 = 0;
double f0 = KMat[0][0];
- VLOG(2) << "intrinsic before bundle = "; displayMatrix(KMat);
+ VLOG(3) << "intrinsic before bundle = "; displayMatrix(KMat);
Matrix3x3d Knorm = KMat;
// Normalize the intrinsic to have unit focal length.
scaleMatrixIP(1.0/f0, Knorm);
@@ -344,7 +344,7 @@ double EuclideanBA(const vector<Mat2X> &x,
double const inlierThreshold = 2.0 / f0;
Matrix3x3d K0 = cams[0].getIntrinsic();
- VLOG(2) << "K0 = "; displayMatrix(K0);
+ VLOG(3) << "K0 = "; displayMatrix(K0);
CommonInternalsMetricBundleOptimizer opt(mode, inlierThreshold,
K0, distortion,
@@ -353,17 +353,17 @@ double EuclideanBA(const vector<Mat2X> &x,
correspondingPoint);
opt.maxIterations = 50;
opt.minimize();
- VLOG(2) << "optimizer status = " << opt.status << std::endl;
- VLOG(2) << "refined K = "; displayMatrix(K0);
- VLOG(2) << "distortion = " << distortion.k1 << " " << distortion.k2 << " "
+ VLOG(3) << "optimizer status = " << opt.status << std::endl;
+ VLOG(3) << "refined K = "; displayMatrix(K0);
+ VLOG(3) << "distortion = " << distortion.k1 << " " << distortion.k2 << " "
<< distortion.p1 << " " << distortion.p2 << std::endl;
for (int i = 0; i < num_camsN; ++i) cams[i].setIntrinsic(K0);
Matrix3x3d Knew = K0;
scaleMatrixIP(f0, Knew);
Knew[2][2] = 1.0;
- VLOG(2) << "Knew = "; displayMatrix(Knew);
+ VLOG(3) << "Knew = "; displayMatrix(Knew);
double rms = showErrorStatistics(f0, distortion, cams,
Xs, measurements,correspondingView,
@@ -442,14 +442,14 @@ void EuclideanResectionEPnP(const Mat2X &x_camera, const Mat3X &X_world,
ui = x_camera(0, c);
vi = x_camera(1, c);
M.block(2*c, 0, 2, 12) << a0, 0,
- a0*(-ui), a1, 0,
- a1*(-ui), a2, 0,
- a2*(-ui), a3, 0,
- a3*(-ui), 0,
- a0, a0*(-vi), 0,
- a1, a1*(-vi), 0,
- a2, a2*(-vi), 0,
- a3, a3*(-vi);
+ a0*(-ui), a1, 0,
+ a1*(-ui), a2, 0,
+ a2*(-ui), a3, 0,
+ a3*(-ui), 0,
+ a0, a0*(-vi), 0,
+ a1, a1*(-vi), 0,
+ a2, a2*(-vi), 0,
+ a3, a3*(-vi);
}
Eigen::SVD<Mat> MtMsvd = (M.transpose()*M).svd();
@@ -112,13 +112,13 @@ typename Kernel::Model Estimate(const Kernel &kernel,
vector<typename Kernel::Model> models;
kernel.Fit(sample, &models);
- VLOG(2) << "Fitted subset; found " << models.size() << " model(s).";
+ VLOG(4) << "Fitted subset; found " << models.size() << " model(s).";
// Compute costs for each fit.
for (int i = 0; i < models.size(); ++i) {
vector<int> inliers;
double cost = scorer.Score(kernel, models[i], all_samples, &inliers);
- VLOG(3) << "Fit cost: " << cost
+ VLOG(5) << "Fit cost: " << cost
<< ", number of inliers: " << inliers.size();
if (cost < best_cost) {
@@ -129,7 +129,7 @@ typename Kernel::Model Estimate(const Kernel &kernel,
if (best_inliers) {
best_inliers->swap(inliers);
}
- VLOG(2) << "New best cost: " << best_cost << " with "
+ VLOG(4) << "New best cost: " << best_cost << " with "
<< best_num_inliers << " inlying of "
<< total_samples << " total samples.";
}
@@ -138,7 +138,7 @@ typename Kernel::Model Estimate(const Kernel &kernel,
outliers_probability,
best_inlier_ratio);
- VLOG(2) << "Max iterations needed given best inlier ratio: "
+ VLOG(5) << "Max iterations needed given best inlier ratio: "
<< max_iterations << "; best inlier ratio: " << best_inlier_ratio;
}
}
@@ -2,19 +2,20 @@ ADD_LIBRARY(reconstruction
euclidean_reconstruction.cc
export_blender.cc
export_ply.cc
- image_order_selection.cc
+ image_selection.cc
+ keyframe_selection.cc
mapping.cc
optimization.cc
projective_reconstruction.cc
reconstruction.cc
tools.cc
)
-TARGET_LINK_LIBRARIES(reconstruction camera multiview numeric V3D colamd ldl)
+TARGET_LINK_LIBRARIES(reconstruction camera multiview numeric V3D colamd ldl glog)
LIBMV_INSTALL_LIB(reconstruction)
MACRO (RECONSTRUCTION_TEST NAME)
- LIBMV_TEST(${NAME} "reconstruction;multiview_test_data;camera;correspondence;multiview;numeric")
+ LIBMV_TEST(${NAME} "reconstruction;multiview_test_data;camera;correspondence;multiview;numeric;glog")
ENDMACRO (RECONSTRUCTION_TEST)
-RECONSTRUCTION_TEST(reconstruction)
+RECONSTRUCTION_TEST(euclidean_reconstruction)
Oops, something went wrong.

0 comments on commit a72b293

Please sign in to comment.