[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58750] branches/soc-2013-motion_track: Modify libmv output types to store multiview reconstructions

Joseph Mansfield sftrabbit at gmail.com
Wed Jul 31 03:10:36 CEST 2013


Revision: 58750
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58750
Author:   sftrabbit
Date:     2013-07-31 01:10:34 +0000 (Wed, 31 Jul 2013)
Log Message:
-----------
Modify libmv output types to store multiview reconstructions

The libmv_solve function returns a libmv_Reconstruction which contains a EuclideanReconstruction. This class and its brother, ProjectiveReconstruction, store the results of a reconstruction. To make way for multiview reconstruction, modify these classes to store reconstructed camera poses associated with particular views.

All libmv algorithms have been adjusted to meet the new API, temporarily assuming view 0 everywhere until they have also been multiviewified.

Modified Paths:
--------------
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/intersect.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/pipeline.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/reconstruction_scale.cc
    branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/resect.cc
    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/bundle.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc	2013-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -255,7 +255,7 @@
   all_cameras_R_t.resize(max_image + 1);
 
   for (int i = 0; i <= max_image; i++) {
-    const EuclideanCamera *camera = reconstruction.CameraForImage(i);
+    const EuclideanCamera *camera = reconstruction.CameraForViewImage(0, i);
 
     if (!camera) {
       continue;
@@ -276,7 +276,7 @@
   int max_image = tracks.MaxImage();
 
   for (int i = 0; i <= max_image; i++) {
-    EuclideanCamera *camera = reconstruction->CameraForImage(i);
+    EuclideanCamera *camera = reconstruction->CameraForViewImage(0, i);
 
     if (!camera) {
       continue;
@@ -343,7 +343,7 @@
       int max_image = tracks.MaxImage();
       bool is_first_camera = true;
       for (int i = 0; i <= max_image; i++) {
-        const EuclideanCamera *camera = reconstruction->CameraForImage(i);
+        const EuclideanCamera *camera = reconstruction->CameraForViewImage(0, i);
         if (camera) {
           double *current_camera_R_t = &(*all_cameras_R_t)[i](0);
 
@@ -455,7 +455,7 @@
   bool have_locked_camera = false;
   for (int i = 0; i < markers.size(); ++i) {
     const Marker &marker = markers[i];
-    EuclideanCamera *camera = reconstruction->CameraForImage(marker.image);
+    EuclideanCamera *camera = reconstruction->CameraForViewImage(0, marker.image);
     EuclideanPoint *point = reconstruction->PointForTrack(marker.track);
     if (camera == NULL || point == NULL) {
       continue;

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-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -85,8 +85,8 @@
   }
 
   // Image 1 gets the reference frame, image 2 gets the relative motion.
-  reconstruction->InsertCamera(image1, Mat3::Identity(), Vec3::Zero());
-  reconstruction->InsertCamera(image2, R, t);
+  reconstruction->InsertCamera(0, image1, Mat3::Identity(), Vec3::Zero());
+  reconstruction->InsertCamera(0, image2, R, t);
 
   LG << "From two frame reconstruction got:\nR:\n" << R
      << "\nt:" << t.transpose();
@@ -186,8 +186,8 @@
   Mat34 P2;
   ProjectionsFromFundamental(F, &P1, &P2);
 
-  reconstruction->InsertCamera(image1, P1);
-  reconstruction->InsertCamera(image2, P2);
+  reconstruction->InsertCamera(0, image1, P1);
+  reconstruction->InsertCamera(0, image2, P2);
 
   LG << "From two frame reconstruction got P2:\n" << P2;
   return true;

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/intersect.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/intersect.cc	2013-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/intersect.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -78,7 +78,7 @@
   vector<Mat34> cameras;
   Mat34 P;
   for (int i = 0; i < markers.size(); ++i) {
-    EuclideanCamera *camera = reconstruction->CameraForImage(markers[i].image);
+    EuclideanCamera *camera = reconstruction->CameraForViewImage(0, markers[i].image);
     P_From_KRt(K, camera->R, camera->t, &P);
     cameras.push_back(P);
   }
@@ -103,7 +103,7 @@
   for (int i = 0; i < markers.size(); ++i) {
     const Marker &marker = markers[i];
     const EuclideanCamera &camera =
-        *reconstruction->CameraForImage(marker.image);
+        *reconstruction->CameraForViewImage(0, marker.image);
 
     problem.AddResidualBlock(
         new ceres::AutoDiffCostFunction<
@@ -131,7 +131,7 @@
   // Try projecting the point; make sure it's in front of everyone.
   for (int i = 0; i < cameras.size(); ++i) {
     const EuclideanCamera &camera =
-        *reconstruction->CameraForImage(markers[i].image);
+        *reconstruction->CameraForViewImage(0, markers[i].image);
     Vec3 x = camera.R * X + camera.t;
     if (x(2) < 0) {
       LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image
@@ -164,7 +164,7 @@
     residuals.setZero();
     for (int i = 0; i < markers.size(); ++i) {
       const ProjectiveCamera &camera =
-          *reconstruction.CameraForImage(markers[i].image);
+          *reconstruction.CameraForViewImage(0, markers[i].image);
       Vec3 projected = camera.P * X;
       projected /= projected(2);
       residuals[2*i + 0] = projected(0) - markers[i].x;
@@ -187,7 +187,7 @@
   // Get the cameras to use for the intersection.
   vector<Mat34> cameras;
   for (int i = 0; i < markers.size(); ++i) {
-    ProjectiveCamera *camera = reconstruction->CameraForImage(markers[i].image);
+    ProjectiveCamera *camera = reconstruction->CameraForViewImage(0, markers[i].image);
     cameras.push_back(camera->P);
   }
 
@@ -215,7 +215,7 @@
   // Try projecting the point; make sure it's in front of everyone.
   for (int i = 0; i < cameras.size(); ++i) {
     const ProjectiveCamera &camera =
-        *reconstruction->CameraForImage(markers[i].image);
+        *reconstruction->CameraForViewImage(0, markers[i].image);
     Vec3 x = camera.P * X;
     if (x(2) < 0) {
       LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image

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-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -442,10 +442,10 @@
          << "\nt:" << t.transpose();
 
       // First camera is identity, second one is relative to it
-      reconstruction.InsertCamera(current_keyframe,
+      reconstruction.InsertCamera(0, current_keyframe,
                                   Mat3::Identity(),
                                   Vec3::Zero());
-      reconstruction.InsertCamera(candidate_image, R, t);
+      reconstruction.InsertCamera(0, candidate_image, R, t);
 
       // 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-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -218,7 +218,7 @@
     // Convert quaternion to rotation matrix.
     Mat3 R;
     ceres::QuaternionToRotation(&quaternion(0), &R(0, 0));
-    reconstruction->InsertCamera(image, R, Vec3::Zero());
+    reconstruction->InsertCamera(0, image, R, Vec3::Zero());
 
     // STEP 3: reproject all new markers appeared at image
 

Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/pipeline.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/pipeline.cc	2013-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/pipeline.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -169,7 +169,7 @@
 
       vector<Marker> reconstructed_markers;
       for (int i = 0; i < all_markers.size(); ++i) {
-        if (reconstruction->CameraForImage(all_markers[i].image)) {
+        if (reconstruction->CameraForViewImage(all_markers[i].view, all_markers[i].image)) {
           reconstructed_markers.push_back(all_markers[i]);
         }
       }
@@ -199,7 +199,7 @@
     // Do all possible resections.
     num_resects = 0;
     for (int image = 0; image <= max_image; ++image) {
-      if (reconstruction->CameraForImage(image)) {
+      if (reconstruction->CameraForViewImage(0, image)) {
         LG << "Skipping frame: " << image;
         continue;
       }
@@ -239,7 +239,7 @@
   // One last pass...
   num_resects = 0;
   for (int image = 0; image <= max_image; ++image) {
-    if (reconstruction->CameraForImage(image)) {
+    if (reconstruction->CameraForViewImage(0, image)) {
       LG << "Skipping frame: " << image;
       continue;
     }
@@ -282,7 +282,7 @@
   vector<Marker> markers = image_tracks.AllMarkers();
   for (int i = 0; i < markers.size(); ++i) {
     const typename PipelineRoutines::Camera *camera =
-        reconstruction.CameraForImage(markers[i].image);
+        reconstruction.CameraForViewImage(0, markers[i].image);
     const typename PipelineRoutines::Point *point =
         reconstruction.PointForTrack(markers[i].track);
     if (!camera || !point) {

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-07-30 23:34:52 UTC (rev 58749)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/reconstruction.cc	2013-07-31 01:10:34 UTC (rev 58750)
@@ -18,6 +18,8 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 // IN THE SOFTWARE.
 
+#include <vector>
+
 #include "libmv/simple_pipeline/reconstruction.h"
 #include "libmv/numeric/numeric.h"
 #include "libmv/logging/logging.h"
@@ -40,16 +42,22 @@
   return *this;
 }
 
-void EuclideanReconstruction::InsertCamera(int image,
+void EuclideanReconstruction::InsertCamera(int view,
+                                           int image,
                                            const Mat3 &R,
                                            const Vec3 &t) {
-  LG << "InsertCamera " << image << ":\nR:\n"<< R << "\nt:\n" << t;
-  if (image >= cameras_.size()) {
-    cameras_.resize(image + 1);
+  LG << "InsertCamera view " << view << ", image " << image
+     << ":\nR:\n"<< R << "\nt:\n" << t;
+  if (view >= cameras_.size()) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list