OpenCV 4.5.3(日本語機械翻訳)
motion_stabilizing.hpp
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 <utility>
48 #include "opencv2/core.hpp"
49 #include "opencv2/videostab/global_motion.hpp"
50
51 namespace cv
52{
53 namespace videostab
54{
55
58
59 class CV_EXPORTS IMotionStabilizer
60{
61 public:
62 virtual ~IMotionStabilizer() {}
63
65 virtual void stabilize(
66 int size, const std::vector<Mat> &motions, const Range &range,
67 Mat *stabilizationMotions) = 0;
68};
69
71{
72 public:
73 void pushBack(Ptr<IMotionStabilizer> stabilizer) { stabilizers_.push_back(stabilizer); }
74 bool empty() const { return stabilizers_.empty(); }
75
76 virtual void stabilize(
77 int size, const std::vector<Mat> &motions, const Range &range,
78 Mat *stabilizationMotions) CV_OVERRIDE;
79
80 private:
81 std::vector<Ptr<IMotionStabilizer> > stabilizers_;
82};
83
84 class CV_EXPORTS MotionFilterBase : public IMotionStabilizer
85{
86 public:
87 virtual ~MotionFilterBase() {}
88
89 virtual Mat stabilize(
90 int idx, const std::vector<Mat> &motions, const Range &range) = 0;
91
92 virtual void stabilize(
93 int size, const std::vector<Mat> &motions, const Range &range,
94 Mat *stabilizationMotions) CV_OVERRIDE;
95};
96
97 class CV_EXPORTS GaussianMotionFilter : public MotionFilterBase
98{
99 public:
100 GaussianMotionFilter(int radius = 15, float stdev = -1.f);
101
102 void setParams(int radius, float stdev = -1.f);
103 int radius() const { return radius_; }
104 float stdev() const { return stdev_; }
105
106 virtual Mat stabilize(
107 int idx, const std::vector<Mat> &motions, const Range &range) CV_OVERRIDE;
108
109 private:
110 int radius_;
111 float stdev_;
112 std::vector<float> weight_;
113};
114
115 inline GaussianMotionFilter::GaussianMotionFilter(int _radius, float _stdev) { setParams(_radius, _stdev); }
116
117 class CV_EXPORTS LpMotionStabilizer : public IMotionStabilizer
118{
119 public:
120 LpMotionStabilizer(MotionModel model = MM_SIMILARITY);
121
122 void setMotionModel(MotionModel val) { model_ = val; }
123 MotionModel motionModel() const { return model_; }
124
125 void setFrameSize(Size val) { frameSize_ = val; }
126 Size frameSize() const { return frameSize_; }
127
128 void setTrimRatio(float val) { trimRatio_ = val; }
129 float trimRatio() const { return trimRatio_; }
130
131 void setWeight1(float val) { w1_ = val; }
132 float weight1() const { return w1_; }
133
134 void setWeight2(float val) { w2_ = val; }
135 float weight2() const { return w2_; }
136
137 void setWeight3(float val) { w3_ = val; }
138 float weight3() const { return w3_; }
139
140 void setWeight4(float val) { w4_ = val; }
141 float weight4() const { return w4_; }
142
143 virtual void stabilize(
144 int size, const std::vector<Mat> &motions, const Range &range,
145 Mat *stabilizationMotions) CV_OVERRIDE;
146
147 private:
148 MotionModel model_;
149 Size frameSize_;
150 float trimRatio_;
151 float w1_, w2_, w3_, w4_;
152
153 std::vector<double> obj_, collb_, colub_;
154 std::vector<int> rows_, cols_;
155 std::vector<double> elems_, rowlb_, rowub_;
156
157 void set(int row, int col, double coef)
158 {
159 rows_.push_back(row);
160 cols_.push_back(col);
161 elems_.push_back(coef);
162 }
163};
164
165CV_EXPORTS Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio);
166
167CV_EXPORTS float estimateOptimalTrimRatio(const Mat &M, Size size);
168
170
171} // namespace videostab
172} // namespace
173
174 #endif
n-dimensional dense array class
Definition: mat.hpp:802
Template class specifying a continuous subsequence (slice) of a sequence.
Definition: core/types.hpp:590
Template class for specifying the size of an image or rectangle.
Definition: core/types.hpp:316
Definition: motion_stabilizing.hpp:98
Definition: motion_stabilizing.hpp:60
virtual void stabilize(int size, const std::vector< Mat > &motions, const Range &range, Mat *stabilizationMotions)=0
assumes that [0, size-1) is in or equals to [range.first, range.second)
Definition: motion_stabilizing.hpp:118
virtual void stabilize(int size, const std::vector< Mat > &motions, const Range &range, Mat *stabilizationMotions) CV_OVERRIDE
assumes that [0, size-1) is in or equals to [range.first, range.second)
Definition: motion_stabilizing.hpp:85
virtual void stabilize(int size, const std::vector< Mat > &motions, const Range &range, Mat *stabilizationMotions) CV_OVERRIDE
assumes that [0, size-1) is in or equals to [range.first, range.second)
Definition: motion_stabilizing.hpp:71
virtual void stabilize(int size, const std::vector< Mat > &motions, const Range &range, Mat *stabilizationMotions) CV_OVERRIDE
assumes that [0, size-1) is in or equals to [range.first, range.second)
MotionModel
Describes motion model between two point clouds.
Definition: motion_core.hpp:60
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74