Skip to content

Commit

Permalink
adding print statement to output global mean reprojection error after…
Browse files Browse the repository at this point in the history
… each round of bundle adjustment
  • Loading branch information
snavely committed Jun 8, 2014
1 parent 92d699f commit f645284
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,13 @@ double BundlerApp::RunSFM_SBA(int num_pts, int num_cameras, int start_camera,
printf("[RunSFM] run_sfm took %0.3fs\n",
(double) (end - start) / (double) CLOCKS_PER_SEC);

/* Check for outliers */
/* Compute statistics and check for outliers */

start = clock();

double global_reprojection_error = 0;
int global_num_observations = 0;

std::vector<int> outliers;
std::vector<double> reproj_errors;

Expand Down Expand Up @@ -784,7 +787,8 @@ double BundlerApp::RunSFM_SBA(int num_pts, int num_cameras, int start_camera,
iround(0.5 * num_pts_proj), dists),
thresh);

// printf("Outlier threshold is %0.3f\n", thresh);
global_reprojection_error += sum;
global_num_observations += num_pts_proj;

pt_count = 0;
for (int j = 0; j < num_keys; j++) {
Expand Down Expand Up @@ -846,6 +850,11 @@ double BundlerApp::RunSFM_SBA(int num_pts, int num_cameras, int start_camera,
delete [] dists;
}

printf("[RunSFM] Global mean reprojection error: %0.3e "
"(%d observations)\n",
global_reprojection_error / global_num_observations,
global_num_observations);

/* Remove outlying points */
if (remove_outliers) {
for (int i = 0; i < (int) outliers.size(); i++) {
Expand Down
11 changes: 11 additions & 0 deletions src/BundleCeres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ double BundlerApp::RunSFM_Ceres(int num_pts, int num_cameras,

start = clock();

double global_reprojection_error = 0;
int global_num_observations = 0;

std::vector<int> outliers;
std::vector<int> outlier_views;
std::vector<double> reproj_errors;
Expand Down Expand Up @@ -649,6 +652,9 @@ double BundlerApp::RunSFM_Ceres(int num_pts, int num_cameras,
iround(0.5 * num_pts_proj), dists),
thresh);

global_reprojection_error += sum;
global_num_observations += num_pts_proj;

pt_count = 0;
for (int j = 0; j < num_keys; j++) {
int pt_idx = GetKey(added_order[i],j).m_extra;
Expand Down Expand Up @@ -715,6 +721,11 @@ double BundlerApp::RunSFM_Ceres(int num_pts, int num_cameras,
delete [] dists;
}

printf("[RunSFM] Global mean reprojection error: %0.3e "
"(%d observations)\n",
global_reprojection_error / global_num_observations,
global_num_observations);

/* Remove outlying points */
if ((!final_bundle || round > 0) && remove_outliers) {
int num_dead = 0;
Expand Down

0 comments on commit f645284

Please sign in to comment.