motion_stabilizing.hpp
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
22 //
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
26 //
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42 
43 #ifndef __OPENCV_VIDEOSTAB_MOTION_STABILIZING_HPP__
44 #define __OPENCV_VIDEOSTAB_MOTION_STABILIZING_HPP__
45 
46 #include <vector>
47 #include "opencv2/core/core.hpp"
48 
49 namespace cv
50 {
51 namespace videostab
52 {
53 
54 class CV_EXPORTS IMotionStabilizer
55 {
56 public:
57  virtual void stabilize(const Mat *motions, int size, Mat *stabilizationMotions) const = 0;
58 
59 #ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY
60  virtual ~IMotionStabilizer() {}
61 #endif
62 };
63 
64 class CV_EXPORTS MotionFilterBase : public IMotionStabilizer
65 {
66 public:
67  MotionFilterBase() : radius_(0) {}
68  virtual ~MotionFilterBase() {}
69 
70  virtual void setRadius(int val) { radius_ = val; }
71  virtual int radius() const { return radius_; }
72 
73  virtual void update() {}
74 
75  virtual Mat stabilize(int index, const Mat *motions, int size) const = 0;
76  virtual void stabilize(const Mat *motions, int size, Mat *stabilizationMotions) const;
77 
78 protected:
79  int radius_;
80 };
81 
82 class CV_EXPORTS GaussianMotionFilter : public MotionFilterBase
83 {
84 public:
85  GaussianMotionFilter() : stdev_(-1.f) {}
86 
87  void setStdev(float val) { stdev_ = val; }
88  float stdev() const { return stdev_; }
89 
90  virtual void update();
91 
92  virtual Mat stabilize(int index, const Mat *motions, int size) const;
93 
94 private:
95  float stdev_;
96  std::vector<float> weight_;
97 };
98 
99 CV_EXPORTS Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio);
100 
101 CV_EXPORTS float estimateOptimalTrimRatio(const Mat &M, Size size);
102 
103 } // namespace videostab
104 } // namespace
105 
106 #endif
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:186
GaussianMotionFilter()
Definition: motion_stabilizing.hpp:85
Definition: motion_stabilizing.hpp:82
virtual ~IMotionStabilizer()
Definition: motion_stabilizing.hpp:60
MotionFilterBase()
Definition: motion_stabilizing.hpp:67
GLuint index
Definition: core_c.h:986
Definition: motion_stabilizing.hpp:64
virtual int radius() const
Definition: motion_stabilizing.hpp:71
The 2D size class.
Definition: core.hpp:81
void setStdev(float val)
Definition: motion_stabilizing.hpp:87
GLuint GLfloat * val
virtual ~MotionFilterBase()
Definition: motion_stabilizing.hpp:68
int radius_
Definition: motion_stabilizing.hpp:79
float stdev() const
Definition: motion_stabilizing.hpp:88
virtual void setRadius(int val)
Definition: motion_stabilizing.hpp:70
Definition: motion_stabilizing.hpp:54
The Core Functionality.
The n-dimensional matrix class.
Definition: core.hpp:1688
virtual void update()
Definition: motion_stabilizing.hpp:73
GLclampf f
CV_EXPORTS Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio)
GLsizeiptr size
Definition: core_c.h:939
CV_EXPORTS float estimateOptimalTrimRatio(const Mat &M, Size size)