Coverage Report

Created: 2023-06-07 08:11

/work/install-coverage/include/opencv4/opencv2/stitching/warpers.hpp
Line
Count
Source (jump to first uncovered line)
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, 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_STITCHING_WARPER_CREATORS_HPP
44
#define OPENCV_STITCHING_WARPER_CREATORS_HPP
45
46
#include "opencv2/stitching/detail/warpers.hpp"
47
#include <string>
48
49
namespace cv {
50
    class CV_EXPORTS_W PyRotationWarper
51
    {
52
        Ptr<detail::RotationWarper> rw;
53
54
    public:
55
        CV_WRAP PyRotationWarper(String type, float scale);
56
0
        CV_WRAP PyRotationWarper() {};
57
0
        ~PyRotationWarper() {}
58
59
        /** @brief Projects the image point.
60
61
        @param pt Source point
62
        @param K Camera intrinsic parameters
63
        @param R Camera rotation matrix
64
        @return Projected point
65
        */
66
        CV_WRAP Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R);
67
68
        /** @brief Projects the image point backward.
69
70
        @param pt Projected point
71
        @param K Camera intrinsic parameters
72
        @param R Camera rotation matrix
73
        @return Backward-projected point
74
        */
75
#if CV_VERSION_MAJOR == 4
76
        CV_WRAP Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R)
77
0
        {
78
0
            CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R);
79
0
            CV_Error(Error::StsNotImplemented, "");
80
0
        }
81
#else
82
        CV_WRAP Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray R);
83
#endif
84
        /** @brief Builds the projection maps according to the given camera data.
85
86
        @param src_size Source image size
87
        @param K Camera intrinsic parameters
88
        @param R Camera rotation matrix
89
        @param xmap Projection map for the x axis
90
        @param ymap Projection map for the y axis
91
        @return Projected image minimum bounding box
92
        */
93
        CV_WRAP Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
94
95
        /** @brief Projects the image.
96
97
        @param src Source image
98
        @param K Camera intrinsic parameters
99
        @param R Camera rotation matrix
100
        @param interp_mode Interpolation mode
101
        @param border_mode Border extrapolation mode
102
        @param dst Projected image
103
        @return Project image top-left corner
104
        */
105
        CV_WRAP Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
106
            CV_OUT OutputArray dst);
107
108
        /** @brief Projects the image backward.
109
110
        @param src Projected image
111
        @param K Camera intrinsic parameters
112
        @param R Camera rotation matrix
113
        @param interp_mode Interpolation mode
114
        @param border_mode Border extrapolation mode
115
        @param dst_size Backward-projected image size
116
        @param dst Backward-projected image
117
        */
118
        CV_WRAP void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
119
            Size dst_size, CV_OUT OutputArray dst);
120
121
        /**
122
        @param src_size Source image bounding box
123
        @param K Camera intrinsic parameters
124
        @param R Camera rotation matrix
125
        @return Projected image minimum bounding box
126
        */
127
        CV_WRAP Rect warpRoi(Size src_size, InputArray K, InputArray R);
128
129
0
        CV_WRAP float getScale() const { return 1.f; }
130
0
        CV_WRAP void setScale(float) {}
131
    };
132
133
//! @addtogroup stitching_warp
134
//! @{
135
136
/** @brief Image warper factories base class.
137
 */
138
139
class CV_EXPORTS_W WarperCreator
140
{
141
public:
142
0
    CV_WRAP virtual ~WarperCreator() {}
143
    virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
144
};
145
146
147
/** @brief Plane warper factory class.
148
  @sa detail::PlaneWarper
149
 */
150
class CV_EXPORTS  PlaneWarper : public WarperCreator
151
{
152
public:
153
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarper>(scale); }
154
};
155
156
/** @brief Affine warper factory class.
157
  @sa detail::AffineWarper
158
 */
159
class CV_EXPORTS  AffineWarper : public WarperCreator
160
{
161
public:
162
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::AffineWarper>(scale); }
163
};
164
165
/** @brief Cylindrical warper factory class.
166
@sa detail::CylindricalWarper
167
*/
168
class CV_EXPORTS CylindricalWarper: public WarperCreator
169
{
170
public:
171
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarper>(scale); }
172
};
173
174
/** @brief Spherical warper factory class */
175
class CV_EXPORTS SphericalWarper: public WarperCreator
176
{
177
public:
178
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarper>(scale); }
179
};
180
181
class CV_EXPORTS FisheyeWarper : public WarperCreator
182
{
183
public:
184
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::FisheyeWarper>(scale); }
185
};
186
187
class CV_EXPORTS StereographicWarper: public WarperCreator
188
{
189
public:
190
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::StereographicWarper>(scale); }
191
};
192
193
class CV_EXPORTS CompressedRectilinearWarper: public WarperCreator
194
{
195
    float a, b;
196
public:
197
    CompressedRectilinearWarper(float A = 1, float B = 1)
198
0
    {
199
0
        a = A; b = B;
200
0
    }
201
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CompressedRectilinearWarper>(scale, a, b); }
202
};
203
204
class CV_EXPORTS CompressedRectilinearPortraitWarper: public WarperCreator
205
{
206
    float a, b;
207
public:
208
    CompressedRectilinearPortraitWarper(float A = 1, float B = 1)
209
0
    {
210
0
        a = A; b = B;
211
0
    }
212
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CompressedRectilinearPortraitWarper>(scale, a, b); }
213
};
214
215
class CV_EXPORTS PaniniWarper: public WarperCreator
216
{
217
    float a, b;
218
public:
219
    PaniniWarper(float A = 1, float B = 1)
220
0
    {
221
0
        a = A; b = B;
222
0
    }
223
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PaniniWarper>(scale, a, b); }
224
};
225
226
class CV_EXPORTS PaniniPortraitWarper: public WarperCreator
227
{
228
    float a, b;
229
public:
230
    PaniniPortraitWarper(float A = 1, float B = 1)
231
0
    {
232
0
        a = A; b = B;
233
0
    }
234
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PaniniPortraitWarper>(scale, a, b); }
235
};
236
237
class CV_EXPORTS MercatorWarper: public WarperCreator
238
{
239
public:
240
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::MercatorWarper>(scale); }
241
};
242
243
class CV_EXPORTS TransverseMercatorWarper: public WarperCreator
244
{
245
public:
246
0
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::TransverseMercatorWarper>(scale); }
247
};
248
249
250
251
#ifdef HAVE_OPENCV_CUDAWARPING
252
class PlaneWarperGpu: public WarperCreator
253
{
254
public:
255
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarperGpu>(scale); }
256
};
257
258
259
class CylindricalWarperGpu: public WarperCreator
260
{
261
public:
262
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarperGpu>(scale); }
263
};
264
265
266
class SphericalWarperGpu: public WarperCreator
267
{
268
public:
269
    Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarperGpu>(scale); }
270
};
271
#endif
272
273
//! @} stitching_warp
274
275
} // namespace cv
276
277
#endif // OPENCV_STITCHING_WARPER_CREATORS_HPP