From: Alexey Spizhevoy Date: Wed, 18 Apr 2012 17:00:07 +0000 (+0000) Subject: Refactoring (videostab) X-Git-Tag: accepted/2.0/20130307.220821~364^2~905 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=536d36b05a5a0b33c2823782b0cce4d6a9eec35a;p=profile%2Fivi%2Fopencv.git Refactoring (videostab) --- diff --git a/modules/videostab/include/opencv2/videostab/global_motion.hpp b/modules/videostab/include/opencv2/videostab/global_motion.hpp index b6f503f..bd41386 100644 --- a/modules/videostab/include/opencv2/videostab/global_motion.hpp +++ b/modules/videostab/include/opencv2/videostab/global_motion.hpp @@ -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); diff --git a/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp b/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp index 78c9f52..69d7ac2 100644 --- a/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp +++ b/modules/videostab/include/opencv2/videostab/motion_stabilizing.hpp @@ -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_; } diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index df27402..56c278f 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -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_ 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); diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index 63988b2..4b35f32 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -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; diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index 05ca8c5..9800a8f 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -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(name) #define argb(name) cmd.get(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")