[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59917] branches/soc-2013-motion_track/ extern/libmv: Improved naming of cameras/views

Joseph Mansfield sftrabbit at gmail.com
Sat Sep 7 16:47:32 CEST 2013


Revision: 59917
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59917
Author:   sftrabbit
Date:     2013-09-07 14:47:32 +0000 (Sat, 07 Sep 2013)
Log Message:
-----------
Improved naming of cameras/views

The recent change that distinguished "multicamera reconstruction" from "multiview reconstruction" led to some confusing naming. A EuclideanReconstruction would store EuclideanCameras, which are the position and orientation of a physical camera for a specific image. That is, a EuclideanCamera is a camera at an instance, rather than representing the physical camera itself. This meant that EuclideanCameras had associated cameras, which is clearly confusing. This commit attempts to unify the terminology:

- View - a specific instance of a camera at some orientation and point in space (giving an image of the scene)
- Multiview reconstruction - reconstruction of a scene from multiple views
- Camera - a physical video camera
- Multicamera reconstruction - a form of multiview reconstruction, where the views are associated with some number of video cameras

To this end, EuclideanCamera and ProjectiveCamera have been renamed to EuclideanView and ProjectiveView, as they represent a camera at a specific instance.

Some functions continue to have variables named "camera" where "view" would be more appropriate.

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

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-09-07 12:59:16 UTC (rev 59916)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/bundle.cc	2013-09-07 14:47:32 UTC (rev 59917)
@@ -255,15 +255,15 @@
   all_cameras_R_t.resize(max_image + 1);
 
   for (int i = 0; i <= max_image; i++) {
-    const EuclideanCamera *camera = reconstruction.CameraForImage(0, i);
+    const EuclideanView *view = reconstruction.ViewForImage(0, i);
 
-    if (!camera) {
+    if (!view) {
       continue;
     }
 
-    ceres::RotationMatrixToAngleAxis(&camera->R(0, 0),
+    ceres::RotationMatrixToAngleAxis(&view->R(0, 0),
                                      &all_cameras_R_t[i](0));
-    all_cameras_R_t[i].tail<3>() = camera->t;
+    all_cameras_R_t[i].tail<3>() = view->t;
   }
   return all_cameras_R_t;
 }
@@ -276,15 +276,15 @@
   int max_image = tracks.MaxImage();
 
   for (int i = 0; i <= max_image; i++) {
-    EuclideanCamera *camera = reconstruction->CameraForImage(0, i);
+    EuclideanView *view = reconstruction->ViewForImage(0, i);
 
-    if (!camera) {
+    if (!view) {
       continue;
     }
 
     ceres::AngleAxisToRotationMatrix(&all_cameras_R_t[i](0),
-                                     &camera->R(0, 0));
-    camera->t = all_cameras_R_t[i].tail<3>();
+                                     &view->R(0, 0));
+    view->t = all_cameras_R_t[i].tail<3>();
   }
 }
 
@@ -343,8 +343,8 @@
       int max_image = tracks.MaxImage();
       bool is_first_camera = true;
       for (int i = 0; i <= max_image; i++) {
-        const EuclideanCamera *camera = reconstruction->CameraForImage(0, i);
-        if (camera) {
+        const EuclideanView *view = reconstruction->ViewForImage(0, i);
+        if (view) {
           double *current_camera_R_t = &(*all_cameras_R_t)[i](0);
 
           // All cameras are variable now.
@@ -456,15 +456,15 @@
   for (int i = 0; i < markers.size(); ++i) {
     const Marker &marker = markers[i];
     int camera = marker.camera;
-    EuclideanCamera *camera_pose = reconstruction->CameraForImage(camera, marker.image);
+    EuclideanView *view = reconstruction->ViewForImage(camera, marker.image);
     EuclideanPoint *point = reconstruction->PointForTrack(marker.track);
-    if (camera_pose == NULL || point == NULL) {
+    if (view == NULL || point == NULL) {
       continue;
     }
 
     // Rotation of camera denoted in angle axis followed with
     // camera translaiton.
-    double *current_camera_R_t = &all_cameras_R_t[camera_pose->image](0);
+    double *current_camera_R_t = &all_cameras_R_t[view->image](0);
 
     OpenCVReprojectionError *cost_function;
     if (bundle_options.constraints & BUNDLE_CONSTRAIN_FOCAL_LENGTH) {

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-07 12:59:16 UTC (rev 59916)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/initialize_reconstruction.cc	2013-09-07 14:47:32 UTC (rev 59917)
@@ -87,8 +87,8 @@
   }
 
   // Image 1 gets the reference frame, image 2 gets the relative motion.
-  reconstruction->InsertCamera(camera, image1, Mat3::Identity(), Vec3::Zero());
-  reconstruction->InsertCamera(camera, image2, R, t);
+  reconstruction->InsertView(camera, image1, Mat3::Identity(), Vec3::Zero());
+  reconstruction->InsertView(camera, image2, R, t);
 
   LG << "From two frame reconstruction got:\nR:\n" << R
      << "\nt:" << t.transpose();
@@ -188,8 +188,8 @@
   Mat34 P2;
   ProjectionsFromFundamental(F, &P1, &P2);
 
-  reconstruction->InsertCamera(0, image1, P1);
-  reconstruction->InsertCamera(0, image2, P2);
+  reconstruction->InsertView(0, image1, P1);
+  reconstruction->InsertView(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-09-07 12:59:16 UTC (rev 59916)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/intersect.cc	2013-09-07 14:47:32 UTC (rev 59917)
@@ -39,8 +39,8 @@
 class EuclideanIntersectCostFunctor {
  public:
   EuclideanIntersectCostFunctor(const Marker &marker,
-                                const EuclideanCamera &camera)
-      : marker_(marker), camera_(camera) {}
+                                const EuclideanView &view)
+      : marker_(marker), view_(view) {}
 
   template<typename T>
   bool operator()(const T *X, T *residuals) const {
@@ -48,8 +48,8 @@
     typedef Eigen::Matrix<T, 3, 1> Vec3;
 
     Vec3 x(X);
-    Mat3 R(camera_.R.cast<T>());
-    Vec3 t(camera_.t.cast<T>());
+    Mat3 R(view_.R.cast<T>());
+    Vec3 t(view_.t.cast<T>());
 
     Vec3 projected = R * x + t;
     projected /= projected(2);
@@ -61,7 +61,7 @@
   }
 
   const Marker &marker_;
-  const EuclideanCamera &camera_;
+  const EuclideanView &view_;
 };
 
 }  // namespace
@@ -78,8 +78,8 @@
   vector<Mat34> cameras;
   Mat34 P;
   for (int i = 0; i < markers.size(); ++i) {
-    EuclideanCamera *camera = reconstruction->CameraForImage(0, markers[i].image);
-    P_From_KRt(K, camera->R, camera->t, &P);
+    EuclideanView *view = reconstruction->ViewForImage(0, markers[i].image);
+    P_From_KRt(K, view->R, view->t, &P);
     cameras.push_back(P);
   }
 
@@ -102,14 +102,14 @@
 
   for (int i = 0; i < markers.size(); ++i) {
     const Marker &marker = markers[i];
-    const EuclideanCamera &camera =
-        *reconstruction->CameraForImage(0, marker.image);
+    const EuclideanView &view =
+        *reconstruction->ViewForImage(0, marker.image);
 
     problem.AddResidualBlock(
         new ceres::AutoDiffCostFunction<
             EuclideanIntersectCostFunctor,
             2, /* num_residuals */
-            3>(new EuclideanIntersectCostFunctor(marker, camera)),
+            3>(new EuclideanIntersectCostFunctor(marker, view)),
         NULL,
         &X(0));
   }
@@ -130,9 +130,9 @@
 
   // 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(0, markers[i].image);
-    Vec3 x = camera.R * X + camera.t;
+    const EuclideanView &view =
+        *reconstruction->ViewForImage(0, markers[i].image);
+    Vec3 x = view.R * X + view.t;
     if (x(2) < 0) {
       LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image
                  << ": " << x.transpose();
@@ -163,9 +163,9 @@
     Vec residuals(2 * markers.size());
     residuals.setZero();
     for (int i = 0; i < markers.size(); ++i) {
-      const ProjectiveCamera &camera =
-          *reconstruction.CameraForImage(0, markers[i].image);
-      Vec3 projected = camera.P * X;
+      const ProjectiveView &view =
+          *reconstruction.ViewForImage(0, markers[i].image);
+      Vec3 projected = view.P * X;
       projected /= projected(2);
       residuals[2*i + 0] = projected(0) - markers[i].x;
       residuals[2*i + 1] = projected(1) - markers[i].y;
@@ -187,8 +187,8 @@
   // Get the cameras to use for the intersection.
   vector<Mat34> cameras;
   for (int i = 0; i < markers.size(); ++i) {
-    ProjectiveCamera *camera = reconstruction->CameraForImage(0, markers[i].image);
-    cameras.push_back(camera->P);
+    ProjectiveView *view = reconstruction->ViewForImage(0, markers[i].image);
+    cameras.push_back(view->P);
   }
 
   // Stack the 2D coordinates together as required by NViewTriangulate.
@@ -214,9 +214,9 @@
 
   // 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(0, markers[i].image);
-    Vec3 x = camera.P * X;
+    const ProjectiveView &view =
+        *reconstruction->ViewForImage(0, markers[i].image);
+    Vec3 x = view.P * X;
     if (x(2) < 0) {
       LOG(ERROR) << "POINT BEHIND CAMERA " << markers[i].image
                  << ": " << x.transpose();

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-07 12:59:16 UTC (rev 59916)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc	2013-09-07 14:47:32 UTC (rev 59917)
@@ -442,10 +442,10 @@
          << "\nt:" << t.transpose();
 
       // First camera is identity, second one is relative to it
-      reconstruction.InsertCamera(0, current_keyframe,
-                                  Mat3::Identity(),
-                                  Vec3::Zero());
-      reconstruction.InsertCamera(0, candidate_image, R, t);
+      reconstruction.InsertView(0, current_keyframe,
+                                Mat3::Identity(),
+                                Vec3::Zero());
+      reconstruction.InsertView(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-09-07 12:59:16 UTC (rev 59916)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/modal_solver.cc	2013-09-07 14:47:32 UTC (rev 59917)
@@ -218,7 +218,7 @@
     // Convert quaternion to rotation matrix.
     Mat3 R;
     ceres::QuaternionToRotation(&quaternion(0), &R(0, 0));
-    reconstruction->InsertCamera(0, image, R, Vec3::Zero());
+    reconstruction->InsertView(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
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list