forked from bartvdbraak/blender
Camera tracking: cleaned progress reporting stuff and made a bit more verbose
This commit is contained in:
parent
aff993db55
commit
29b89cbc7b
7
extern/libmv/libmv-capi.cpp
vendored
7
extern/libmv/libmv-capi.cpp
vendored
@ -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);
|
||||
|
||||
|
40
extern/libmv/libmv/simple_pipeline/pipeline.cc
vendored
40
extern/libmv/libmv/simple_pipeline/pipeline.cc
vendored
@ -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.";
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user