[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60047] branches/soc-2013-motion_track: Clearer association between markers and cameras

Joseph Mansfield sftrabbit at gmail.com
Wed Sep 11 16:48:29 CEST 2013


Revision: 60047
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60047
Author:   sftrabbit
Date:     2013-09-11 14:48:29 +0000 (Wed, 11 Sep 2013)
Log Message:
-----------
Clearer association between markers and cameras

As the camera identifier associated with a marker is simply bookkeeping for multicamera reconstruction, make it an optional attribute when handling tracks and reconstructed views. This means that the libmv API is still nice for users that don't need to associate images with cameras.

Modified Paths:
--------------
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.h
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/resect.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.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/extern/libmv/libmv-capi_stub.cc
    branches/soc-2013-motion_track/source/blender/blenkernel/intern/tracking.c

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc	2013-09-11 14:14:18 UTC (rev 60046)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc	2013-09-11 14:48:29 UTC (rev 60047)
@@ -87,8 +87,8 @@
   }
 
   // Image 1 gets the reference frame, image 2 gets the relative motion.
-  reconstruction->InsertView(camera, image1, Mat3::Identity(), Vec3::Zero());
-  reconstruction->InsertView(camera, image2, R, t);
+  reconstruction->InsertView(image1, Mat3::Identity(), Vec3::Zero(), camera);
+  reconstruction->InsertView(image2, R, t, camera);
 
   LG << "From two frame reconstruction got:\nR:\n" << R
      << "\nt:" << t.transpose();
@@ -188,8 +188,8 @@
   Mat34 P2;
   ProjectionsFromFundamental(F, &P1, &P2);
 
-  reconstruction->InsertView(0, image1, P1);
-  reconstruction->InsertView(0, image2, P2);
+  reconstruction->InsertView(image1, P1, 0);
+  reconstruction->InsertView(image2, P2, 0);
 
   LG << "From two frame reconstruction got P2:\n" << P2;
   return true;

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-09-11 14:14:18 UTC (rev 60046)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-09-11 14:48:29 UTC (rev 60047)
@@ -446,10 +446,11 @@
          << "\nt:" << t.transpose();
 
       // First camera is identity, second one is relative to it
-      reconstruction.InsertView(kSelectionCamera, current_keyframe,
+      reconstruction.InsertView(current_keyframe,
                                 Mat3::Identity(),
-                                Vec3::Zero());
-      reconstruction.InsertView(kSelectionCamera, candidate_image, R, t);
+                                Vec3::Zero(),
+                                kSelectionCamera);
+      reconstruction.InsertView(candidate_image, R, t, kSelectionCamera);
 
       // Reconstruct 3D points
       int intersects_total = 0, intersects_success = 0;

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc	2013-09-11 14:14:18 UTC (rev 60046)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc	2013-09-11 14:48:29 UTC (rev 60047)
@@ -218,7 +218,7 @@
     // Convert quaternion to rotation matrix.
     Mat3 R;
     ceres::QuaternionToRotation(&quaternion(0), &R(0, 0));
-    reconstruction->InsertView(kModalCamera, image, R, Vec3::Zero());
+    reconstruction->InsertView(image, R, Vec3::Zero(), kModalCamera);
 
     // STEP 3: reproject all new markers appeared at image
 

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.cc	2013-09-11 14:14:18 UTC (rev 60046)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.cc	2013-09-11 14:48:29 UTC (rev 60047)
@@ -42,19 +42,19 @@
   return *this;
 }
 
-void EuclideanReconstruction::InsertView(int camera,
-                                         int image,
+void EuclideanReconstruction::InsertView(int image,
                                          const Mat3 &R,
-                                         const Vec3 &t) {
+                                         const Vec3 &t,
+                                         int camera) {
   LG << "InsertView camera " << camera << ", image " << image
      << ":\nR:\n"<< R << "\nt:\n" << t;
   if (image >= views_.size()) {
     views_.resize(image + 1);
   }
-  views_[image].camera = camera;
   views_[image].image = image;
   views_[image].R = R;
   views_[image].t = t;
+  views_[image].camera = camera;
 }
 
 void EuclideanReconstruction::InsertPoint(int track, const Vec3 &X) {
@@ -99,7 +99,7 @@
     int camera) const {
   vector<EuclideanView> views;
   for (int i = 0; i < views_.size(); ++i) {
-    if (views_[i].camera == camera) {
+    if (views_[i].image != -1 && views_[i].camera == camera) {
       views.push_back(views_[i]);
     }
   }
@@ -132,16 +132,17 @@
   return points;
 }
 
-void ProjectiveReconstruction::InsertView(int camera, int image,
-                                          const Mat34 &P) {
+void ProjectiveReconstruction::InsertView(int image,
+                                          const Mat34 &P,
+                                          int camera) {
   LG << "InsertView camera " << camera << ", image " << image
      << ":\nP:\n"<< P;
   if (image >= views_.size()) {
     views_.resize(image + 1);
   }
-  views_[image].camera = camera;
   views_[image].image = image;
   views_[image].P = P;
+  views_[image].camera = camera;
 }
 
 void ProjectiveReconstruction::InsertPoint(int track, const Vec4 &X) {

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.h
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.h	2013-09-11 14:14:18 UTC (rev 60046)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.h	2013-09-11 14:48:29 UTC (rev 60047)
@@ -40,26 +40,28 @@
 };
 
 /*!
-    A EuclideanView is the location and rotation of a \a camera viewing an
-    \a image. All EuclideanViews for the same \a camera represent the motion of
-    a particular video camera across all of its corresponding images.
+    A EuclideanView is the location and orientation of a camera viewing an
+    \a image. A EuclideanView may be associated with a particular \a camera for
+    a multicamera reconstruction. All EuclideanViews for the same \a camera
+    represent the motion of a particular video camera across all of its
+    corresponding images.
 
-    \a camera identify which camera from \l Tracks this view is associated with.
     \a image identify which image from \l Tracks this view represents.
     \a R is a 3x3 matrix representing the rotation of the view.
     \a t is a translation vector representing its positions.
+    \a camera identify which camera from \l Tracks this view is associated with.
 
     \sa Reconstruction
 */
 struct EuclideanView {
-  EuclideanView() : camera(-1), image(-1) {}
+  EuclideanView() : image(-1), camera(0) {}
   EuclideanView(const EuclideanView &v)
-      : camera(v.camera), image(v.image), R(v.R), t(v.t) {}
+      : image(v.image), R(v.R), t(v.t), camera(v.camera) {}
 
-  int camera;
   int image;
   Mat3 R;
   Vec3 t;
+  int camera;
 };
 
 /*!
@@ -84,8 +86,8 @@
     The EuclideanReconstruction container is intended as the store of 3D
     reconstruction data to be used with the MultiView API.
 
-    The container has lookups to query a \a EuclideanView for a \a camera
-    and \a image, or a \a EuclideanPoint from a \a track.
+    The container has lookups to query a \a EuclideanView for an \a image, or a
+    \a EuclideanPoint from a \a track.
 
     \sa View, Point
 */
@@ -102,17 +104,18 @@
   /*!
       Insert a view into the set. If there is already a view for the given
       \a image, the existing view is replaced. If there is no view for the given
-      \a image, a new one is added.
+      \a image, a new one is added. A view may be associated with a \a camera
+      in a multicamera reconstruction.
 
-      \a image is the key used to retrieve the views with the other methods in
-      this class.
+      \a image and \a camera are the keys used to retrieve the views with the
+      other methods in this class.
 
       \note You should use the same \a camera and \a image identifiers as in
             \l Tracks.
       \note All markers for a single \a image should have the same \a camera
             identifiers.
   */
-  void InsertView(int camera, int image, const Mat3 &R, const Vec3 &t);
+  void InsertView(int image, const Mat3 &R, const Vec3 &t, int camera = 0);
 
   /*!
       Insert a point into the reconstruction. If there is already a point for
@@ -149,24 +152,26 @@
 };
 
 /*!
-    A ProjectiveView is the projection matrix for the view of an \a image from
-    a \a camera. All ProjectiveViews for the same \a camera represent the motion of
-    a particular video camera across all of its corresponding images.
+    A ProjectiveView is the projection matrix for the view of an \a image. A
+    ProjectiveView may be associated with a particular \a camera for a
+    multicamera reconstruction. All ProjectiveViews for the same \a camera
+    represent the motion of a particular video camera across all of its
+    corresponding images.
 
-    \a camera identify which camera from \l Tracks this view is associated with.
     \a image identify which image from \l Tracks this view represents.
     \a P is the 3x4 projection matrix.
+    \a camera identify which camera from \l Tracks this view is associated with.
 
     \sa ProjectiveReconstruction
 */
 struct ProjectiveView {
-  ProjectiveView() : camera(-1), image(-1) {}
+  ProjectiveView() : image(-1), camera(0) {}
   ProjectiveView(const ProjectiveView &v)
-      : camera(v.camera), image(v.image), P(v.P) {}
+      : image(v.image), P(v.P), camera(v.camera) {}
 
-  int camera;
   int image;
   Mat34 P;
+  int camera;
 };
 
 /*!
@@ -191,8 +196,8 @@
     The ProjectiveReconstruction container is intended as the store of 3D
     reconstruction data to be used with the MultiView API.
 
-    The container has lookups to query a \a ProjectiveView for a \a camera and
-    \a image, or a \a ProjectivePoint from a \a track.
+    The container has lookups to query a \a ProjectiveView for an \a image, or
+    a \a ProjectivePoint from a \a track.
 
     \sa View, Point
 */
@@ -201,17 +206,18 @@
   /*!
       Insert a view into the set. If there is already a view for the given
       \a image, the existing view is replaced. If there is no view for the given
-      \a image, a new one is added.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list