Camera tracking: cleaned progress reporting stuff and made a bit more verbose
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 25 Nov 2011 15:43:38 +0000 (15:43 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 25 Nov 2011 15:43:38 +0000 (15:43 +0000)
extern/libmv/libmv-capi.cpp
extern/libmv/libmv/simple_pipeline/pipeline.cc
source/blender/blenkernel/intern/tracking.c
source/blender/editors/space_clip/tracking_ops.c

index 6be8d838d37eca746287db2364a037c7ced59a24..2472b08da190fae3870efbbab1460b5e4f939527 100644 (file)
@@ -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);
 
index 93f41d237e85bd9c3861ae7008f69bc0997d451e..654127ac51d2ba96e7eae76ff2cf8bc37cdbe017 100644 (file)
@@ -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.";
index cb58abbfa24128c411734e30bff7a895db319a6e..65ca0a87602627822fe3fe4e3f402c1c2a1b1ce8 100644 (file)
@@ -1328,6 +1328,7 @@ typedef struct ReconstructProgressData {
        short *stop;
        short *do_update;
        float *progress;
+       float stats_progress;
        char *stats_message;
        int message_size;
 } ReconstructProgressData;
@@ -1627,11 +1628,8 @@ static void solve_reconstruction_update_cb(void *customdata, double progress, co
                *progressdata->do_update= 1;
        }
 
-       if(progress) {
-               BLI_snprintf(progressdata->stats_message, progressdata->message_size, "%s | %d%%", message, (int)(progress*100));
-       } else {
-               BLI_strncpy(progressdata->stats_message, message, progressdata->message_size);
-       }
+       BLI_snprintf(progressdata->stats_message, progressdata->message_size, "Solving camera | %s", message);
+       progressdata->stats_progress= progress;
 }
 
 #if 0
index dc3a857c2c98f82bdb07b4431510715130d6c6c2..43cce0ada673a974c52bbc14d9ece8797a7327b9 100644 (file)
@@ -1518,6 +1518,8 @@ typedef struct {
        ReportList *reports;
 
        char stats_message[256];
+       float *stats_progress;
+
        struct MovieReconstructContext *context;
 } SolveCameraJob;
 
@@ -1555,12 +1557,17 @@ static void solve_camera_updatejob(void *scv)
        MovieTracking *tracking= &scj->clip->tracking;
 
        BLI_strncpy(tracking->stats->message, scj->stats_message, sizeof(tracking->stats->message));
+
+       if(scj->stats_progress)
+               tracking->stats->progress= *scj->stats_progress;
 }
 
 static void solve_camera_startjob(void *scv, short *stop, short *do_update, float *progress)
 {
        SolveCameraJob *scj= (SolveCameraJob *)scv;
 
+       scj->stats_progress= progress;
+
        BKE_tracking_solve_reconstruction(scj->context, stop, do_update, progress,
                        scj->stats_message, sizeof(scj->stats_message));
 }
@@ -1665,7 +1672,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
                return OPERATOR_CANCELLED;
        }
 
-       BLI_strncpy(tracking->stats->message, "Preparing solve", sizeof(tracking->stats->message));
+       BLI_strncpy(tracking->stats->message, "Solving camera | Preparing solve", sizeof(tracking->stats->message));
 
        /* hide reconstruction statistics from previous solve */
        clip->tracking.reconstruction.flag&= ~TRACKING_RECONSTRUCTED;
@@ -1674,7 +1681,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
        /* setup job */
        steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS);
        WM_jobs_customdata(steve, scj, solve_camera_freejob);
-       WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0);
+       WM_jobs_timer(steve, 0.1, NC_MOVIECLIP|NA_EVALUATED, 0);
        WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL);
 
        G.afbreek= 0;