Refactoring (videostab)
This commit is contained in:
parent
1569c1ed52
commit
536d36b05a
@ -49,6 +49,7 @@
|
|||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/features2d/features2d.hpp"
|
#include "opencv2/features2d/features2d.hpp"
|
||||||
#include "opencv2/videostab/optical_flow.hpp"
|
#include "opencv2/videostab/optical_flow.hpp"
|
||||||
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
#if HAVE_OPENCV_GPU
|
#if HAVE_OPENCV_GPU
|
||||||
#include "opencv2/gpu/gpu.hpp"
|
#include "opencv2/gpu/gpu.hpp"
|
||||||
@ -63,7 +64,7 @@ enum MotionModel
|
|||||||
{
|
{
|
||||||
MM_TRANSLATION = 0,
|
MM_TRANSLATION = 0,
|
||||||
MM_TRANSLATION_AND_SCALE = 1,
|
MM_TRANSLATION_AND_SCALE = 1,
|
||||||
MM_LINEAR_SIMILARITY = 2,
|
MM_SIMILARITY = 2,
|
||||||
MM_AFFINE = 3,
|
MM_AFFINE = 3,
|
||||||
MM_HOMOGRAPHY = 4,
|
MM_HOMOGRAPHY = 4,
|
||||||
MM_UNKNOWN = 5
|
MM_UNKNOWN = 5
|
||||||
@ -90,7 +91,7 @@ struct CV_EXPORTS RansacParams
|
|||||||
return RansacParams(1, 0.5f, 0.5f, 0.99f);
|
return RansacParams(1, 0.5f, 0.5f, 0.99f);
|
||||||
if (model == MM_TRANSLATION_AND_SCALE)
|
if (model == MM_TRANSLATION_AND_SCALE)
|
||||||
return RansacParams(2, 0.5f, 0.5f, 0.99f);
|
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);
|
return RansacParams(2, 0.5f, 0.5f, 0.99f);
|
||||||
if (model == MM_AFFINE)
|
if (model == MM_AFFINE)
|
||||||
return RansacParams(3, 0.5f, 0.5f, 0.99f);
|
return RansacParams(3, 0.5f, 0.5f, 0.99f);
|
||||||
|
@ -112,7 +112,7 @@ private:
|
|||||||
class CV_EXPORTS LpMotionStabilizer : public IMotionStabilizer
|
class CV_EXPORTS LpMotionStabilizer : public IMotionStabilizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LpMotionStabilizer(MotionModel model = MM_LINEAR_SIMILARITY);
|
LpMotionStabilizer(MotionModel model = MM_SIMILARITY);
|
||||||
|
|
||||||
void setMotionModel(MotionModel val) { model_ = val; }
|
void setMotionModel(MotionModel val) { model_ = val; }
|
||||||
MotionModel motionModel() const { return model_; }
|
MotionModel motionModel() const { return model_; }
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include "opencv2/videostab/global_motion.hpp"
|
#include "opencv2/videostab/global_motion.hpp"
|
||||||
#include "opencv2/videostab/ring_buffer.hpp"
|
#include "opencv2/videostab/ring_buffer.hpp"
|
||||||
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -149,7 +150,7 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Mat estimateGlobMotionLeastSquaresLinearSimilarity(
|
static Mat estimateGlobMotionLeastSquaresSimilarity(
|
||||||
int npoints, Point2f *points0, Point2f *points1, float *rmse)
|
int npoints, Point2f *points0, Point2f *points1, float *rmse)
|
||||||
{
|
{
|
||||||
Mat_<float> T0 = normalizePoints(npoints, points0);
|
Mat_<float> T0 = normalizePoints(npoints, points0);
|
||||||
@ -165,7 +166,7 @@ static Mat estimateGlobMotionLeastSquaresLinearSimilarity(
|
|||||||
a1 = A[2*i+1];
|
a1 = A[2*i+1];
|
||||||
p0 = points0[i];
|
p0 = points0[i];
|
||||||
p1 = points1[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;
|
a1[0] = p0.y; a1[1] = -p0.x; a1[2] = 0; a1[3] = 1;
|
||||||
b(2*i,0) = p1.x;
|
b(2*i,0) = p1.x;
|
||||||
b(2*i+1,0) = p1.y;
|
b(2*i+1,0) = p1.y;
|
||||||
@ -233,7 +234,7 @@ Mat estimateGlobalMotionLeastSquares(
|
|||||||
typedef Mat (*Impl)(int, Point2f*, Point2f*, float*);
|
typedef Mat (*Impl)(int, Point2f*, Point2f*, float*);
|
||||||
static Impl impls[] = { estimateGlobMotionLeastSquaresTranslation,
|
static Impl impls[] = { estimateGlobMotionLeastSquaresTranslation,
|
||||||
estimateGlobMotionLeastSquaresTranslationAndScale,
|
estimateGlobMotionLeastSquaresTranslationAndScale,
|
||||||
estimateGlobMotionLeastSquaresLinearSimilarity,
|
estimateGlobMotionLeastSquaresSimilarity,
|
||||||
estimateGlobMotionLeastSquaresAffine };
|
estimateGlobMotionLeastSquaresAffine };
|
||||||
|
|
||||||
return impls[model](npoints, points0, points1, rmse);
|
return impls[model](npoints, points0, points1, rmse);
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "opencv2/videostab/global_motion.hpp"
|
#include "opencv2/videostab/global_motion.hpp"
|
||||||
#include "opencv2/videostab/fast_marching.hpp"
|
#include "opencv2/videostab/fast_marching.hpp"
|
||||||
#include "opencv2/videostab/ring_buffer.hpp"
|
#include "opencv2/videostab/ring_buffer.hpp"
|
||||||
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include "opencv2/videostab/videostab.hpp"
|
#include "opencv2/videostab/videostab.hpp"
|
||||||
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
#define arg(name) cmd.get<string>(name)
|
#define arg(name) cmd.get<string>(name)
|
||||||
#define argb(name) cmd.get<bool>(name)
|
#define argb(name) cmd.get<bool>(name)
|
||||||
@ -223,7 +224,7 @@ int main(int argc, const char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if HAVE_OPENCV_GPU
|
||||||
if (arg("gpu") == "yes")
|
if (arg("gpu") == "yes")
|
||||||
{
|
{
|
||||||
cout << "initializing GPU..."; cout.flush();
|
cout << "initializing GPU..."; cout.flush();
|
||||||
@ -281,7 +282,7 @@ int main(int argc, const char **argv)
|
|||||||
else if (arg("ws-model") == "transl_and_scale")
|
else if (arg("ws-model") == "transl_and_scale")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
|
est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
|
||||||
else if (arg("ws-model") == "linear_sim")
|
else if (arg("ws-model") == "linear_sim")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_LINEAR_SIMILARITY);
|
est = new PyrLkRobustMotionEstimator(MM_SIMILARITY);
|
||||||
else if (arg("ws-model") == "affine")
|
else if (arg("ws-model") == "affine")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_AFFINE);
|
est = new PyrLkRobustMotionEstimator(MM_AFFINE);
|
||||||
else if (arg("ws-model") == "homography")
|
else if (arg("ws-model") == "homography")
|
||||||
@ -306,7 +307,7 @@ int main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
else if (arg("gpu") == "yes")
|
else if (arg("gpu") == "yes")
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if HAVE_OPENCV_GPU
|
||||||
PyrLkRobustMotionEstimatorGpu *est = 0;
|
PyrLkRobustMotionEstimatorGpu *est = 0;
|
||||||
|
|
||||||
if (arg("ws-model") == "transl")
|
if (arg("ws-model") == "transl")
|
||||||
@ -314,7 +315,7 @@ int main(int argc, const char **argv)
|
|||||||
else if (arg("ws-model") == "transl_and_scale")
|
else if (arg("ws-model") == "transl_and_scale")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
|
||||||
else if (arg("ws-model") == "linear_sim")
|
else if (arg("ws-model") == "linear_sim")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_LINEAR_SIMILARITY);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_SIMILARITY);
|
||||||
else if (arg("ws-model") == "affine")
|
else if (arg("ws-model") == "affine")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
|
||||||
else if (arg("ws-model") == "homography")
|
else if (arg("ws-model") == "homography")
|
||||||
@ -377,7 +378,7 @@ int main(int argc, const char **argv)
|
|||||||
else if (arg("model") == "transl_and_scale")
|
else if (arg("model") == "transl_and_scale")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
|
est = new PyrLkRobustMotionEstimator(MM_TRANSLATION_AND_SCALE);
|
||||||
else if (arg("model") == "linear_sim")
|
else if (arg("model") == "linear_sim")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_LINEAR_SIMILARITY);
|
est = new PyrLkRobustMotionEstimator(MM_SIMILARITY);
|
||||||
else if (arg("model") == "affine")
|
else if (arg("model") == "affine")
|
||||||
est = new PyrLkRobustMotionEstimator(MM_AFFINE);
|
est = new PyrLkRobustMotionEstimator(MM_AFFINE);
|
||||||
else if (arg("model") == "homography")
|
else if (arg("model") == "homography")
|
||||||
@ -401,7 +402,7 @@ int main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
else if (arg("gpu") == "yes")
|
else if (arg("gpu") == "yes")
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if HAVE_OPENCV_GPU
|
||||||
PyrLkRobustMotionEstimatorGpu *est = 0;
|
PyrLkRobustMotionEstimatorGpu *est = 0;
|
||||||
|
|
||||||
if (arg("ws-model") == "transl")
|
if (arg("ws-model") == "transl")
|
||||||
@ -409,7 +410,7 @@ int main(int argc, const char **argv)
|
|||||||
else if (arg("ws-model") == "transl_and_scale")
|
else if (arg("ws-model") == "transl_and_scale")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_TRANSLATION_AND_SCALE);
|
||||||
else if (arg("ws-model") == "linear_sim")
|
else if (arg("ws-model") == "linear_sim")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_LINEAR_SIMILARITY);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_SIMILARITY);
|
||||||
else if (arg("ws-model") == "affine")
|
else if (arg("ws-model") == "affine")
|
||||||
est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
|
est = new PyrLkRobustMotionEstimatorGpu(MM_AFFINE);
|
||||||
else if (arg("ws-model") == "homography")
|
else if (arg("ws-model") == "homography")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user