Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-11-22 18:45:22 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-11-22 18:45:22 +0400
commite22884966656e19339b509024894f674e0ee3afb (patch)
treed89d2bead74a93ff5f3182eaf7ac77a745714362 /extern
parentf48e1b55723abe4d31e117a7fb988835b45d8a1a (diff)
Camera tracking: expose progress and status from camera solver into interface
Reporting progress isn't really accurate, but trying to make it more linear can lead to spending more effort on it than having benefit. Also, changing status in the information line helps to understand that blender isn't hang up and solving is till working nicely. Main changes in code: - libmv_solveReconstruction now accepts additional parameters: * progress_update_callback - a function which is getting called from solver algorithm to report progress back to Blender. * callback_customdata - a user-defined context which is passing to progress_update_callback so progress can be updated in needed blender-side data structures. This parameters are optional. - Added structure MovieTrackingStats which is placed in MovieTracking structure. It's supposed to be used for displaying information about different operations (currently it's only camera solver, but can be easily used for something else in the future) in clip editor. This statistics structure is getting allocated for time operator is working and not saving into .blend file. - Clip Editor now displays statistics stored in MovieTrackingStats structure like it's done for rendering.
Diffstat (limited to 'extern')
-rw-r--r--extern/libmv/libmv-capi.cpp16
-rw-r--r--extern/libmv/libmv-capi.h6
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.cc22
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.h6
4 files changed, 40 insertions, 10 deletions
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp
index 8c453944e9d..6be8d838d37 100644
--- a/extern/libmv/libmv-capi.cpp
+++ b/extern/libmv/libmv-capi.cpp
@@ -31,6 +31,8 @@
#include "libmv-capi.h"
#include "glog/logging.h"
+#include "libmv/logging/logging.h"
+
#include "Math/v3d_optimization.h"
#include "libmv/tracking/esm_region_tracker.h"
@@ -356,7 +358,8 @@ int libmv_refineParametersAreValid(int parameters) {
libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyframe1, int keyframe2,
- int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3)
+ int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+ reconstruct_progress_update_cb progress_update_callback, void *callback_customdata)
{
/* Invert the camera intrinsics. */
libmv::vector<libmv::Marker> markers = ((libmv::Tracks*)tracks)->AllMarkers();
@@ -377,15 +380,17 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra
libmv::Tracks normalized_tracks(markers);
- // printf("frames to init from: %d, %d\n", keyframe1, keyframe2);
+ LG << "frames to init from: " << keyframe1 << " " << keyframe2;
libmv::vector<libmv::Marker> keyframe_markers =
normalized_tracks.MarkersForTracksInBothImages(keyframe1, keyframe2);
- // printf("number of markers for init: %d\n", keyframe_markers.size());
+ LG << "number of markers for init: " << keyframe_markers.size();
+
+ progress_update_callback(callback_customdata, 0, "Initial reconstruction");
libmv::EuclideanReconstructTwoFrames(keyframe_markers, reconstruction);
libmv::EuclideanBundle(normalized_tracks, reconstruction);
- libmv::EuclideanCompleteReconstruction(normalized_tracks, reconstruction);
+ libmv::EuclideanCompleteReconstruction(normalized_tracks, reconstruction, progress_update_callback, callback_customdata);
if (refine_intrinsics) {
/* only a few combinations are supported but trust the caller */
@@ -402,9 +407,12 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra
if (refine_intrinsics & LIBMV_REFINE_RADIAL_DISTORTION_K2) {
libmv_refine_flags |= libmv::BUNDLE_RADIAL_K2;
}
+
+ progress_update_callback(callback_customdata, 0, "Refining solution");
libmv::EuclideanBundleCommonIntrinsics(*(libmv::Tracks *)tracks, libmv_refine_flags, reconstruction, intrinsics);
}
+ progress_update_callback(callback_customdata, 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-capi.h b/extern/libmv/libmv-capi.h
index 8252a11739b..536f8a5f14c 100644
--- a/extern/libmv/libmv-capi.h
+++ b/extern/libmv/libmv-capi.h
@@ -64,10 +64,14 @@ void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
#define LIBMV_REFINE_PRINCIPAL_POINT (1<<1)
#define LIBMV_REFINE_RADIAL_DISTORTION_K1 (1<<2)
#define LIBMV_REFINE_RADIAL_DISTORTION_K2 (1<<4)
+
+typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
+
int libmv_refineParametersAreValid(int parameters);
struct libmv_Reconstruction *libmv_solveReconstruction(struct libmv_Tracks *tracks, int keyframe1, int keyframe2,
- int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3);
+ int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+ reconstruct_progress_update_cb progress_update_callback, void *callback_customdata);
int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track);
double libmv_reporojectionErrorForImage(struct libmv_Reconstruction *libmv_reconstruction, int image);
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc
index 9512a41c00f..93f41d237e8 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.cc
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc
@@ -21,6 +21,7 @@
#include <cstdio>
#include "libmv/logging/logging.h"
+#include "libmv/simple_pipeline/pipeline.h"
#include "libmv/simple_pipeline/bundle.h"
#include "libmv/simple_pipeline/intersect.h"
#include "libmv/simple_pipeline/resect.h"
@@ -120,11 +121,14 @@ struct ProjectivePipelineRoutines {
template<typename PipelineRoutines>
void InternalCompleteReconstruction(
const Tracks &tracks,
- typename PipelineRoutines::Reconstruction *reconstruction) {
+ typename PipelineRoutines::Reconstruction *reconstruction,
+ progress_update_callback update_callback,
+ void *update_customdata) {
int max_track = tracks.MaxTrack();
int max_image = tracks.MaxImage();
int num_resects = -1;
int num_intersects = -1;
+ int tot_resects = 0;
LG << "Max track: " << max_track;
LG << "Max image: " << max_image;
LG << "Number of markers: " << tracks.NumMarkers();
@@ -180,6 +184,9 @@ void InternalCompleteReconstruction(
if (reconstructed_markers.size() >= 5) {
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;
@@ -211,6 +218,8 @@ void InternalCompleteReconstruction(
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;
}
@@ -289,15 +298,20 @@ double ProjectiveReprojectionError(
}
void EuclideanCompleteReconstruction(const Tracks &tracks,
- EuclideanReconstruction *reconstruction) {
+ EuclideanReconstruction *reconstruction,
+ progress_update_callback update_callback,
+ void *update_customdata) {
InternalCompleteReconstruction<EuclideanPipelineRoutines>(tracks,
- reconstruction);
+ reconstruction,
+ update_callback,
+ update_customdata);
}
void ProjectiveCompleteReconstruction(const Tracks &tracks,
ProjectiveReconstruction *reconstruction) {
InternalCompleteReconstruction<ProjectivePipelineRoutines>(tracks,
- reconstruction);
+ reconstruction,
+ NULL, NULL);
}
void InvertIntrinsicsForTracks(const Tracks &raw_tracks,
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.h b/extern/libmv/libmv/simple_pipeline/pipeline.h
index b7dfcb7993a..dc1a79506f2 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.h
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.h
@@ -26,6 +26,8 @@
namespace libmv {
+typedef void (*progress_update_callback) (void *customdata, double progress, const char *message);
+
/*!
Estimate camera poses and scene 3D coordinates for all frames and tracks.
@@ -46,7 +48,9 @@ namespace libmv {
\sa EuclideanResect, EuclideanIntersect, EuclideanBundle
*/
void EuclideanCompleteReconstruction(const Tracks &tracks,
- EuclideanReconstruction *reconstruction);
+ EuclideanReconstruction *reconstruction,
+ progress_update_callback update_callback,
+ void *update_customdata);
/*!
Estimate camera matrices and homogeneous 3D coordinates for all frames and