[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39350] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Fri Aug 12 23:56:09 CEST 2011


Revision: 39350
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39350
Author:   nazgul
Date:     2011-08-12 21:56:08 +0000 (Fri, 12 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Distortion/undistortion were accidentally swapped in both of grease
  pencil calibration and grid.

  This was fixed but distortion coefficients should be re-adjusted.

  There are some issues with high distortion coefficients but it
  came from libmv and until it'll be fixed there nothing really
  can be done here.

- Fixed displayed aspect ratio for muted footage when pixel/display
  aspect ratio is differ from 1.0 or proxy size is not Full Render,

- Added c-api for image distortion/undistortion, Not used yet.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/ChangeLog
    branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
    branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h
    branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
    branches/soc-2011-tomato/extern/libmv/libmv-capi.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c

Modified: branches/soc-2011-tomato/extern/libmv/ChangeLog
===================================================================
--- branches/soc-2011-tomato/extern/libmv/ChangeLog	2011-08-12 20:53:29 UTC (rev 39349)
+++ branches/soc-2011-tomato/extern/libmv/ChangeLog	2011-08-12 21:56:08 UTC (rev 39350)
@@ -1,3 +1,33 @@
+commit 10bdad9ad2cea2603896263cde5a5339169a9af0
+Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
+Date:   Fri Aug 12 21:05:32 2011 +0200
+
+    Fix out of bound access in warp bilinear sampling.
+
+commit dd9a418db021a28af2c1198d5e5b9e68fe048a03
+Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
+Date:   Fri Aug 12 19:14:36 2011 +0200
+
+    Fix compilation with -funsigned-char.
+
+commit bd1a268ede39b67f2ba4b360f6fc693419e7cd7f
+Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
+Date:   Fri Aug 12 18:39:27 2011 +0200
+
+    CameraIntrinsics fixes.
+
+commit ae513b39fb779632f96ceff7c1e014fb8e68702a
+Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
+Date:   Tue Aug 9 19:38:58 2011 +0200
+
+    Remove stray QDebug include.
+
+commit 1e58f55078ce6009a885be30ae0316aec6ed8239
+Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
+Date:   Tue Aug 9 14:16:31 2011 +0200
+
+    Make API future-proof (for an eventual affine or planar tracker).
+
 commit c2af303e7bf0dddcb02937323ac5846b1801e6cc
 Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
 Date:   Tue Aug 9 11:13:29 2011 +0200
@@ -388,58 +418,3 @@
     Add feature detection.
     
     Remove unused keyframe selection code.
-
-commit 1088517da70ae9ec2369752fbc17dde4bb869c47
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Mon Jul 11 22:42:14 2011 +0200
-
-    Replace system file dialog with custom one which supports multiple file/folder selection.
-    Add Stop button when adding frame from video.
-
-commit 323af7a3a1344e7ef419c72fe22b674c17c578e3
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Mon Jul 11 16:30:59 2011 +0200
-
-    Add stub for feature detection.
-
-commit 739ec729fa8bc6e0ba6a40cc7b89d85e5332e900
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Mon Jul 11 16:30:42 2011 +0200
-
-    Fix compilation of Qt Calibration tool.
-
-commit 113ccc413db6bdfb75839418bddfba5ce3ba60f7
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Mon Jul 11 12:27:47 2011 +0200
-
-    Add raw on-disk video cache.
-    
-    This is useful for faster testing iterations.
-    It avoids waiting for the footage to decode on startup.
-    Using file memory mapping, we let the OS handle caching.
-    The OS disk cache also has the advantage of being kept in memory between runs.
-    A cache is only created for shot < 1GiB (e.g 17s of 1080 at 30).
-
-commit efbe8b6a3e2a8cff497726e11afffbce0ec6aa53
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Mon Jul 11 11:11:47 2011 +0200
-
-    Miscellaneous UI fixes, faster grayscale conversion, compute window size from pattern size and pyramid level count.
-
-commit 0c6911831b0a391da14bf1c5833b1e5c0d5056b7
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Sun Jul 10 22:48:15 2011 +0200
-
-    Add Video support using FFmpeg to Qt Calibration.
-
-commit c9f2bd5a17585f816bf0ef89097ac8f222ad058e
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Sun Jul 10 19:44:35 2011 +0200
-
-    Add Video support using FFmpeg to Qt Tracker.
-
-commit af8f9c412b0592868a0e68a14686651b45de9737
-Author: Matthias Fauconneau <matthias.fauconneau at gmail.com>
-Date:   Sat Jul 9 12:08:28 2011 +0200
-
-    Update README with instructions to build Qt OpenCV Calibration tool.

Modified: branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc	2011-08-12 20:53:29 UTC (rev 39349)
+++ branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.cc	2011-08-12 21:56:08 UTC (rev 39350)
@@ -23,7 +23,7 @@
 
 namespace libmv {
 
-struct Offset { char ix,iy; unsigned char fx,fy; };
+struct Offset { signed char ix,iy; unsigned char fx,fy; };
 
 CameraIntrinsics::CameraIntrinsics()
     : K_(Mat3::Identity()),
@@ -42,6 +42,44 @@
   if(undistort_) delete[] undistort_;
 }
 
+/// Set the entire calibration matrix at once.
+void CameraIntrinsics::SetK(const Mat3 new_k) {
+  K_ = new_k;
+  FreeLookupGrid();
+}
+
+/// Set both x and y focal length in pixels.
+void CameraIntrinsics::SetFocalLength(double focal_x, double focal_y) {
+  K_(0, 0) = focal_x;
+  K_(1, 1) = focal_y;
+  FreeLookupGrid();
+}
+
+void CameraIntrinsics::SetPrincipalPoint(double cx, double cy) {
+  K_(0, 2) = cx;
+  K_(1, 2) = cy;
+  FreeLookupGrid();
+}
+
+void CameraIntrinsics::SetImageSize(int width, int height) {
+  image_width_ = width;
+  image_height_ = height;
+  FreeLookupGrid();
+}
+
+void CameraIntrinsics::SetRadialDistortion(double k1, double k2, double k3) {
+  k1_ = k1;
+  k2_ = k2;
+  k3_ = k3;
+  FreeLookupGrid();
+}
+
+void CameraIntrinsics::SetTangentialDistortion(double p1, double p2) {
+  p1_ = p1;
+  p2_ = p2;
+  FreeLookupGrid();
+}
+
 void CameraIntrinsics::ApplyIntrinsics(double normalized_x,
                                        double normalized_y,
                                        double *image_x,
@@ -117,18 +155,11 @@
       int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256);
       if(fx == 256) { fx=0; ix++; }
       if(fy == 256) { fy=0; iy++; }
-#ifdef CLIP
       // Use nearest border pixel
       if( ix < 0 ) { ix = 0, fx = 0; }
       if( iy < 0 ) { iy = 0, fy = 0; }
-      if( ix >= width-1 ) { ix = width-1, fx = 0; }
-      if( iy >= height-1 ) { iy = height-1, fy = 0; }
-#else
-      // No offset: Avoid adding out of bounds to error.
-      if( ix < 0 || iy < 0 || ix >= width-1 || iy >= height-1 ) {
-        ix = x; iy = y; fx = fy = 0;
-      }
-#endif
+      if( ix >= width-2 ) ix = width-2;
+      if( iy >= height-2 ) iy = height-2;
       //assert( ix-x > -128 && ix-x < 128 && iy-y > -128 && iy-y < 128 );
       Offset offset = { ix-x, iy-y, fx, fy };
       grid[y*width+x] = offset;
@@ -152,6 +183,11 @@
   }
 }
 
+void CameraIntrinsics::FreeLookupGrid() {
+  if(distort_) delete distort_, distort_=0;
+  if(undistort_) delete undistort_, undistort_=0;
+}
+
 // FIXME: C++ templates limitations makes thing complicated, but maybe there is a simpler method.
 struct ApplyIntrinsicsFunction {
   ApplyIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y,

Modified: branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h	2011-08-12 20:53:29 UTC (rev 39349)
+++ branches/soc-2011-tomato/extern/libmv/libmv/simple_pipeline/camera_intrinsics.h	2011-08-12 21:56:08 UTC (rev 39350)
@@ -49,36 +49,18 @@
   double      p2()                const { return p2_; }
 
   /// Set the entire calibration matrix at once.
-  void SetK(const Mat3 new_k) {
-    K_ = new_k;
-  }
+  void SetK(const Mat3 new_k);
 
   /// Set both x and y focal length in pixels.
-  void SetFocalLength(double focal_x, double focal_y) {
-    K_(0, 0) = focal_x;
-    K_(1, 1) = focal_y;
-  }
+  void SetFocalLength(double focal_x, double focal_y);
 
-  void SetPrincipalPoint(double cx, double cy) {
-    K_(0, 2) = cx;
-    K_(1, 2) = cy;
-  }
+  void SetPrincipalPoint(double cx, double cy);
 
-  void SetImageSize(int width, int height) {
-    image_width_ = width;
-    image_height_ = height;
-  }
+  void SetImageSize(int width, int height);
 
-  void SetRadialDistortion(double k1, double k2, double k3 = 0) {
-    k1_ = k1;
-    k2_ = k2;
-    k3_ = k3;
-  }
+  void SetRadialDistortion(double k1, double k2, double k3 = 0);
 
-  void SetTangentialDistortion(double p1, double p2) {
-    p1_ = p1;
-    p2_ = p2;
-  }
+  void SetTangentialDistortion(double p1, double p2);
 
   /*!
       Apply camera intrinsics to the normalized point to get image coordinates.
@@ -142,6 +124,7 @@
 
  private:
   template<typename WarpFunction> void ComputeLookupGrid(Offset* grid, int width, int height);
+  void FreeLookupGrid();
 
   // The traditional intrinsics matrix from x = K[R|t]X.
   Mat3 K_;

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2011-08-12 20:53:29 UTC (rev 39349)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2011-08-12 21:56:08 UTC (rev 39350)
@@ -501,6 +501,56 @@
 	delete (std::vector<libmv::Corner> *)libmv_corners;
 }
 
+/* ************ distortion ************ */
+
+void libmv_undistortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+			unsigned char *src, unsigned char *dst, int width, int height, int channels)
+{
+	libmv::CameraIntrinsics intrinsics;
+
+	intrinsics.SetFocalLength(focal_length, focal_length);
+	intrinsics.SetPrincipalPoint(principal_x, principal_y);
+	intrinsics.SetRadialDistortion(k1, k2, k3);
+
+	intrinsics.Undistort(src, dst, width, height, channels);
+}
+
+void libmv_undistortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+			float *src, float *dst, int width, int height, int channels)
+{
+	libmv::CameraIntrinsics intrinsics;
+
+	intrinsics.SetFocalLength(focal_length, focal_length);
+	intrinsics.SetPrincipalPoint(principal_x, principal_y);
+	intrinsics.SetRadialDistortion(k1, k2, k3);
+
+	intrinsics.Undistort(src, dst, width, height, channels);
+}
+
+void libmv_distortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+			unsigned char *src, unsigned char *dst, int width, int height, int channels)
+{
+	libmv::CameraIntrinsics intrinsics;
+
+	intrinsics.SetFocalLength(focal_length, focal_length);
+	intrinsics.SetPrincipalPoint(principal_x, principal_y);
+	intrinsics.SetRadialDistortion(k1, k2, k3);
+
+	intrinsics.Distort(src, dst, width, height, channels);
+}
+
+void libmv_distortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
+			float *src, float *dst, int width, int height, int channels)
+{
+	libmv::CameraIntrinsics intrinsics;
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list