Refactoring (videostab)
authorAlexey Spizhevoy <no@email>
Wed, 18 Apr 2012 17:00:07 +0000 (17:00 +0000)
committerAlexey Spizhevoy <no@email>
Wed, 18 Apr 2012 17:00:07 +0000 (17:00 +0000)
modules/videostab/include/opencv2/videostab/global_motion.hpp
modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp
modules/videostab/src/global_motion.cpp
modules/videostab/src/inpainting.cpp
samples/cpp/videostab.cpp

index b6f503f..bd41386 100644 (file)
@@ -49,6 +49,7 @@
 #include "opencv2/core/core.hpp"
 #include "opencv2/features2d/features2d.hpp"
 #include "opencv2/videostab/optical_flow.hpp"
+#include "opencv2/opencv_modules.hpp"
 
 #if HAVE_OPENCV_GPU
   #include "opencv2/gpu/gpu.hpp"
@@ -63,7 +64,7 @@ enum MotionModel
 {
     MM_TRANSLATION = 0,
     MM_TRANSLATION_AND_SCALE = 1,
-    MM_LINEAR_SIMILARITY = 2,
+    MM_SIMILARITY = 2,
     MM_AFFINE = 3,
     MM_HOMOGRAPHY = 4,
     MM_UNKNOWN = 5
@@ -90,7 +91,7 @@ struct CV_EXPORTS RansacParams
             return RansacParams(1, 0.5f, 0.5f, 0.99f);
         if (model == MM_TRANSLATION_AND_SCALE)
             return RansacParams(2, 0.5f, 0.5f, 0.99f);
-        if (model == MM_LINEAR_SIMILARITY)
+        if (model == MM_SIMILARITY)
             return RansacParams(2, 0.5f, 0.5f, 0.99f);
         if (model == MM_AFFINE)
             return RansacParams(3, 0.5f, 0.5f, 0.99f);
index 78c9f52..69d7ac2 100644 (file)
@@ -112,7 +112,7 @@ private:
 class CV_EXPORTS LpMotionStabilizer : public IMotionStabilizer
 {
 public:
-    LpMotionStabilizer(MotionModel model = MM_LINEAR_SIMILARITY);
+    LpMotionStabilizer(MotionModel model = MM_SIMILARITY);
 
     void setMotionModel(MotionModel val) { model_ = val; }
     MotionModel motionModel() const { return model_; }
index df27402..56c278f 100644 (file)
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 #include "opencv2/videostab/global_motion.hpp"
 #include "opencv2/videostab/ring_buffer.hpp"
+#include "opencv2/opencv_modules.hpp"
 
 using namespace std;
 
@@ -149,7 +150,7 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale(
 }
 
 
-static Mat estimateGlobMotionLeastSquaresLinearSimilarity(
+static Mat estimateGlobMotionLeastSquaresSimilarity(
         int npoints, Point2f *points0, Point2f *points1, float *rmse)
 {
     Mat_<float> T0 = normalizePoints(npoints, points0);
@@ -165,7 +166,7 @@ static Mat estimateGlobMotionLeastSquaresLinearSimilarity(
         a1 = A[2*i+1];
         p0 = points0[i];
         p1 = points1[i];
-        a0[0] = p0.x; a0[1] = p0.y; a0[2] = 1;  a0[3] = 0;
+        a0[0] = p0.x; a0[1] = p0.y; a0[2] = 1; a0[3] = 0;
         a1[0] = p0.y; a1[1] = -p0.x; a1[2] = 0; a1[3] = 1;
         b(2*i,0) = p1.x;
         b(2*i+1,0) = p1.y;
@@ -233,7 +234,7 @@ Mat estimateGlobalMotionLeastSquares(
     typedef Mat (*Impl)(int, Point2f*, Point2f*, float*);
     static Impl impls[] = { estimateGlobMotionLeastSquaresTranslation,
                             estimateGlobMotionLeastSquaresTranslationAndScale,
-                            estimateGlobMotionLeastSquaresLinearSimilarity,
+                            estimateGlobMotionLeastSquaresSimilarity,
                             estimateGlobMotionLeastSquaresAffine };
 
     return impls[model](npoints, points0, points1, rmse);
index 63988b2..4b35f32 100644 (file)
@@ -46,6 +46,7 @@
 #include "opencv2/videostab/global_motion.hpp"
 #include "opencv2/videostab/fast_marching.hpp"
 #include "opencv2/videostab/ring_buffer.hpp"
+#include "opencv2/opencv_modules.hpp"
 
 using namespace std;
 
index 05ca8c5..9800a8f 100644 (file)
@@ -8,6 +8,7 @@
 #include "opencv2/imgproc/imgproc.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/videostab/videostab.hpp"
+#include "opencv2/opencv_modules.hpp"
 
 #define arg(name) cmd.get<string>(name)
 #define argb(name) cmd.get<bool>(name)
@@ -223,7 +224,7 @@ int main(int argc, const char **argv)
             return 0;
         }
 
-#ifdef HAVE_OPENCV_GPU
+#if HAVE_OPENCV_GPU
         if (arg("gpu") == "yes")
         {
             cout << "initializing GPU..."; cout.flush();
@@ -281,7 +282,7 @@ int main(int argc, const char **argv)
                     else if (arg("ws-model") == "transl_and_scale")
                         est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
                     else if (arg("ws-model") == "linear_sim")
-                        est = new PyrLkRobustMotionEstimator(MM_LINEAR_SIMILARITY);
+                        est = new PyrLkRobustMotionEstimator(MM_SIMILARITY);
                     else if (arg("ws-model") == "affine")
                         est = new PyrLkRobustMotionEstimator(MM_AFFINE);
                     else if (arg("ws-model") == "homography")
@@ -306,7 +307,7 @@ int main(int argc, const char **argv)
                 }
                 else if (arg("gpu") == "yes")
                 {
-#ifdef HAVE_OPENCV_GPU
+#if HAVE_OPENCV_GPU
                     PyrLkRobustMotionEstimatorGpu *est = 0;
 
                     if (arg("ws-model") == "transl")
@@ -314,7 +315,7 @@ int main(int argc, const char **argv)
                     else if (arg("ws-model") == "transl_and_scale")
                         est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
                     else if (arg("ws-model") == "linear_sim")
-                        est = new PyrLkRobustMotionEstimatorGpu(MM_LINEAR_SIMILARITY);
+                        est = new PyrLkRobustMotionEstimatorGpu(MM_SIMILARITY);
                     else if (arg("ws-model") == "affine")
                         est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
                     else if (arg("ws-model") == "homography")
@@ -377,7 +378,7 @@ int main(int argc, const char **argv)
             else if (arg("model") == "transl_and_scale")
                 est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
             else if (arg("model") == "linear_sim")
-                est = new PyrLkRobustMotionEstimator(MM_LINEAR_SIMILARITY);
+                est = new PyrLkRobustMotionEstimator(MM_SIMILARITY);
             else if (arg("model") == "affine")
                 est = new PyrLkRobustMotionEstimator(MM_AFFINE);
             else if (arg("model") == "homography")
@@ -401,7 +402,7 @@ int main(int argc, const char **argv)
         }
         else if (arg("gpu") == "yes")
         {
-#ifdef HAVE_OPENCV_GPU
+#if HAVE_OPENCV_GPU
             PyrLkRobustMotionEstimatorGpu *est = 0;
 
             if (arg("ws-model") == "transl")
@@ -409,7 +410,7 @@ int main(int argc, const char **argv)
             else if (arg("ws-model") == "transl_and_scale")
                 est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
             else if (arg("ws-model") == "linear_sim")
-                est = new PyrLkRobustMotionEstimatorGpu(MM_LINEAR_SIMILARITY);
+                est = new PyrLkRobustMotionEstimatorGpu(MM_SIMILARITY);
             else if (arg("ws-model") == "affine")
                 est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
             else if (arg("ws-model") == "homography")