diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-25 19:43:38 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-25 19:43:38 +0400 |
commit | 29b89cbc7b1af0a7c3943423496c6ea6a2730dac (patch) | |
tree | 834a7118b4ebc00e49417f6486e03f071317f7e2 /extern | |
parent | aff993db555dce2d45462856320ab640b7dab429 (diff) |
Camera tracking: cleaned progress reporting stuff and made a bit more verbose
Diffstat (limited to 'extern')
-rw-r--r-- | extern/libmv/libmv-capi.cpp | 7 | ||||
-rw-r--r-- | extern/libmv/libmv/simple_pipeline/pipeline.cc | 40 |
2 files changed, 39 insertions, 8 deletions
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index 6be8d838d37..2472b08da19 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -385,7 +385,8 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra normalized_tracks.MarkersForTracksInBothImages(keyframe1, keyframe2); LG << "number of markers for init: " << keyframe_markers.size(); - progress_update_callback(callback_customdata, 0, "Initial reconstruction"); + if(progress_update_callback) + progress_update_callback(callback_customdata, 0, "Initial reconstruction"); libmv::EuclideanReconstructTwoFrames(keyframe_markers, reconstruction); libmv::EuclideanBundle(normalized_tracks, reconstruction); @@ -408,11 +409,11 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra libmv_refine_flags |= libmv::BUNDLE_RADIAL_K2; } - progress_update_callback(callback_customdata, 0, "Refining solution"); + progress_update_callback(callback_customdata, 1.0, "Refining solution"); libmv::EuclideanBundleCommonIntrinsics(*(libmv::Tracks *)tracks, libmv_refine_flags, reconstruction, intrinsics); } - progress_update_callback(callback_customdata, 0, "Finishing solution"); + progress_update_callback(callback_customdata, 1.0, "Finishing solution"); libmv_reconstruction->tracks = *(libmv::Tracks *)tracks; libmv_reconstruction->error = libmv::EuclideanReprojectionError(*(libmv::Tracks *)tracks, *reconstruction, *intrinsics); diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc index 93f41d237e8..654127ac51d 100644 --- a/extern/libmv/libmv/simple_pipeline/pipeline.cc +++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc @@ -118,6 +118,21 @@ struct ProjectivePipelineRoutines { } // namespace +static void CompleteReconstructionLogProress(progress_update_callback update_callback, + void *update_customdata, + double progress, + const char *step) +{ + if(update_callback) { + char message[256]; + if(step) + snprintf(message, sizeof(message), "Completing solution %d%% | %s", (int)(progress*100), step); + else + snprintf(message, sizeof(message), "Completing solution %d%%", (int)(progress*100)); + update_callback(update_customdata, progress, message); + } +} + template<typename PipelineRoutines> void InternalCompleteReconstruction( const Tracks &tracks, @@ -152,12 +167,18 @@ void InternalCompleteReconstruction( LG << "Got " << reconstructed_markers.size() << " reconstructed markers for track " << track; if (reconstructed_markers.size() >= 2) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + NULL); PipelineRoutines::Intersect(reconstructed_markers, reconstruction); num_intersects++; LG << "Ran Intersect() for track " << track; } } if (num_intersects) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + "Bundling..."); PipelineRoutines::Bundle(tracks, reconstruction); LG << "Ran Bundle() after intersections."; } @@ -182,11 +203,12 @@ void InternalCompleteReconstruction( LG << "Got " << reconstructed_markers.size() << " reconstructed markers for image " << image; if (reconstructed_markers.size() >= 5) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + NULL); if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, false)) { num_resects++; tot_resects++; - if(update_callback) - update_callback(update_customdata, (float)tot_resects/(max_image), "Completing solution"); LG << "Ran Resect() for image " << image; } else { LG << "Failed Resect() for image " << image; @@ -194,6 +216,9 @@ void InternalCompleteReconstruction( } } if (num_resects) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + "Bundling..."); PipelineRoutines::Bundle(tracks, reconstruction); } LG << "Did " << num_resects << " resects."; @@ -215,17 +240,21 @@ void InternalCompleteReconstruction( } } if (reconstructed_markers.size() >= 5) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + NULL); if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, true)) { num_resects++; LG << "Ran Resect() for image " << image; - if(update_callback) - update_callback(update_customdata, (float)tot_resects/(max_image), "Completing solution"); } else { LG << "Failed Resect() for image " << image; } } } if (num_resects) { + CompleteReconstructionLogProress(update_callback, update_customdata, + (double)tot_resects/(max_image), + "Bundling..."); PipelineRoutines::Bundle(tracks, reconstruction); } } @@ -253,7 +282,7 @@ double InternalReprojectionError(const Tracks &image_tracks, PipelineRoutines::ProjectMarker(*point, *camera, intrinsics); double ex = reprojected_marker.x - markers[i].x; double ey = reprojected_marker.y - markers[i].y; - +#if 0 const int N = 100; char line[N]; snprintf(line, N, @@ -271,6 +300,7 @@ double InternalReprojectionError(const Tracks &image_tracks, ex, ey, sqrt(ex*ex + ey*ey)); +#endif total_error += sqrt(ex*ex + ey*ey); } LG << "Skipped " << num_skipped << " markers."; |