Skip to content

Commit

Permalink
Add various video reconstruction improvements.
Browse files Browse the repository at this point in the history
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
julien-michot committed Mar 18, 2011
1 parent be8faa9 commit a72b293
Show file tree
Hide file tree
Showing 34 changed files with 2,474 additions and 2,300 deletions.
23 changes: 0 additions & 23 deletions CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions README
Expand Up @@ -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
$ ...
Expand Down
2 changes: 1 addition & 1 deletion src/libmv/correspondence/ArrayMatcher_Kdtree_Flann.h
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libmv/correspondence/robust_tracker.cc
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/libmv/image/image_converter.h
Expand Up @@ -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...)
Expand Down
26 changes: 13 additions & 13 deletions src/libmv/multiview/bundle.cc
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions src/libmv/multiview/euclidean_resection.cc
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/libmv/multiview/robust_estimation.h
Expand Up @@ -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) {
Expand All @@ -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.";
}
Expand All @@ -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;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/libmv/reconstruction/CMakeLists.txt
Expand Up @@ -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)

0 comments on commit a72b293

Please sign in to comment.