[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58361] branches/soc-2013-motion_track: Refactor and tidy up bundle options and interfaces

Joseph Mansfield sftrabbit at gmail.com
Thu Jul 18 11:21:52 CEST 2013


Revision: 58361
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58361
Author:   sftrabbit
Date:     2013-07-18 09:21:52 +0000 (Thu, 18 Jul 2013)
Log Message:
-----------
Refactor and tidy up bundle options and interfaces

Non-functional changes to a few data types and interfaces involved in passing bundle options from the UI to libmv. A significant change is that the decision to perform a modal reconstruction or not is moved into the libmv C API and the type of camera movement is passed as an option.

Modified Paths:
--------------
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.h
    branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc
    branches/soc-2013-motion_track/extern/libmv/libmv-capi.h
    branches/soc-2013-motion_track/source/blender/blenkernel/intern/tracking.c
    branches/soc-2013-motion_track/source/blender/makesdna/DNA_tracking_types.h
    branches/soc-2013-motion_track/source/blender/makesrna/intern/rna_tracking.c

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc	2013-07-18 07:54:19 UTC (rev 58360)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc	2013-07-18 09:21:52 UTC (rev 58361)
@@ -376,7 +376,7 @@
 }  // namespace
 
 BundleOptions::BundleOptions() :
-  intrinsics(BUNDLE_NO_INTRINSICS),
+  bundle_intrinsics(BUNDLE_NO_INTRINSICS),
   constraints(BUNDLE_NO_CONSTRAINTS),
   focal_length_min(0.0),
   focal_length_max(0.0),
@@ -399,7 +399,7 @@
                                      EuclideanReconstruction *reconstruction,
                                      CameraIntrinsics *intrinsics,
                                      BundleEvaluation *evaluation) {
-  const int bundle_intrinsics = bundle_options.intrinsics;
+  const int bundle_intrinsics = bundle_options.bundle_intrinsics;
   const int bundle_constraints = bundle_options.constraints;
 
   LG << "Original intrinsics: " << *intrinsics;

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.h
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.h	2013-07-18 07:54:19 UTC (rev 58360)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.h	2013-07-18 09:21:52 UTC (rev 58361)
@@ -126,7 +126,7 @@
 
   // Bitfield denoting the camera intrinsics to adjust during
   // bundling. Use BundleIntrinsics flags.
-  int intrinsics;
+  short bundle_intrinsics;
 
   // Bitfield denoting the constraints to place on bundle parameters.
   // Use BundleConstraints flags.

Modified: branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc	2013-07-18 07:54:19 UTC (rev 58360)
+++ branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc	2013-07-18 09:21:52 UTC (rev 58361)
@@ -436,22 +436,26 @@
 
 static void libmv_solveRefineIntrinsics(const libmv::Tracks &tracks,
                                         const libmv_reconstructionOptions &reconstruction_options,
-                                        const int bundle_constraints,
                                         reconstruct_progress_update_cb progress_update_callback,
                                         void *callback_customdata,
                                         libmv::EuclideanReconstruction *reconstruction,
                                         libmv::CameraIntrinsics *intrinsics)
 {
 	/* only a few combinations are supported but trust the caller */
-	const int refine_intrinsics = reconstruction_options.refine_intrinsics;
 	libmv::BundleOptions bundle_options;
-	bundle_options.constraints = bundle_constraints;
 
 	LoggingCallback callback;
 	bundle_options.iteration_callback = &callback;
 
+	const int motion_flag = reconstruction_options.motion_flag;
+	const int refine_intrinsics = reconstruction_options.refine_intrinsics;
+
+	if (motion_flag & LIBMV_TRACKING_MOTION_MODAL) {
+		bundle_options.constraints |= libmv::BUNDLE_NO_TRANSLATION;
+	}
+
 	if (refine_intrinsics & LIBMV_REFINE_FOCAL_LENGTH) {
-		bundle_options.intrinsics |= libmv::BUNDLE_FOCAL_LENGTH;
+		bundle_options.bundle_intrinsics |= libmv::BUNDLE_FOCAL_LENGTH;
 		if (refine_intrinsics & LIBMV_CONSTRAIN_FOCAL_LENGTH) {
 			bundle_options.constraints |= libmv::BUNDLE_CONSTRAIN_FOCAL_LENGTH;
 			bundle_options.focal_length_min = reconstruction_options.focal_length_min;
@@ -459,13 +463,13 @@
 		}
 	}
 	if (refine_intrinsics & LIBMV_REFINE_PRINCIPAL_POINT) {
-		bundle_options.intrinsics |= libmv::BUNDLE_PRINCIPAL_POINT;
+		bundle_options.bundle_intrinsics |= libmv::BUNDLE_PRINCIPAL_POINT;
 	}
 	if (refine_intrinsics & LIBMV_REFINE_RADIAL_DISTORTION_K1) {
-		bundle_options.intrinsics |= libmv::BUNDLE_RADIAL_K1;
+		bundle_options.bundle_intrinsics |= libmv::BUNDLE_RADIAL_K1;
 	}
 	if (refine_intrinsics & LIBMV_REFINE_RADIAL_DISTORTION_K2) {
-		bundle_options.intrinsics |= libmv::BUNDLE_RADIAL_K2;
+		bundle_options.bundle_intrinsics |= libmv::BUNDLE_RADIAL_K2;
 	}
 
 	progress_update_callback(callback_customdata, 1.0, "Refining solution");
@@ -591,7 +595,7 @@
 	return true;
 }
 
-libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks *libmv_tracks,
+static libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks *libmv_tracks,
 			const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
 			libmv_reconstructionOptions *libmv_reconstruction_options,
 			reconstruct_progress_update_cb progress_update_callback,
@@ -656,7 +660,6 @@
 	if (libmv_reconstruction_options->refine_intrinsics) {
 		libmv_solveRefineIntrinsics(tracks,
 		                            *libmv_reconstruction_options,
-		                            libmv::BUNDLE_NO_CONSTRAINTS,
 		                            progress_update_callback,
 		                            callback_customdata,
 		                            &reconstruction,
@@ -673,7 +676,7 @@
 	return (libmv_Reconstruction *)libmv_reconstruction;
 }
 
-struct libmv_Reconstruction *libmv_solveModal(const libmv_Tracks *libmv_tracks,
+static struct libmv_Reconstruction *libmv_solveModal(const libmv_Tracks *libmv_tracks,
 			const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
 			const libmv_reconstructionOptions *libmv_reconstruction_options,
 			reconstruct_progress_update_cb progress_update_callback,
@@ -697,7 +700,7 @@
 	libmv::ModalSolver(normalized_tracks, &reconstruction, &update_callback);
 
 	libmv::BundleOptions bundle_options;
-	bundle_options.intrinsics = libmv::BUNDLE_NO_INTRINSICS;
+	bundle_options.bundle_intrinsics = libmv::BUNDLE_NO_INTRINSICS;
 	bundle_options.constraints = libmv::BUNDLE_NO_TRANSLATION;
 
 	libmv::CameraIntrinsics empty_intrinsics;
@@ -710,7 +713,6 @@
 	if (libmv_reconstruction_options->refine_intrinsics) {
 		libmv_solveRefineIntrinsics(tracks,
 		                            *libmv_reconstruction_options,
-		                            libmv::BUNDLE_NO_TRANSLATION,
 		                            progress_update_callback, callback_customdata,
 		                            &reconstruction,
 		                            &camera_intrinsics);
@@ -723,6 +725,28 @@
 	return (libmv_Reconstruction *)libmv_reconstruction;
 }
 
+libmv_Reconstruction *libmv_solve(const libmv_Tracks *libmv_tracks,
+			const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+			libmv_reconstructionOptions *libmv_reconstruction_options,
+			reconstruct_progress_update_cb progress_update_callback,
+			void *callback_customdata)
+{	
+	if (libmv_reconstruction_options->motion_flag & LIBMV_TRACKING_MOTION_MODAL) {
+    return libmv_solveModal(libmv_tracks,
+		                        libmv_camera_intrinsics_options,
+		                        libmv_reconstruction_options,
+		                        progress_update_callback,
+		                        callback_customdata);
+	}
+	else {
+		return libmv_solveReconstruction(libmv_tracks,
+		                                 libmv_camera_intrinsics_options,
+		                                 libmv_reconstruction_options,
+		                                 progress_update_callback,
+		                                 callback_customdata);
+	}
+}
+
 int libmv_reporojectionPointForTrack(const libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
 {
 	const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;

Modified: branches/soc-2013-motion_track/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv-capi.h	2013-07-18 07:54:19 UTC (rev 58360)
+++ branches/soc-2013-motion_track/extern/libmv/libmv-capi.h	2013-07-18 09:21:52 UTC (rev 58361)
@@ -78,12 +78,15 @@
 
 /* Reconstruction solver */
 
+#define LIBMV_TRACKING_MOTION_MODAL        (1 << 0)
+
 #define LIBMV_REFINE_FOCAL_LENGTH          (1 << 0)
 #define LIBMV_REFINE_PRINCIPAL_POINT       (1 << 1)
 #define LIBMV_REFINE_RADIAL_DISTORTION_K1  (1 << 2)
 #define LIBMV_REFINE_RADIAL_DISTORTION_K2  (1 << 4)
-#define LIBMV_CONSTRAIN_FOCAL_LENGTH       (1 << 8)
 
+#define LIBMV_CONSTRAIN_FOCAL_LENGTH       (1 << 0)
+
 typedef struct libmv_cameraIntrinsicsOptions {
 	double focal_length;
 	double principal_point_x, principal_point_y;
@@ -96,7 +99,10 @@
 	int select_keyframes;
 	int keyframe1, keyframe2;
 
-	int refine_intrinsics;
+	short motion_flag;
+
+	short refine_intrinsics;
+	short constrain_intrinsics;
 	double focal_length_min, focal_length_max;
 
 	double success_threshold;
@@ -105,16 +111,11 @@
 
 typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
 
-struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks *libmv_tracks,
+struct libmv_Reconstruction *libmv_solve(const struct libmv_Tracks *libmv_tracks,
 			const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
 			libmv_reconstructionOptions *libmv_reconstruction_options,
 			reconstruct_progress_update_cb progress_update_callback,
 			void *callback_customdata);
-struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks *libmv_tracks,
-			const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-			const libmv_reconstructionOptions *libmv_reconstruction_options,
-			reconstruct_progress_update_cb progress_update_callback,
-			void *callback_customdata);
 int libmv_reporojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
 double libmv_reporojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track);
 double libmv_reporojectionErrorForImage(const struct libmv_Reconstruction *libmv_reconstruction, int image);

Modified: branches/soc-2013-motion_track/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2013-motion_track/source/blender/blenkernel/intern/tracking.c	2013-07-18 07:54:19 UTC (rev 58360)
+++ branches/soc-2013-motion_track/source/blender/blenkernel/intern/tracking.c	2013-07-18 09:21:52 UTC (rev 58361)
@@ -2869,8 +2869,9 @@
 	struct libmv_Tracks *tracks;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list