openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:0e0631af0305 1 /*M///////////////////////////////////////////////////////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2 //
RyoheiHagimoto 0:0e0631af0305 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
RyoheiHagimoto 0:0e0631af0305 4 //
RyoheiHagimoto 0:0e0631af0305 5 // By downloading, copying, installing or using the software you agree to this license.
RyoheiHagimoto 0:0e0631af0305 6 // If you do not agree to this license, do not download, install,
RyoheiHagimoto 0:0e0631af0305 7 // copy or use the software.
RyoheiHagimoto 0:0e0631af0305 8 //
RyoheiHagimoto 0:0e0631af0305 9 //
RyoheiHagimoto 0:0e0631af0305 10 // License Agreement
RyoheiHagimoto 0:0e0631af0305 11 // For Open Source Computer Vision Library
RyoheiHagimoto 0:0e0631af0305 12 //
RyoheiHagimoto 0:0e0631af0305 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 16 // Third party copyrights are property of their respective owners.
RyoheiHagimoto 0:0e0631af0305 17 //
RyoheiHagimoto 0:0e0631af0305 18 // Redistribution and use in source and binary forms, with or without modification,
RyoheiHagimoto 0:0e0631af0305 19 // are permitted provided that the following conditions are met:
RyoheiHagimoto 0:0e0631af0305 20 //
RyoheiHagimoto 0:0e0631af0305 21 // * Redistribution's of source code must retain the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 22 // this list of conditions and the following disclaimer.
RyoheiHagimoto 0:0e0631af0305 23 //
RyoheiHagimoto 0:0e0631af0305 24 // * Redistribution's in binary form must reproduce the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 25 // this list of conditions and the following disclaimer in the documentation
RyoheiHagimoto 0:0e0631af0305 26 // and/or other materials provided with the distribution.
RyoheiHagimoto 0:0e0631af0305 27 //
RyoheiHagimoto 0:0e0631af0305 28 // * The name of the copyright holders may not be used to endorse or promote products
RyoheiHagimoto 0:0e0631af0305 29 // derived from this software without specific prior written permission.
RyoheiHagimoto 0:0e0631af0305 30 //
RyoheiHagimoto 0:0e0631af0305 31 // This software is provided by the copyright holders and contributors "as is" and
RyoheiHagimoto 0:0e0631af0305 32 // any express or implied warranties, including, but not limited to, the implied
RyoheiHagimoto 0:0e0631af0305 33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
RyoheiHagimoto 0:0e0631af0305 34 // In no event shall the Intel Corporation or contributors be liable for any direct,
RyoheiHagimoto 0:0e0631af0305 35 // indirect, incidental, special, exemplary, or consequential damages
RyoheiHagimoto 0:0e0631af0305 36 // (including, but not limited to, procurement of substitute goods or services;
RyoheiHagimoto 0:0e0631af0305 37 // loss of use, data, or profits; or business interruption) however caused
RyoheiHagimoto 0:0e0631af0305 38 // and on any theory of liability, whether in contract, strict liability,
RyoheiHagimoto 0:0e0631af0305 39 // or tort (including negligence or otherwise) arising in any way out of
RyoheiHagimoto 0:0e0631af0305 40 // the use of this software, even if advised of the possibility of such damage.
RyoheiHagimoto 0:0e0631af0305 41 //
RyoheiHagimoto 0:0e0631af0305 42 //M*/
RyoheiHagimoto 0:0e0631af0305 43
RyoheiHagimoto 0:0e0631af0305 44 #ifndef OPENCV_CORE_TYPES_HPP
RyoheiHagimoto 0:0e0631af0305 45 #define OPENCV_CORE_TYPES_HPP
RyoheiHagimoto 0:0e0631af0305 46
RyoheiHagimoto 0:0e0631af0305 47 #ifndef __cplusplus
RyoheiHagimoto 0:0e0631af0305 48 # error types.hpp header must be compiled as C++
RyoheiHagimoto 0:0e0631af0305 49 #endif
RyoheiHagimoto 0:0e0631af0305 50
RyoheiHagimoto 0:0e0631af0305 51 #include <climits>
RyoheiHagimoto 0:0e0631af0305 52 #include <cfloat>
RyoheiHagimoto 0:0e0631af0305 53 #include <vector>
RyoheiHagimoto 0:0e0631af0305 54 #include <limits>
RyoheiHagimoto 0:0e0631af0305 55
RyoheiHagimoto 0:0e0631af0305 56 #include "opencv2/core/cvdef.h"
RyoheiHagimoto 0:0e0631af0305 57 #include "opencv2/core/cvstd.hpp"
RyoheiHagimoto 0:0e0631af0305 58 #include "opencv2/core/matx.hpp"
RyoheiHagimoto 0:0e0631af0305 59
RyoheiHagimoto 0:0e0631af0305 60 namespace cv
RyoheiHagimoto 0:0e0631af0305 61 {
RyoheiHagimoto 0:0e0631af0305 62
RyoheiHagimoto 0:0e0631af0305 63 //! @addtogroup core_basic
RyoheiHagimoto 0:0e0631af0305 64 //! @{
RyoheiHagimoto 0:0e0631af0305 65
RyoheiHagimoto 0:0e0631af0305 66 //////////////////////////////// Complex //////////////////////////////
RyoheiHagimoto 0:0e0631af0305 67
RyoheiHagimoto 0:0e0631af0305 68 /** @brief A complex number class.
RyoheiHagimoto 0:0e0631af0305 69
RyoheiHagimoto 0:0e0631af0305 70 The template class is similar and compatible with std::complex, however it provides slightly
RyoheiHagimoto 0:0e0631af0305 71 more convenient access to the real and imaginary parts using through the simple field access, as opposite
RyoheiHagimoto 0:0e0631af0305 72 to std::complex::real() and std::complex::imag().
RyoheiHagimoto 0:0e0631af0305 73 */
RyoheiHagimoto 0:0e0631af0305 74 template<typename _Tp> class Complex
RyoheiHagimoto 0:0e0631af0305 75 {
RyoheiHagimoto 0:0e0631af0305 76 public:
RyoheiHagimoto 0:0e0631af0305 77
RyoheiHagimoto 0:0e0631af0305 78 //! constructors
RyoheiHagimoto 0:0e0631af0305 79 Complex();
RyoheiHagimoto 0:0e0631af0305 80 Complex( _Tp _re, _Tp _im = 0 );
RyoheiHagimoto 0:0e0631af0305 81
RyoheiHagimoto 0:0e0631af0305 82 //! conversion to another data type
RyoheiHagimoto 0:0e0631af0305 83 template<typename T2> operator Complex<T2>() const;
RyoheiHagimoto 0:0e0631af0305 84 //! conjugation
RyoheiHagimoto 0:0e0631af0305 85 Complex conj() const;
RyoheiHagimoto 0:0e0631af0305 86
RyoheiHagimoto 0:0e0631af0305 87 _Tp re, im; //< the real and the imaginary parts
RyoheiHagimoto 0:0e0631af0305 88 };
RyoheiHagimoto 0:0e0631af0305 89
RyoheiHagimoto 0:0e0631af0305 90 typedef Complex<float> Complexf;
RyoheiHagimoto 0:0e0631af0305 91 typedef Complex<double> Complexd;
RyoheiHagimoto 0:0e0631af0305 92
RyoheiHagimoto 0:0e0631af0305 93 template<typename _Tp> class DataType< Complex<_Tp> >
RyoheiHagimoto 0:0e0631af0305 94 {
RyoheiHagimoto 0:0e0631af0305 95 public:
RyoheiHagimoto 0:0e0631af0305 96 typedef Complex<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 97 typedef value_type work_type;
RyoheiHagimoto 0:0e0631af0305 98 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 99
RyoheiHagimoto 0:0e0631af0305 100 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 101 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 102 channels = 2,
RyoheiHagimoto 0:0e0631af0305 103 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 104 type = CV_MAKETYPE(depth, channels) };
RyoheiHagimoto 0:0e0631af0305 105
RyoheiHagimoto 0:0e0631af0305 106 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 107 };
RyoheiHagimoto 0:0e0631af0305 108
RyoheiHagimoto 0:0e0631af0305 109
RyoheiHagimoto 0:0e0631af0305 110
RyoheiHagimoto 0:0e0631af0305 111 //////////////////////////////// Point_ ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 112
RyoheiHagimoto 0:0e0631af0305 113 /** @brief Template class for 2D points specified by its coordinates `x` and `y`.
RyoheiHagimoto 0:0e0631af0305 114
RyoheiHagimoto 0:0e0631af0305 115 An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is
RyoheiHagimoto 0:0e0631af0305 116 also a cast operator to convert point coordinates to the specified type. The conversion from
RyoheiHagimoto 0:0e0631af0305 117 floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion
RyoheiHagimoto 0:0e0631af0305 118 uses this operation for each of the coordinates. Besides the class members listed in the
RyoheiHagimoto 0:0e0631af0305 119 declaration above, the following operations on points are implemented:
RyoheiHagimoto 0:0e0631af0305 120 @code
RyoheiHagimoto 0:0e0631af0305 121 pt1 = pt2 + pt3;
RyoheiHagimoto 0:0e0631af0305 122 pt1 = pt2 - pt3;
RyoheiHagimoto 0:0e0631af0305 123 pt1 = pt2 * a;
RyoheiHagimoto 0:0e0631af0305 124 pt1 = a * pt2;
RyoheiHagimoto 0:0e0631af0305 125 pt1 = pt2 / a;
RyoheiHagimoto 0:0e0631af0305 126 pt1 += pt2;
RyoheiHagimoto 0:0e0631af0305 127 pt1 -= pt2;
RyoheiHagimoto 0:0e0631af0305 128 pt1 *= a;
RyoheiHagimoto 0:0e0631af0305 129 pt1 /= a;
RyoheiHagimoto 0:0e0631af0305 130 double value = norm(pt); // L2 norm
RyoheiHagimoto 0:0e0631af0305 131 pt1 == pt2;
RyoheiHagimoto 0:0e0631af0305 132 pt1 != pt2;
RyoheiHagimoto 0:0e0631af0305 133 @endcode
RyoheiHagimoto 0:0e0631af0305 134 For your convenience, the following type aliases are defined:
RyoheiHagimoto 0:0e0631af0305 135 @code
RyoheiHagimoto 0:0e0631af0305 136 typedef Point_<int> Point2i;
RyoheiHagimoto 0:0e0631af0305 137 typedef Point2i Point;
RyoheiHagimoto 0:0e0631af0305 138 typedef Point_<float> Point2f;
RyoheiHagimoto 0:0e0631af0305 139 typedef Point_<double> Point2d;
RyoheiHagimoto 0:0e0631af0305 140 @endcode
RyoheiHagimoto 0:0e0631af0305 141 Example:
RyoheiHagimoto 0:0e0631af0305 142 @code
RyoheiHagimoto 0:0e0631af0305 143 Point2f a(0.3f, 0.f), b(0.f, 0.4f);
RyoheiHagimoto 0:0e0631af0305 144 Point pt = (a + b)*10.f;
RyoheiHagimoto 0:0e0631af0305 145 cout << pt.x << ", " << pt.y << endl;
RyoheiHagimoto 0:0e0631af0305 146 @endcode
RyoheiHagimoto 0:0e0631af0305 147 */
RyoheiHagimoto 0:0e0631af0305 148 template<typename _Tp> class Point_
RyoheiHagimoto 0:0e0631af0305 149 {
RyoheiHagimoto 0:0e0631af0305 150 public:
RyoheiHagimoto 0:0e0631af0305 151 typedef _Tp value_type;
RyoheiHagimoto 0:0e0631af0305 152
RyoheiHagimoto 0:0e0631af0305 153 // various constructors
RyoheiHagimoto 0:0e0631af0305 154 Point_();
RyoheiHagimoto 0:0e0631af0305 155 Point_(_Tp _x, _Tp _y);
RyoheiHagimoto 0:0e0631af0305 156 Point_(const Point_& pt);
RyoheiHagimoto 0:0e0631af0305 157 Point_(const Size_<_Tp>& sz);
RyoheiHagimoto 0:0e0631af0305 158 Point_(const Vec<_Tp, 2>& v);
RyoheiHagimoto 0:0e0631af0305 159
RyoheiHagimoto 0:0e0631af0305 160 Point_& operator = (const Point_& pt);
RyoheiHagimoto 0:0e0631af0305 161 //! conversion to another data type
RyoheiHagimoto 0:0e0631af0305 162 template<typename _Tp2> operator Point_<_Tp2>() const;
RyoheiHagimoto 0:0e0631af0305 163
RyoheiHagimoto 0:0e0631af0305 164 //! conversion to the old-style C structures
RyoheiHagimoto 0:0e0631af0305 165 operator Vec<_Tp, 2>() const;
RyoheiHagimoto 0:0e0631af0305 166
RyoheiHagimoto 0:0e0631af0305 167 //! dot product
RyoheiHagimoto 0:0e0631af0305 168 _Tp dot(const Point_& pt) const;
RyoheiHagimoto 0:0e0631af0305 169 //! dot product computed in double-precision arithmetics
RyoheiHagimoto 0:0e0631af0305 170 double ddot(const Point_& pt) const;
RyoheiHagimoto 0:0e0631af0305 171 //! cross-product
RyoheiHagimoto 0:0e0631af0305 172 double cross(const Point_& pt) const;
RyoheiHagimoto 0:0e0631af0305 173 //! checks whether the point is inside the specified rectangle
RyoheiHagimoto 0:0e0631af0305 174 bool inside(const Rect_<_Tp>& r) const;
RyoheiHagimoto 0:0e0631af0305 175
RyoheiHagimoto 0:0e0631af0305 176 _Tp x, y; //< the point coordinates
RyoheiHagimoto 0:0e0631af0305 177 };
RyoheiHagimoto 0:0e0631af0305 178
RyoheiHagimoto 0:0e0631af0305 179 typedef Point_<int> Point2i;
RyoheiHagimoto 0:0e0631af0305 180 typedef Point_<int64> Point2l;
RyoheiHagimoto 0:0e0631af0305 181 typedef Point_<float> Point2f;
RyoheiHagimoto 0:0e0631af0305 182 typedef Point_<double> Point2d;
RyoheiHagimoto 0:0e0631af0305 183 typedef Point2i Point;
RyoheiHagimoto 0:0e0631af0305 184
RyoheiHagimoto 0:0e0631af0305 185 template<typename _Tp> class DataType< Point_<_Tp> >
RyoheiHagimoto 0:0e0631af0305 186 {
RyoheiHagimoto 0:0e0631af0305 187 public:
RyoheiHagimoto 0:0e0631af0305 188 typedef Point_<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 189 typedef Point_<typename DataType<_Tp>::work_type> work_type;
RyoheiHagimoto 0:0e0631af0305 190 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 191
RyoheiHagimoto 0:0e0631af0305 192 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 193 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 194 channels = 2,
RyoheiHagimoto 0:0e0631af0305 195 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 196 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 197 };
RyoheiHagimoto 0:0e0631af0305 198
RyoheiHagimoto 0:0e0631af0305 199 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 200 };
RyoheiHagimoto 0:0e0631af0305 201
RyoheiHagimoto 0:0e0631af0305 202
RyoheiHagimoto 0:0e0631af0305 203
RyoheiHagimoto 0:0e0631af0305 204 //////////////////////////////// Point3_ ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 205
RyoheiHagimoto 0:0e0631af0305 206 /** @brief Template class for 3D points specified by its coordinates `x`, `y` and `z`.
RyoheiHagimoto 0:0e0631af0305 207
RyoheiHagimoto 0:0e0631af0305 208 An instance of the class is interchangeable with the C structure CvPoint2D32f . Similarly to
RyoheiHagimoto 0:0e0631af0305 209 Point_ , the coordinates of 3D points can be converted to another type. The vector arithmetic and
RyoheiHagimoto 0:0e0631af0305 210 comparison operations are also supported.
RyoheiHagimoto 0:0e0631af0305 211
RyoheiHagimoto 0:0e0631af0305 212 The following Point3_\<\> aliases are available:
RyoheiHagimoto 0:0e0631af0305 213 @code
RyoheiHagimoto 0:0e0631af0305 214 typedef Point3_<int> Point3i;
RyoheiHagimoto 0:0e0631af0305 215 typedef Point3_<float> Point3f;
RyoheiHagimoto 0:0e0631af0305 216 typedef Point3_<double> Point3d;
RyoheiHagimoto 0:0e0631af0305 217 @endcode
RyoheiHagimoto 0:0e0631af0305 218 @see cv::Point3i, cv::Point3f and cv::Point3d
RyoheiHagimoto 0:0e0631af0305 219 */
RyoheiHagimoto 0:0e0631af0305 220 template<typename _Tp> class Point3_
RyoheiHagimoto 0:0e0631af0305 221 {
RyoheiHagimoto 0:0e0631af0305 222 public:
RyoheiHagimoto 0:0e0631af0305 223 typedef _Tp value_type;
RyoheiHagimoto 0:0e0631af0305 224
RyoheiHagimoto 0:0e0631af0305 225 // various constructors
RyoheiHagimoto 0:0e0631af0305 226 Point3_();
RyoheiHagimoto 0:0e0631af0305 227 Point3_(_Tp _x, _Tp _y, _Tp _z);
RyoheiHagimoto 0:0e0631af0305 228 Point3_(const Point3_& pt);
RyoheiHagimoto 0:0e0631af0305 229 explicit Point3_(const Point_<_Tp>& pt);
RyoheiHagimoto 0:0e0631af0305 230 Point3_(const Vec<_Tp, 3>& v);
RyoheiHagimoto 0:0e0631af0305 231
RyoheiHagimoto 0:0e0631af0305 232 Point3_& operator = (const Point3_& pt);
RyoheiHagimoto 0:0e0631af0305 233 //! conversion to another data type
RyoheiHagimoto 0:0e0631af0305 234 template<typename _Tp2> operator Point3_<_Tp2>() const;
RyoheiHagimoto 0:0e0631af0305 235 //! conversion to cv::Vec<>
RyoheiHagimoto 0:0e0631af0305 236 #if OPENCV_ABI_COMPATIBILITY > 300
RyoheiHagimoto 0:0e0631af0305 237 template<typename _Tp2> operator Vec<_Tp2, 3>() const;
RyoheiHagimoto 0:0e0631af0305 238 #else
RyoheiHagimoto 0:0e0631af0305 239 operator Vec<_Tp, 3>() const;
RyoheiHagimoto 0:0e0631af0305 240 #endif
RyoheiHagimoto 0:0e0631af0305 241
RyoheiHagimoto 0:0e0631af0305 242 //! dot product
RyoheiHagimoto 0:0e0631af0305 243 _Tp dot(const Point3_& pt) const;
RyoheiHagimoto 0:0e0631af0305 244 //! dot product computed in double-precision arithmetics
RyoheiHagimoto 0:0e0631af0305 245 double ddot(const Point3_& pt) const;
RyoheiHagimoto 0:0e0631af0305 246 //! cross product of the 2 3D points
RyoheiHagimoto 0:0e0631af0305 247 Point3_ cross(const Point3_& pt) const;
RyoheiHagimoto 0:0e0631af0305 248
RyoheiHagimoto 0:0e0631af0305 249 _Tp x, y, z; //< the point coordinates
RyoheiHagimoto 0:0e0631af0305 250 };
RyoheiHagimoto 0:0e0631af0305 251
RyoheiHagimoto 0:0e0631af0305 252 typedef Point3_<int> Point3i;
RyoheiHagimoto 0:0e0631af0305 253 typedef Point3_<float> Point3f;
RyoheiHagimoto 0:0e0631af0305 254 typedef Point3_<double> Point3d;
RyoheiHagimoto 0:0e0631af0305 255
RyoheiHagimoto 0:0e0631af0305 256 template<typename _Tp> class DataType< Point3_<_Tp> >
RyoheiHagimoto 0:0e0631af0305 257 {
RyoheiHagimoto 0:0e0631af0305 258 public:
RyoheiHagimoto 0:0e0631af0305 259 typedef Point3_<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 260 typedef Point3_<typename DataType<_Tp>::work_type> work_type;
RyoheiHagimoto 0:0e0631af0305 261 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 262
RyoheiHagimoto 0:0e0631af0305 263 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 264 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 265 channels = 3,
RyoheiHagimoto 0:0e0631af0305 266 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 267 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 268 };
RyoheiHagimoto 0:0e0631af0305 269
RyoheiHagimoto 0:0e0631af0305 270 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 271 };
RyoheiHagimoto 0:0e0631af0305 272
RyoheiHagimoto 0:0e0631af0305 273
RyoheiHagimoto 0:0e0631af0305 274
RyoheiHagimoto 0:0e0631af0305 275 //////////////////////////////// Size_ ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 276
RyoheiHagimoto 0:0e0631af0305 277 /** @brief Template class for specifying the size of an image or rectangle.
RyoheiHagimoto 0:0e0631af0305 278
RyoheiHagimoto 0:0e0631af0305 279 The class includes two members called width and height. The structure can be converted to and from
RyoheiHagimoto 0:0e0631af0305 280 the old OpenCV structures CvSize and CvSize2D32f . The same set of arithmetic and comparison
RyoheiHagimoto 0:0e0631af0305 281 operations as for Point_ is available.
RyoheiHagimoto 0:0e0631af0305 282
RyoheiHagimoto 0:0e0631af0305 283 OpenCV defines the following Size_\<\> aliases:
RyoheiHagimoto 0:0e0631af0305 284 @code
RyoheiHagimoto 0:0e0631af0305 285 typedef Size_<int> Size2i;
RyoheiHagimoto 0:0e0631af0305 286 typedef Size2i Size;
RyoheiHagimoto 0:0e0631af0305 287 typedef Size_<float> Size2f;
RyoheiHagimoto 0:0e0631af0305 288 @endcode
RyoheiHagimoto 0:0e0631af0305 289 */
RyoheiHagimoto 0:0e0631af0305 290 template<typename _Tp> class Size_
RyoheiHagimoto 0:0e0631af0305 291 {
RyoheiHagimoto 0:0e0631af0305 292 public:
RyoheiHagimoto 0:0e0631af0305 293 typedef _Tp value_type;
RyoheiHagimoto 0:0e0631af0305 294
RyoheiHagimoto 0:0e0631af0305 295 //! various constructors
RyoheiHagimoto 0:0e0631af0305 296 Size_();
RyoheiHagimoto 0:0e0631af0305 297 Size_(_Tp _width, _Tp _height);
RyoheiHagimoto 0:0e0631af0305 298 Size_(const Size_& sz);
RyoheiHagimoto 0:0e0631af0305 299 Size_(const Point_<_Tp>& pt);
RyoheiHagimoto 0:0e0631af0305 300
RyoheiHagimoto 0:0e0631af0305 301 Size_& operator = (const Size_& sz);
RyoheiHagimoto 0:0e0631af0305 302 //! the area (width*height)
RyoheiHagimoto 0:0e0631af0305 303 _Tp area() const;
RyoheiHagimoto 0:0e0631af0305 304
RyoheiHagimoto 0:0e0631af0305 305 //! conversion of another data type.
RyoheiHagimoto 0:0e0631af0305 306 template<typename _Tp2> operator Size_<_Tp2>() const;
RyoheiHagimoto 0:0e0631af0305 307
RyoheiHagimoto 0:0e0631af0305 308 _Tp width, height; // the width and the height
RyoheiHagimoto 0:0e0631af0305 309 };
RyoheiHagimoto 0:0e0631af0305 310
RyoheiHagimoto 0:0e0631af0305 311 typedef Size_<int> Size2i;
RyoheiHagimoto 0:0e0631af0305 312 typedef Size_<int64> Size2l;
RyoheiHagimoto 0:0e0631af0305 313 typedef Size_<float> Size2f;
RyoheiHagimoto 0:0e0631af0305 314 typedef Size_<double> Size2d;
RyoheiHagimoto 0:0e0631af0305 315 typedef Size2i Size;
RyoheiHagimoto 0:0e0631af0305 316
RyoheiHagimoto 0:0e0631af0305 317 template<typename _Tp> class DataType< Size_<_Tp> >
RyoheiHagimoto 0:0e0631af0305 318 {
RyoheiHagimoto 0:0e0631af0305 319 public:
RyoheiHagimoto 0:0e0631af0305 320 typedef Size_<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 321 typedef Size_<typename DataType<_Tp>::work_type> work_type;
RyoheiHagimoto 0:0e0631af0305 322 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 323
RyoheiHagimoto 0:0e0631af0305 324 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 325 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 326 channels = 2,
RyoheiHagimoto 0:0e0631af0305 327 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 328 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 329 };
RyoheiHagimoto 0:0e0631af0305 330
RyoheiHagimoto 0:0e0631af0305 331 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 332 };
RyoheiHagimoto 0:0e0631af0305 333
RyoheiHagimoto 0:0e0631af0305 334
RyoheiHagimoto 0:0e0631af0305 335
RyoheiHagimoto 0:0e0631af0305 336 //////////////////////////////// Rect_ ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 337
RyoheiHagimoto 0:0e0631af0305 338 /** @brief Template class for 2D rectangles
RyoheiHagimoto 0:0e0631af0305 339
RyoheiHagimoto 0:0e0631af0305 340 described by the following parameters:
RyoheiHagimoto 0:0e0631af0305 341 - Coordinates of the top-left corner. This is a default interpretation of Rect_::x and Rect_::y
RyoheiHagimoto 0:0e0631af0305 342 in OpenCV. Though, in your algorithms you may count x and y from the bottom-left corner.
RyoheiHagimoto 0:0e0631af0305 343 - Rectangle width and height.
RyoheiHagimoto 0:0e0631af0305 344
RyoheiHagimoto 0:0e0631af0305 345 OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the
RyoheiHagimoto 0:0e0631af0305 346 right and bottom boundaries are not. For example, the method Rect_::contains returns true if
RyoheiHagimoto 0:0e0631af0305 347
RyoheiHagimoto 0:0e0631af0305 348 \f[x \leq pt.x < x+width,
RyoheiHagimoto 0:0e0631af0305 349 y \leq pt.y < y+height\f]
RyoheiHagimoto 0:0e0631af0305 350
RyoheiHagimoto 0:0e0631af0305 351 Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_\<int\> ) is
RyoheiHagimoto 0:0e0631af0305 352 implemented as:
RyoheiHagimoto 0:0e0631af0305 353 @code
RyoheiHagimoto 0:0e0631af0305 354 for(int y = roi.y; y < roi.y + roi.height; y++)
RyoheiHagimoto 0:0e0631af0305 355 for(int x = roi.x; x < roi.x + roi.width; x++)
RyoheiHagimoto 0:0e0631af0305 356 {
RyoheiHagimoto 0:0e0631af0305 357 // ...
RyoheiHagimoto 0:0e0631af0305 358 }
RyoheiHagimoto 0:0e0631af0305 359 @endcode
RyoheiHagimoto 0:0e0631af0305 360 In addition to the class members, the following operations on rectangles are implemented:
RyoheiHagimoto 0:0e0631af0305 361 - \f$\texttt{rect} = \texttt{rect} \pm \texttt{point}\f$ (shifting a rectangle by a certain offset)
RyoheiHagimoto 0:0e0631af0305 362 - \f$\texttt{rect} = \texttt{rect} \pm \texttt{size}\f$ (expanding or shrinking a rectangle by a
RyoheiHagimoto 0:0e0631af0305 363 certain amount)
RyoheiHagimoto 0:0e0631af0305 364 - rect += point, rect -= point, rect += size, rect -= size (augmenting operations)
RyoheiHagimoto 0:0e0631af0305 365 - rect = rect1 & rect2 (rectangle intersection)
RyoheiHagimoto 0:0e0631af0305 366 - rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 )
RyoheiHagimoto 0:0e0631af0305 367 - rect &= rect1, rect |= rect1 (and the corresponding augmenting operations)
RyoheiHagimoto 0:0e0631af0305 368 - rect == rect1, rect != rect1 (rectangle comparison)
RyoheiHagimoto 0:0e0631af0305 369
RyoheiHagimoto 0:0e0631af0305 370 This is an example how the partial ordering on rectangles can be established (rect1 \f$\subseteq\f$
RyoheiHagimoto 0:0e0631af0305 371 rect2):
RyoheiHagimoto 0:0e0631af0305 372 @code
RyoheiHagimoto 0:0e0631af0305 373 template<typename _Tp> inline bool
RyoheiHagimoto 0:0e0631af0305 374 operator <= (const Rect_<_Tp>& r1, const Rect_<_Tp>& r2)
RyoheiHagimoto 0:0e0631af0305 375 {
RyoheiHagimoto 0:0e0631af0305 376 return (r1 & r2) == r1;
RyoheiHagimoto 0:0e0631af0305 377 }
RyoheiHagimoto 0:0e0631af0305 378 @endcode
RyoheiHagimoto 0:0e0631af0305 379 For your convenience, the Rect_\<\> alias is available: cv::Rect
RyoheiHagimoto 0:0e0631af0305 380 */
RyoheiHagimoto 0:0e0631af0305 381 template<typename _Tp> class Rect_
RyoheiHagimoto 0:0e0631af0305 382 {
RyoheiHagimoto 0:0e0631af0305 383 public:
RyoheiHagimoto 0:0e0631af0305 384 typedef _Tp value_type;
RyoheiHagimoto 0:0e0631af0305 385
RyoheiHagimoto 0:0e0631af0305 386 //! various constructors
RyoheiHagimoto 0:0e0631af0305 387 Rect_();
RyoheiHagimoto 0:0e0631af0305 388 Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
RyoheiHagimoto 0:0e0631af0305 389 Rect_(const Rect_& r);
RyoheiHagimoto 0:0e0631af0305 390 Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz);
RyoheiHagimoto 0:0e0631af0305 391 Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2);
RyoheiHagimoto 0:0e0631af0305 392
RyoheiHagimoto 0:0e0631af0305 393 Rect_& operator = ( const Rect_& r );
RyoheiHagimoto 0:0e0631af0305 394 //! the top-left corner
RyoheiHagimoto 0:0e0631af0305 395 Point_<_Tp> tl() const;
RyoheiHagimoto 0:0e0631af0305 396 //! the bottom-right corner
RyoheiHagimoto 0:0e0631af0305 397 Point_<_Tp> br() const;
RyoheiHagimoto 0:0e0631af0305 398
RyoheiHagimoto 0:0e0631af0305 399 //! size (width, height) of the rectangle
RyoheiHagimoto 0:0e0631af0305 400 Size_<_Tp> size() const;
RyoheiHagimoto 0:0e0631af0305 401 //! area (width*height) of the rectangle
RyoheiHagimoto 0:0e0631af0305 402 _Tp area() const;
RyoheiHagimoto 0:0e0631af0305 403
RyoheiHagimoto 0:0e0631af0305 404 //! conversion to another data type
RyoheiHagimoto 0:0e0631af0305 405 template<typename _Tp2> operator Rect_<_Tp2>() const;
RyoheiHagimoto 0:0e0631af0305 406
RyoheiHagimoto 0:0e0631af0305 407 //! checks whether the rectangle contains the point
RyoheiHagimoto 0:0e0631af0305 408 bool contains(const Point_<_Tp>& pt) const;
RyoheiHagimoto 0:0e0631af0305 409
RyoheiHagimoto 0:0e0631af0305 410 _Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle
RyoheiHagimoto 0:0e0631af0305 411 };
RyoheiHagimoto 0:0e0631af0305 412
RyoheiHagimoto 0:0e0631af0305 413 typedef Rect_<int> Rect2i;
RyoheiHagimoto 0:0e0631af0305 414 typedef Rect_<float> Rect2f;
RyoheiHagimoto 0:0e0631af0305 415 typedef Rect_<double> Rect2d;
RyoheiHagimoto 0:0e0631af0305 416 typedef Rect2i Rect;
RyoheiHagimoto 0:0e0631af0305 417
RyoheiHagimoto 0:0e0631af0305 418 template<typename _Tp> class DataType< Rect_<_Tp> >
RyoheiHagimoto 0:0e0631af0305 419 {
RyoheiHagimoto 0:0e0631af0305 420 public:
RyoheiHagimoto 0:0e0631af0305 421 typedef Rect_<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 422 typedef Rect_<typename DataType<_Tp>::work_type> work_type;
RyoheiHagimoto 0:0e0631af0305 423 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 424
RyoheiHagimoto 0:0e0631af0305 425 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 426 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 427 channels = 4,
RyoheiHagimoto 0:0e0631af0305 428 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 429 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 430 };
RyoheiHagimoto 0:0e0631af0305 431
RyoheiHagimoto 0:0e0631af0305 432 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 433 };
RyoheiHagimoto 0:0e0631af0305 434
RyoheiHagimoto 0:0e0631af0305 435
RyoheiHagimoto 0:0e0631af0305 436
RyoheiHagimoto 0:0e0631af0305 437 ///////////////////////////// RotatedRect /////////////////////////////
RyoheiHagimoto 0:0e0631af0305 438
RyoheiHagimoto 0:0e0631af0305 439 /** @brief The class represents rotated (i.e. not up-right) rectangles on a plane.
RyoheiHagimoto 0:0e0631af0305 440
RyoheiHagimoto 0:0e0631af0305 441 Each rectangle is specified by the center point (mass center), length of each side (represented by
RyoheiHagimoto 0:0e0631af0305 442 cv::Size2f structure) and the rotation angle in degrees.
RyoheiHagimoto 0:0e0631af0305 443
RyoheiHagimoto 0:0e0631af0305 444 The sample below demonstrates how to use RotatedRect:
RyoheiHagimoto 0:0e0631af0305 445 @code
RyoheiHagimoto 0:0e0631af0305 446 Mat image(200, 200, CV_8UC3, Scalar(0));
RyoheiHagimoto 0:0e0631af0305 447 RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30);
RyoheiHagimoto 0:0e0631af0305 448
RyoheiHagimoto 0:0e0631af0305 449 Point2f vertices[4];
RyoheiHagimoto 0:0e0631af0305 450 rRect.points(vertices);
RyoheiHagimoto 0:0e0631af0305 451 for (int i = 0; i < 4; i++)
RyoheiHagimoto 0:0e0631af0305 452 line(image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0));
RyoheiHagimoto 0:0e0631af0305 453
RyoheiHagimoto 0:0e0631af0305 454 Rect brect = rRect.boundingRect();
RyoheiHagimoto 0:0e0631af0305 455 rectangle(image, brect, Scalar(255,0,0));
RyoheiHagimoto 0:0e0631af0305 456
RyoheiHagimoto 0:0e0631af0305 457 imshow("rectangles", image);
RyoheiHagimoto 0:0e0631af0305 458 waitKey(0);
RyoheiHagimoto 0:0e0631af0305 459 @endcode
RyoheiHagimoto 0:0e0631af0305 460 ![image](pics/rotatedrect.png)
RyoheiHagimoto 0:0e0631af0305 461
RyoheiHagimoto 0:0e0631af0305 462 @sa CamShift, fitEllipse, minAreaRect, CvBox2D
RyoheiHagimoto 0:0e0631af0305 463 */
RyoheiHagimoto 0:0e0631af0305 464 class CV_EXPORTS RotatedRect
RyoheiHagimoto 0:0e0631af0305 465 {
RyoheiHagimoto 0:0e0631af0305 466 public:
RyoheiHagimoto 0:0e0631af0305 467 //! various constructors
RyoheiHagimoto 0:0e0631af0305 468 RotatedRect();
RyoheiHagimoto 0:0e0631af0305 469 /**
RyoheiHagimoto 0:0e0631af0305 470 @param center The rectangle mass center.
RyoheiHagimoto 0:0e0631af0305 471 @param size Width and height of the rectangle.
RyoheiHagimoto 0:0e0631af0305 472 @param angle The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc.,
RyoheiHagimoto 0:0e0631af0305 473 the rectangle becomes an up-right rectangle.
RyoheiHagimoto 0:0e0631af0305 474 */
RyoheiHagimoto 0:0e0631af0305 475 RotatedRect(const Point2f& center, const Size2f& size, float angle);
RyoheiHagimoto 0:0e0631af0305 476 /**
RyoheiHagimoto 0:0e0631af0305 477 Any 3 end points of the RotatedRect. They must be given in order (either clockwise or
RyoheiHagimoto 0:0e0631af0305 478 anticlockwise).
RyoheiHagimoto 0:0e0631af0305 479 */
RyoheiHagimoto 0:0e0631af0305 480 RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3);
RyoheiHagimoto 0:0e0631af0305 481
RyoheiHagimoto 0:0e0631af0305 482 /** returns 4 vertices of the rectangle
RyoheiHagimoto 0:0e0631af0305 483 @param pts The points array for storing rectangle vertices.
RyoheiHagimoto 0:0e0631af0305 484 */
RyoheiHagimoto 0:0e0631af0305 485 void points(Point2f pts[]) const;
RyoheiHagimoto 0:0e0631af0305 486 //! returns the minimal up-right integer rectangle containing the rotated rectangle
RyoheiHagimoto 0:0e0631af0305 487 Rect boundingRect() const;
RyoheiHagimoto 0:0e0631af0305 488 //! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images
RyoheiHagimoto 0:0e0631af0305 489 Rect_<float> boundingRect2f() const;
RyoheiHagimoto 0:0e0631af0305 490
RyoheiHagimoto 0:0e0631af0305 491 Point2f center; //< the rectangle mass center
RyoheiHagimoto 0:0e0631af0305 492 Size2f size; //< width and height of the rectangle
RyoheiHagimoto 0:0e0631af0305 493 float angle; //< the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
RyoheiHagimoto 0:0e0631af0305 494 };
RyoheiHagimoto 0:0e0631af0305 495
RyoheiHagimoto 0:0e0631af0305 496 template<> class DataType< RotatedRect >
RyoheiHagimoto 0:0e0631af0305 497 {
RyoheiHagimoto 0:0e0631af0305 498 public:
RyoheiHagimoto 0:0e0631af0305 499 typedef RotatedRect value_type;
RyoheiHagimoto 0:0e0631af0305 500 typedef value_type work_type;
RyoheiHagimoto 0:0e0631af0305 501 typedef float channel_type;
RyoheiHagimoto 0:0e0631af0305 502
RyoheiHagimoto 0:0e0631af0305 503 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 504 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 505 channels = (int)sizeof(value_type)/sizeof(channel_type), // 5
RyoheiHagimoto 0:0e0631af0305 506 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 507 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 508 };
RyoheiHagimoto 0:0e0631af0305 509
RyoheiHagimoto 0:0e0631af0305 510 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 511 };
RyoheiHagimoto 0:0e0631af0305 512
RyoheiHagimoto 0:0e0631af0305 513
RyoheiHagimoto 0:0e0631af0305 514
RyoheiHagimoto 0:0e0631af0305 515 //////////////////////////////// Range /////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 516
RyoheiHagimoto 0:0e0631af0305 517 /** @brief Template class specifying a continuous subsequence (slice) of a sequence.
RyoheiHagimoto 0:0e0631af0305 518
RyoheiHagimoto 0:0e0631af0305 519 The class is used to specify a row or a column span in a matrix ( Mat ) and for many other purposes.
RyoheiHagimoto 0:0e0631af0305 520 Range(a,b) is basically the same as a:b in Matlab or a..b in Python. As in Python, start is an
RyoheiHagimoto 0:0e0631af0305 521 inclusive left boundary of the range and end is an exclusive right boundary of the range. Such a
RyoheiHagimoto 0:0e0631af0305 522 half-opened interval is usually denoted as \f$[start,end)\f$ .
RyoheiHagimoto 0:0e0631af0305 523
RyoheiHagimoto 0:0e0631af0305 524 The static method Range::all() returns a special variable that means "the whole sequence" or "the
RyoheiHagimoto 0:0e0631af0305 525 whole range", just like " : " in Matlab or " ... " in Python. All the methods and functions in
RyoheiHagimoto 0:0e0631af0305 526 OpenCV that take Range support this special Range::all() value. But, of course, in case of your own
RyoheiHagimoto 0:0e0631af0305 527 custom processing, you will probably have to check and handle it explicitly:
RyoheiHagimoto 0:0e0631af0305 528 @code
RyoheiHagimoto 0:0e0631af0305 529 void my_function(..., const Range& r, ....)
RyoheiHagimoto 0:0e0631af0305 530 {
RyoheiHagimoto 0:0e0631af0305 531 if(r == Range::all()) {
RyoheiHagimoto 0:0e0631af0305 532 // process all the data
RyoheiHagimoto 0:0e0631af0305 533 }
RyoheiHagimoto 0:0e0631af0305 534 else {
RyoheiHagimoto 0:0e0631af0305 535 // process [r.start, r.end)
RyoheiHagimoto 0:0e0631af0305 536 }
RyoheiHagimoto 0:0e0631af0305 537 }
RyoheiHagimoto 0:0e0631af0305 538 @endcode
RyoheiHagimoto 0:0e0631af0305 539 */
RyoheiHagimoto 0:0e0631af0305 540 class CV_EXPORTS Range
RyoheiHagimoto 0:0e0631af0305 541 {
RyoheiHagimoto 0:0e0631af0305 542 public:
RyoheiHagimoto 0:0e0631af0305 543 Range();
RyoheiHagimoto 0:0e0631af0305 544 Range(int _start, int _end);
RyoheiHagimoto 0:0e0631af0305 545 int size() const;
RyoheiHagimoto 0:0e0631af0305 546 bool empty() const;
RyoheiHagimoto 0:0e0631af0305 547 static Range all();
RyoheiHagimoto 0:0e0631af0305 548
RyoheiHagimoto 0:0e0631af0305 549 int start, end;
RyoheiHagimoto 0:0e0631af0305 550 };
RyoheiHagimoto 0:0e0631af0305 551
RyoheiHagimoto 0:0e0631af0305 552 template<> class DataType<Range>
RyoheiHagimoto 0:0e0631af0305 553 {
RyoheiHagimoto 0:0e0631af0305 554 public:
RyoheiHagimoto 0:0e0631af0305 555 typedef Range value_type;
RyoheiHagimoto 0:0e0631af0305 556 typedef value_type work_type;
RyoheiHagimoto 0:0e0631af0305 557 typedef int channel_type;
RyoheiHagimoto 0:0e0631af0305 558
RyoheiHagimoto 0:0e0631af0305 559 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 560 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 561 channels = 2,
RyoheiHagimoto 0:0e0631af0305 562 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 563 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 564 };
RyoheiHagimoto 0:0e0631af0305 565
RyoheiHagimoto 0:0e0631af0305 566 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 567 };
RyoheiHagimoto 0:0e0631af0305 568
RyoheiHagimoto 0:0e0631af0305 569
RyoheiHagimoto 0:0e0631af0305 570
RyoheiHagimoto 0:0e0631af0305 571 //////////////////////////////// Scalar_ ///////////////////////////////
RyoheiHagimoto 0:0e0631af0305 572
RyoheiHagimoto 0:0e0631af0305 573 /** @brief Template class for a 4-element vector derived from Vec.
RyoheiHagimoto 0:0e0631af0305 574
RyoheiHagimoto 0:0e0631af0305 575 Being derived from Vec\<_Tp, 4\> , Scalar_ and Scalar can be used just as typical 4-element
RyoheiHagimoto 0:0e0631af0305 576 vectors. In addition, they can be converted to/from CvScalar . The type Scalar is widely used in
RyoheiHagimoto 0:0e0631af0305 577 OpenCV to pass pixel values.
RyoheiHagimoto 0:0e0631af0305 578 */
RyoheiHagimoto 0:0e0631af0305 579 template<typename _Tp> class Scalar_ : public Vec<_Tp, 4>
RyoheiHagimoto 0:0e0631af0305 580 {
RyoheiHagimoto 0:0e0631af0305 581 public:
RyoheiHagimoto 0:0e0631af0305 582 //! various constructors
RyoheiHagimoto 0:0e0631af0305 583 Scalar_();
RyoheiHagimoto 0:0e0631af0305 584 Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0);
RyoheiHagimoto 0:0e0631af0305 585 Scalar_(_Tp v0);
RyoheiHagimoto 0:0e0631af0305 586
RyoheiHagimoto 0:0e0631af0305 587 template<typename _Tp2, int cn>
RyoheiHagimoto 0:0e0631af0305 588 Scalar_(const Vec<_Tp2, cn>& v);
RyoheiHagimoto 0:0e0631af0305 589
RyoheiHagimoto 0:0e0631af0305 590 //! returns a scalar with all elements set to v0
RyoheiHagimoto 0:0e0631af0305 591 static Scalar_<_Tp> all(_Tp v0);
RyoheiHagimoto 0:0e0631af0305 592
RyoheiHagimoto 0:0e0631af0305 593 //! conversion to another data type
RyoheiHagimoto 0:0e0631af0305 594 template<typename T2> operator Scalar_<T2>() const;
RyoheiHagimoto 0:0e0631af0305 595
RyoheiHagimoto 0:0e0631af0305 596 //! per-element product
RyoheiHagimoto 0:0e0631af0305 597 Scalar_<_Tp> mul(const Scalar_<_Tp>& a, double scale=1 ) const;
RyoheiHagimoto 0:0e0631af0305 598
RyoheiHagimoto 0:0e0631af0305 599 // returns (v0, -v1, -v2, -v3)
RyoheiHagimoto 0:0e0631af0305 600 Scalar_<_Tp> conj() const;
RyoheiHagimoto 0:0e0631af0305 601
RyoheiHagimoto 0:0e0631af0305 602 // returns true iff v1 == v2 == v3 == 0
RyoheiHagimoto 0:0e0631af0305 603 bool isReal() const;
RyoheiHagimoto 0:0e0631af0305 604 };
RyoheiHagimoto 0:0e0631af0305 605
RyoheiHagimoto 0:0e0631af0305 606 typedef Scalar_<double> Scalar;
RyoheiHagimoto 0:0e0631af0305 607
RyoheiHagimoto 0:0e0631af0305 608 template<typename _Tp> class DataType< Scalar_<_Tp> >
RyoheiHagimoto 0:0e0631af0305 609 {
RyoheiHagimoto 0:0e0631af0305 610 public:
RyoheiHagimoto 0:0e0631af0305 611 typedef Scalar_<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 612 typedef Scalar_<typename DataType<_Tp>::work_type> work_type;
RyoheiHagimoto 0:0e0631af0305 613 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 614
RyoheiHagimoto 0:0e0631af0305 615 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 616 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 617 channels = 4,
RyoheiHagimoto 0:0e0631af0305 618 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 619 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 620 };
RyoheiHagimoto 0:0e0631af0305 621
RyoheiHagimoto 0:0e0631af0305 622 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 623 };
RyoheiHagimoto 0:0e0631af0305 624
RyoheiHagimoto 0:0e0631af0305 625
RyoheiHagimoto 0:0e0631af0305 626
RyoheiHagimoto 0:0e0631af0305 627 /////////////////////////////// KeyPoint ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 628
RyoheiHagimoto 0:0e0631af0305 629 /** @brief Data structure for salient point detectors.
RyoheiHagimoto 0:0e0631af0305 630
RyoheiHagimoto 0:0e0631af0305 631 The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint
RyoheiHagimoto 0:0e0631af0305 632 detectors, such as Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT,
RyoheiHagimoto 0:0e0631af0305 633 cv::LDetector etc.
RyoheiHagimoto 0:0e0631af0305 634
RyoheiHagimoto 0:0e0631af0305 635 The keypoint is characterized by the 2D position, scale (proportional to the diameter of the
RyoheiHagimoto 0:0e0631af0305 636 neighborhood that needs to be taken into account), orientation and some other parameters. The
RyoheiHagimoto 0:0e0631af0305 637 keypoint neighborhood is then analyzed by another algorithm that builds a descriptor (usually
RyoheiHagimoto 0:0e0631af0305 638 represented as a feature vector). The keypoints representing the same object in different images
RyoheiHagimoto 0:0e0631af0305 639 can then be matched using cv::KDTree or another method.
RyoheiHagimoto 0:0e0631af0305 640 */
RyoheiHagimoto 0:0e0631af0305 641 class CV_EXPORTS_W_SIMPLE KeyPoint
RyoheiHagimoto 0:0e0631af0305 642 {
RyoheiHagimoto 0:0e0631af0305 643 public:
RyoheiHagimoto 0:0e0631af0305 644 //! the default constructor
RyoheiHagimoto 0:0e0631af0305 645 CV_WRAP KeyPoint();
RyoheiHagimoto 0:0e0631af0305 646 /**
RyoheiHagimoto 0:0e0631af0305 647 @param _pt x & y coordinates of the keypoint
RyoheiHagimoto 0:0e0631af0305 648 @param _size keypoint diameter
RyoheiHagimoto 0:0e0631af0305 649 @param _angle keypoint orientation
RyoheiHagimoto 0:0e0631af0305 650 @param _response keypoint detector response on the keypoint (that is, strength of the keypoint)
RyoheiHagimoto 0:0e0631af0305 651 @param _octave pyramid octave in which the keypoint has been detected
RyoheiHagimoto 0:0e0631af0305 652 @param _class_id object id
RyoheiHagimoto 0:0e0631af0305 653 */
RyoheiHagimoto 0:0e0631af0305 654 KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1);
RyoheiHagimoto 0:0e0631af0305 655 /**
RyoheiHagimoto 0:0e0631af0305 656 @param x x-coordinate of the keypoint
RyoheiHagimoto 0:0e0631af0305 657 @param y y-coordinate of the keypoint
RyoheiHagimoto 0:0e0631af0305 658 @param _size keypoint diameter
RyoheiHagimoto 0:0e0631af0305 659 @param _angle keypoint orientation
RyoheiHagimoto 0:0e0631af0305 660 @param _response keypoint detector response on the keypoint (that is, strength of the keypoint)
RyoheiHagimoto 0:0e0631af0305 661 @param _octave pyramid octave in which the keypoint has been detected
RyoheiHagimoto 0:0e0631af0305 662 @param _class_id object id
RyoheiHagimoto 0:0e0631af0305 663 */
RyoheiHagimoto 0:0e0631af0305 664 CV_WRAP KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1);
RyoheiHagimoto 0:0e0631af0305 665
RyoheiHagimoto 0:0e0631af0305 666 size_t hash() const;
RyoheiHagimoto 0:0e0631af0305 667
RyoheiHagimoto 0:0e0631af0305 668 /**
RyoheiHagimoto 0:0e0631af0305 669 This method converts vector of keypoints to vector of points or the reverse, where each keypoint is
RyoheiHagimoto 0:0e0631af0305 670 assigned the same size and the same orientation.
RyoheiHagimoto 0:0e0631af0305 671
RyoheiHagimoto 0:0e0631af0305 672 @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB
RyoheiHagimoto 0:0e0631af0305 673 @param points2f Array of (x,y) coordinates of each keypoint
RyoheiHagimoto 0:0e0631af0305 674 @param keypointIndexes Array of indexes of keypoints to be converted to points. (Acts like a mask to
RyoheiHagimoto 0:0e0631af0305 675 convert only specified keypoints)
RyoheiHagimoto 0:0e0631af0305 676 */
RyoheiHagimoto 0:0e0631af0305 677 CV_WRAP static void convert(const std::vector<KeyPoint>& keypoints,
RyoheiHagimoto 0:0e0631af0305 678 CV_OUT std::vector<Point2f>& points2f,
RyoheiHagimoto 0:0e0631af0305 679 const std::vector<int>& keypointIndexes=std::vector<int>());
RyoheiHagimoto 0:0e0631af0305 680 /** @overload
RyoheiHagimoto 0:0e0631af0305 681 @param points2f Array of (x,y) coordinates of each keypoint
RyoheiHagimoto 0:0e0631af0305 682 @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB
RyoheiHagimoto 0:0e0631af0305 683 @param size keypoint diameter
RyoheiHagimoto 0:0e0631af0305 684 @param response keypoint detector response on the keypoint (that is, strength of the keypoint)
RyoheiHagimoto 0:0e0631af0305 685 @param octave pyramid octave in which the keypoint has been detected
RyoheiHagimoto 0:0e0631af0305 686 @param class_id object id
RyoheiHagimoto 0:0e0631af0305 687 */
RyoheiHagimoto 0:0e0631af0305 688 CV_WRAP static void convert(const std::vector<Point2f>& points2f,
RyoheiHagimoto 0:0e0631af0305 689 CV_OUT std::vector<KeyPoint>& keypoints,
RyoheiHagimoto 0:0e0631af0305 690 float size=1, float response=1, int octave=0, int class_id=-1);
RyoheiHagimoto 0:0e0631af0305 691
RyoheiHagimoto 0:0e0631af0305 692 /**
RyoheiHagimoto 0:0e0631af0305 693 This method computes overlap for pair of keypoints. Overlap is the ratio between area of keypoint
RyoheiHagimoto 0:0e0631af0305 694 regions' intersection and area of keypoint regions' union (considering keypoint region as circle).
RyoheiHagimoto 0:0e0631af0305 695 If they don't overlap, we get zero. If they coincide at same location with same size, we get 1.
RyoheiHagimoto 0:0e0631af0305 696 @param kp1 First keypoint
RyoheiHagimoto 0:0e0631af0305 697 @param kp2 Second keypoint
RyoheiHagimoto 0:0e0631af0305 698 */
RyoheiHagimoto 0:0e0631af0305 699 CV_WRAP static float overlap(const KeyPoint& kp1, const KeyPoint& kp2);
RyoheiHagimoto 0:0e0631af0305 700
RyoheiHagimoto 0:0e0631af0305 701 CV_PROP_RW Point2f pt; //!< coordinates of the keypoints
RyoheiHagimoto 0:0e0631af0305 702 CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood
RyoheiHagimoto 0:0e0631af0305 703 CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable);
RyoheiHagimoto 0:0e0631af0305 704 //!< it's in [0,360) degrees and measured relative to
RyoheiHagimoto 0:0e0631af0305 705 //!< image coordinate system, ie in clockwise.
RyoheiHagimoto 0:0e0631af0305 706 CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
RyoheiHagimoto 0:0e0631af0305 707 CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted
RyoheiHagimoto 0:0e0631af0305 708 CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to)
RyoheiHagimoto 0:0e0631af0305 709 };
RyoheiHagimoto 0:0e0631af0305 710
RyoheiHagimoto 0:0e0631af0305 711 template<> class DataType<KeyPoint>
RyoheiHagimoto 0:0e0631af0305 712 {
RyoheiHagimoto 0:0e0631af0305 713 public:
RyoheiHagimoto 0:0e0631af0305 714 typedef KeyPoint value_type;
RyoheiHagimoto 0:0e0631af0305 715 typedef float work_type;
RyoheiHagimoto 0:0e0631af0305 716 typedef float channel_type;
RyoheiHagimoto 0:0e0631af0305 717
RyoheiHagimoto 0:0e0631af0305 718 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 719 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 720 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7
RyoheiHagimoto 0:0e0631af0305 721 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 722 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 723 };
RyoheiHagimoto 0:0e0631af0305 724
RyoheiHagimoto 0:0e0631af0305 725 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 726 };
RyoheiHagimoto 0:0e0631af0305 727
RyoheiHagimoto 0:0e0631af0305 728
RyoheiHagimoto 0:0e0631af0305 729
RyoheiHagimoto 0:0e0631af0305 730 //////////////////////////////// DMatch /////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 731
RyoheiHagimoto 0:0e0631af0305 732 /** @brief Class for matching keypoint descriptors
RyoheiHagimoto 0:0e0631af0305 733
RyoheiHagimoto 0:0e0631af0305 734 query descriptor index, train descriptor index, train image index, and distance between
RyoheiHagimoto 0:0e0631af0305 735 descriptors.
RyoheiHagimoto 0:0e0631af0305 736 */
RyoheiHagimoto 0:0e0631af0305 737 class CV_EXPORTS_W_SIMPLE DMatch
RyoheiHagimoto 0:0e0631af0305 738 {
RyoheiHagimoto 0:0e0631af0305 739 public:
RyoheiHagimoto 0:0e0631af0305 740 CV_WRAP DMatch();
RyoheiHagimoto 0:0e0631af0305 741 CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance);
RyoheiHagimoto 0:0e0631af0305 742 CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance);
RyoheiHagimoto 0:0e0631af0305 743
RyoheiHagimoto 0:0e0631af0305 744 CV_PROP_RW int queryIdx; // query descriptor index
RyoheiHagimoto 0:0e0631af0305 745 CV_PROP_RW int trainIdx; // train descriptor index
RyoheiHagimoto 0:0e0631af0305 746 CV_PROP_RW int imgIdx; // train image index
RyoheiHagimoto 0:0e0631af0305 747
RyoheiHagimoto 0:0e0631af0305 748 CV_PROP_RW float distance;
RyoheiHagimoto 0:0e0631af0305 749
RyoheiHagimoto 0:0e0631af0305 750 // less is better
RyoheiHagimoto 0:0e0631af0305 751 bool operator<(const DMatch &m) const;
RyoheiHagimoto 0:0e0631af0305 752 };
RyoheiHagimoto 0:0e0631af0305 753
RyoheiHagimoto 0:0e0631af0305 754 template<> class DataType<DMatch>
RyoheiHagimoto 0:0e0631af0305 755 {
RyoheiHagimoto 0:0e0631af0305 756 public:
RyoheiHagimoto 0:0e0631af0305 757 typedef DMatch value_type;
RyoheiHagimoto 0:0e0631af0305 758 typedef int work_type;
RyoheiHagimoto 0:0e0631af0305 759 typedef int channel_type;
RyoheiHagimoto 0:0e0631af0305 760
RyoheiHagimoto 0:0e0631af0305 761 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 762 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 763 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4
RyoheiHagimoto 0:0e0631af0305 764 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 765 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 766 };
RyoheiHagimoto 0:0e0631af0305 767
RyoheiHagimoto 0:0e0631af0305 768 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 769 };
RyoheiHagimoto 0:0e0631af0305 770
RyoheiHagimoto 0:0e0631af0305 771
RyoheiHagimoto 0:0e0631af0305 772
RyoheiHagimoto 0:0e0631af0305 773 ///////////////////////////// TermCriteria //////////////////////////////
RyoheiHagimoto 0:0e0631af0305 774
RyoheiHagimoto 0:0e0631af0305 775 /** @brief The class defining termination criteria for iterative algorithms.
RyoheiHagimoto 0:0e0631af0305 776
RyoheiHagimoto 0:0e0631af0305 777 You can initialize it by default constructor and then override any parameters, or the structure may
RyoheiHagimoto 0:0e0631af0305 778 be fully initialized using the advanced variant of the constructor.
RyoheiHagimoto 0:0e0631af0305 779 */
RyoheiHagimoto 0:0e0631af0305 780 class CV_EXPORTS TermCriteria
RyoheiHagimoto 0:0e0631af0305 781 {
RyoheiHagimoto 0:0e0631af0305 782 public:
RyoheiHagimoto 0:0e0631af0305 783 /**
RyoheiHagimoto 0:0e0631af0305 784 Criteria type, can be one of: COUNT, EPS or COUNT + EPS
RyoheiHagimoto 0:0e0631af0305 785 */
RyoheiHagimoto 0:0e0631af0305 786 enum Type
RyoheiHagimoto 0:0e0631af0305 787 {
RyoheiHagimoto 0:0e0631af0305 788 COUNT=1, //!< the maximum number of iterations or elements to compute
RyoheiHagimoto 0:0e0631af0305 789 MAX_ITER=COUNT, //!< ditto
RyoheiHagimoto 0:0e0631af0305 790 EPS=2 //!< the desired accuracy or change in parameters at which the iterative algorithm stops
RyoheiHagimoto 0:0e0631af0305 791 };
RyoheiHagimoto 0:0e0631af0305 792
RyoheiHagimoto 0:0e0631af0305 793 //! default constructor
RyoheiHagimoto 0:0e0631af0305 794 TermCriteria();
RyoheiHagimoto 0:0e0631af0305 795 /**
RyoheiHagimoto 0:0e0631af0305 796 @param type The type of termination criteria, one of TermCriteria::Type
RyoheiHagimoto 0:0e0631af0305 797 @param maxCount The maximum number of iterations or elements to compute.
RyoheiHagimoto 0:0e0631af0305 798 @param epsilon The desired accuracy or change in parameters at which the iterative algorithm stops.
RyoheiHagimoto 0:0e0631af0305 799 */
RyoheiHagimoto 0:0e0631af0305 800 TermCriteria(int type, int maxCount, double epsilon);
RyoheiHagimoto 0:0e0631af0305 801
RyoheiHagimoto 0:0e0631af0305 802 int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS
RyoheiHagimoto 0:0e0631af0305 803 int maxCount; // the maximum number of iterations/elements
RyoheiHagimoto 0:0e0631af0305 804 double epsilon; // the desired accuracy
RyoheiHagimoto 0:0e0631af0305 805 };
RyoheiHagimoto 0:0e0631af0305 806
RyoheiHagimoto 0:0e0631af0305 807
RyoheiHagimoto 0:0e0631af0305 808 //! @} core_basic
RyoheiHagimoto 0:0e0631af0305 809
RyoheiHagimoto 0:0e0631af0305 810 ///////////////////////// raster image moments //////////////////////////
RyoheiHagimoto 0:0e0631af0305 811
RyoheiHagimoto 0:0e0631af0305 812 //! @addtogroup imgproc_shape
RyoheiHagimoto 0:0e0631af0305 813 //! @{
RyoheiHagimoto 0:0e0631af0305 814
RyoheiHagimoto 0:0e0631af0305 815 /** @brief struct returned by cv::moments
RyoheiHagimoto 0:0e0631af0305 816
RyoheiHagimoto 0:0e0631af0305 817 The spatial moments \f$\texttt{Moments::m}_{ji}\f$ are computed as:
RyoheiHagimoto 0:0e0631af0305 818
RyoheiHagimoto 0:0e0631af0305 819 \f[\texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right )\f]
RyoheiHagimoto 0:0e0631af0305 820
RyoheiHagimoto 0:0e0631af0305 821 The central moments \f$\texttt{Moments::mu}_{ji}\f$ are computed as:
RyoheiHagimoto 0:0e0631af0305 822
RyoheiHagimoto 0:0e0631af0305 823 \f[\texttt{mu} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot (x - \bar{x} )^j \cdot (y - \bar{y} )^i \right )\f]
RyoheiHagimoto 0:0e0631af0305 824
RyoheiHagimoto 0:0e0631af0305 825 where \f$(\bar{x}, \bar{y})\f$ is the mass center:
RyoheiHagimoto 0:0e0631af0305 826
RyoheiHagimoto 0:0e0631af0305 827 \f[\bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}}\f]
RyoheiHagimoto 0:0e0631af0305 828
RyoheiHagimoto 0:0e0631af0305 829 The normalized central moments \f$\texttt{Moments::nu}_{ij}\f$ are computed as:
RyoheiHagimoto 0:0e0631af0305 830
RyoheiHagimoto 0:0e0631af0305 831 \f[\texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} .\f]
RyoheiHagimoto 0:0e0631af0305 832
RyoheiHagimoto 0:0e0631af0305 833 @note
RyoheiHagimoto 0:0e0631af0305 834 \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
RyoheiHagimoto 0:0e0631af0305 835 \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$ , hence the values are not
RyoheiHagimoto 0:0e0631af0305 836 stored.
RyoheiHagimoto 0:0e0631af0305 837
RyoheiHagimoto 0:0e0631af0305 838 The moments of a contour are defined in the same way but computed using the Green's formula (see
RyoheiHagimoto 0:0e0631af0305 839 <http://en.wikipedia.org/wiki/Green_theorem>). So, due to a limited raster resolution, the moments
RyoheiHagimoto 0:0e0631af0305 840 computed for a contour are slightly different from the moments computed for the same rasterized
RyoheiHagimoto 0:0e0631af0305 841 contour.
RyoheiHagimoto 0:0e0631af0305 842
RyoheiHagimoto 0:0e0631af0305 843 @note
RyoheiHagimoto 0:0e0631af0305 844 Since the contour moments are computed using Green formula, you may get seemingly odd results for
RyoheiHagimoto 0:0e0631af0305 845 contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours.
RyoheiHagimoto 0:0e0631af0305 846 */
RyoheiHagimoto 0:0e0631af0305 847 class CV_EXPORTS_W_MAP Moments
RyoheiHagimoto 0:0e0631af0305 848 {
RyoheiHagimoto 0:0e0631af0305 849 public:
RyoheiHagimoto 0:0e0631af0305 850 //! the default constructor
RyoheiHagimoto 0:0e0631af0305 851 Moments();
RyoheiHagimoto 0:0e0631af0305 852 //! the full constructor
RyoheiHagimoto 0:0e0631af0305 853 Moments(double m00, double m10, double m01, double m20, double m11,
RyoheiHagimoto 0:0e0631af0305 854 double m02, double m30, double m21, double m12, double m03 );
RyoheiHagimoto 0:0e0631af0305 855 ////! the conversion from CvMoments
RyoheiHagimoto 0:0e0631af0305 856 //Moments( const CvMoments& moments );
RyoheiHagimoto 0:0e0631af0305 857 ////! the conversion to CvMoments
RyoheiHagimoto 0:0e0631af0305 858 //operator CvMoments() const;
RyoheiHagimoto 0:0e0631af0305 859
RyoheiHagimoto 0:0e0631af0305 860 //! @name spatial moments
RyoheiHagimoto 0:0e0631af0305 861 //! @{
RyoheiHagimoto 0:0e0631af0305 862 CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
RyoheiHagimoto 0:0e0631af0305 863 //! @}
RyoheiHagimoto 0:0e0631af0305 864
RyoheiHagimoto 0:0e0631af0305 865 //! @name central moments
RyoheiHagimoto 0:0e0631af0305 866 //! @{
RyoheiHagimoto 0:0e0631af0305 867 CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
RyoheiHagimoto 0:0e0631af0305 868 //! @}
RyoheiHagimoto 0:0e0631af0305 869
RyoheiHagimoto 0:0e0631af0305 870 //! @name central normalized moments
RyoheiHagimoto 0:0e0631af0305 871 //! @{
RyoheiHagimoto 0:0e0631af0305 872 CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
RyoheiHagimoto 0:0e0631af0305 873 //! @}
RyoheiHagimoto 0:0e0631af0305 874 };
RyoheiHagimoto 0:0e0631af0305 875
RyoheiHagimoto 0:0e0631af0305 876 template<> class DataType<Moments>
RyoheiHagimoto 0:0e0631af0305 877 {
RyoheiHagimoto 0:0e0631af0305 878 public:
RyoheiHagimoto 0:0e0631af0305 879 typedef Moments value_type;
RyoheiHagimoto 0:0e0631af0305 880 typedef double work_type;
RyoheiHagimoto 0:0e0631af0305 881 typedef double channel_type;
RyoheiHagimoto 0:0e0631af0305 882
RyoheiHagimoto 0:0e0631af0305 883 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 884 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 885 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24
RyoheiHagimoto 0:0e0631af0305 886 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 887 type = CV_MAKETYPE(depth, channels)
RyoheiHagimoto 0:0e0631af0305 888 };
RyoheiHagimoto 0:0e0631af0305 889
RyoheiHagimoto 0:0e0631af0305 890 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 891 };
RyoheiHagimoto 0:0e0631af0305 892
RyoheiHagimoto 0:0e0631af0305 893 //! @} imgproc_shape
RyoheiHagimoto 0:0e0631af0305 894
RyoheiHagimoto 0:0e0631af0305 895 //! @cond IGNORED
RyoheiHagimoto 0:0e0631af0305 896
RyoheiHagimoto 0:0e0631af0305 897 /////////////////////////////////////////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 898 ///////////////////////////// Implementation ////////////////////////////
RyoheiHagimoto 0:0e0631af0305 899 /////////////////////////////////////////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 900
RyoheiHagimoto 0:0e0631af0305 901 //////////////////////////////// Complex ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 902
RyoheiHagimoto 0:0e0631af0305 903 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 904 Complex<_Tp>::Complex()
RyoheiHagimoto 0:0e0631af0305 905 : re(0), im(0) {}
RyoheiHagimoto 0:0e0631af0305 906
RyoheiHagimoto 0:0e0631af0305 907 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 908 Complex<_Tp>::Complex( _Tp _re, _Tp _im )
RyoheiHagimoto 0:0e0631af0305 909 : re(_re), im(_im) {}
RyoheiHagimoto 0:0e0631af0305 910
RyoheiHagimoto 0:0e0631af0305 911 template<typename _Tp> template<typename T2> inline
RyoheiHagimoto 0:0e0631af0305 912 Complex<_Tp>::operator Complex<T2>() const
RyoheiHagimoto 0:0e0631af0305 913 {
RyoheiHagimoto 0:0e0631af0305 914 return Complex<T2>(saturate_cast<T2>(re), saturate_cast<T2>(im));
RyoheiHagimoto 0:0e0631af0305 915 }
RyoheiHagimoto 0:0e0631af0305 916
RyoheiHagimoto 0:0e0631af0305 917 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 918 Complex<_Tp> Complex<_Tp>::conj() const
RyoheiHagimoto 0:0e0631af0305 919 {
RyoheiHagimoto 0:0e0631af0305 920 return Complex<_Tp>(re, -im);
RyoheiHagimoto 0:0e0631af0305 921 }
RyoheiHagimoto 0:0e0631af0305 922
RyoheiHagimoto 0:0e0631af0305 923
RyoheiHagimoto 0:0e0631af0305 924 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 925 bool operator == (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 926 {
RyoheiHagimoto 0:0e0631af0305 927 return a.re == b.re && a.im == b.im;
RyoheiHagimoto 0:0e0631af0305 928 }
RyoheiHagimoto 0:0e0631af0305 929
RyoheiHagimoto 0:0e0631af0305 930 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 931 bool operator != (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 932 {
RyoheiHagimoto 0:0e0631af0305 933 return a.re != b.re || a.im != b.im;
RyoheiHagimoto 0:0e0631af0305 934 }
RyoheiHagimoto 0:0e0631af0305 935
RyoheiHagimoto 0:0e0631af0305 936 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 937 Complex<_Tp> operator + (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 938 {
RyoheiHagimoto 0:0e0631af0305 939 return Complex<_Tp>( a.re + b.re, a.im + b.im );
RyoheiHagimoto 0:0e0631af0305 940 }
RyoheiHagimoto 0:0e0631af0305 941
RyoheiHagimoto 0:0e0631af0305 942 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 943 Complex<_Tp>& operator += (Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 944 {
RyoheiHagimoto 0:0e0631af0305 945 a.re += b.re; a.im += b.im;
RyoheiHagimoto 0:0e0631af0305 946 return a;
RyoheiHagimoto 0:0e0631af0305 947 }
RyoheiHagimoto 0:0e0631af0305 948
RyoheiHagimoto 0:0e0631af0305 949 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 950 Complex<_Tp> operator - (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 951 {
RyoheiHagimoto 0:0e0631af0305 952 return Complex<_Tp>( a.re - b.re, a.im - b.im );
RyoheiHagimoto 0:0e0631af0305 953 }
RyoheiHagimoto 0:0e0631af0305 954
RyoheiHagimoto 0:0e0631af0305 955 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 956 Complex<_Tp>& operator -= (Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 957 {
RyoheiHagimoto 0:0e0631af0305 958 a.re -= b.re; a.im -= b.im;
RyoheiHagimoto 0:0e0631af0305 959 return a;
RyoheiHagimoto 0:0e0631af0305 960 }
RyoheiHagimoto 0:0e0631af0305 961
RyoheiHagimoto 0:0e0631af0305 962 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 963 Complex<_Tp> operator - (const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 964 {
RyoheiHagimoto 0:0e0631af0305 965 return Complex<_Tp>(-a.re, -a.im);
RyoheiHagimoto 0:0e0631af0305 966 }
RyoheiHagimoto 0:0e0631af0305 967
RyoheiHagimoto 0:0e0631af0305 968 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 969 Complex<_Tp> operator * (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 970 {
RyoheiHagimoto 0:0e0631af0305 971 return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
RyoheiHagimoto 0:0e0631af0305 972 }
RyoheiHagimoto 0:0e0631af0305 973
RyoheiHagimoto 0:0e0631af0305 974 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 975 Complex<_Tp> operator * (const Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 976 {
RyoheiHagimoto 0:0e0631af0305 977 return Complex<_Tp>( a.re*b, a.im*b );
RyoheiHagimoto 0:0e0631af0305 978 }
RyoheiHagimoto 0:0e0631af0305 979
RyoheiHagimoto 0:0e0631af0305 980 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 981 Complex<_Tp> operator * (_Tp b, const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 982 {
RyoheiHagimoto 0:0e0631af0305 983 return Complex<_Tp>( a.re*b, a.im*b );
RyoheiHagimoto 0:0e0631af0305 984 }
RyoheiHagimoto 0:0e0631af0305 985
RyoheiHagimoto 0:0e0631af0305 986 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 987 Complex<_Tp> operator + (const Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 988 {
RyoheiHagimoto 0:0e0631af0305 989 return Complex<_Tp>( a.re + b, a.im );
RyoheiHagimoto 0:0e0631af0305 990 }
RyoheiHagimoto 0:0e0631af0305 991
RyoheiHagimoto 0:0e0631af0305 992 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 993 Complex<_Tp> operator - (const Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 994 { return Complex<_Tp>( a.re - b, a.im ); }
RyoheiHagimoto 0:0e0631af0305 995
RyoheiHagimoto 0:0e0631af0305 996 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 997 Complex<_Tp> operator + (_Tp b, const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 998 {
RyoheiHagimoto 0:0e0631af0305 999 return Complex<_Tp>( a.re + b, a.im );
RyoheiHagimoto 0:0e0631af0305 1000 }
RyoheiHagimoto 0:0e0631af0305 1001
RyoheiHagimoto 0:0e0631af0305 1002 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1003 Complex<_Tp> operator - (_Tp b, const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 1004 {
RyoheiHagimoto 0:0e0631af0305 1005 return Complex<_Tp>( b - a.re, -a.im );
RyoheiHagimoto 0:0e0631af0305 1006 }
RyoheiHagimoto 0:0e0631af0305 1007
RyoheiHagimoto 0:0e0631af0305 1008 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1009 Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1010 {
RyoheiHagimoto 0:0e0631af0305 1011 a.re += b; return a;
RyoheiHagimoto 0:0e0631af0305 1012 }
RyoheiHagimoto 0:0e0631af0305 1013
RyoheiHagimoto 0:0e0631af0305 1014 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1015 Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1016 {
RyoheiHagimoto 0:0e0631af0305 1017 a.re -= b; return a;
RyoheiHagimoto 0:0e0631af0305 1018 }
RyoheiHagimoto 0:0e0631af0305 1019
RyoheiHagimoto 0:0e0631af0305 1020 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1021 Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1022 {
RyoheiHagimoto 0:0e0631af0305 1023 a.re *= b; a.im *= b; return a;
RyoheiHagimoto 0:0e0631af0305 1024 }
RyoheiHagimoto 0:0e0631af0305 1025
RyoheiHagimoto 0:0e0631af0305 1026 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1027 double abs(const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 1028 {
RyoheiHagimoto 0:0e0631af0305 1029 return std::sqrt( (double)a.re*a.re + (double)a.im*a.im);
RyoheiHagimoto 0:0e0631af0305 1030 }
RyoheiHagimoto 0:0e0631af0305 1031
RyoheiHagimoto 0:0e0631af0305 1032 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1033 Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1034 {
RyoheiHagimoto 0:0e0631af0305 1035 double t = 1./((double)b.re*b.re + (double)b.im*b.im);
RyoheiHagimoto 0:0e0631af0305 1036 return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t),
RyoheiHagimoto 0:0e0631af0305 1037 (_Tp)((-a.re*b.im + a.im*b.re)*t) );
RyoheiHagimoto 0:0e0631af0305 1038 }
RyoheiHagimoto 0:0e0631af0305 1039
RyoheiHagimoto 0:0e0631af0305 1040 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1041 Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1042 {
RyoheiHagimoto 0:0e0631af0305 1043 return (a = a / b);
RyoheiHagimoto 0:0e0631af0305 1044 }
RyoheiHagimoto 0:0e0631af0305 1045
RyoheiHagimoto 0:0e0631af0305 1046 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1047 Complex<_Tp> operator / (const Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1048 {
RyoheiHagimoto 0:0e0631af0305 1049 _Tp t = (_Tp)1/b;
RyoheiHagimoto 0:0e0631af0305 1050 return Complex<_Tp>( a.re*t, a.im*t );
RyoheiHagimoto 0:0e0631af0305 1051 }
RyoheiHagimoto 0:0e0631af0305 1052
RyoheiHagimoto 0:0e0631af0305 1053 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1054 Complex<_Tp> operator / (_Tp b, const Complex<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 1055 {
RyoheiHagimoto 0:0e0631af0305 1056 return Complex<_Tp>(b)/a;
RyoheiHagimoto 0:0e0631af0305 1057 }
RyoheiHagimoto 0:0e0631af0305 1058
RyoheiHagimoto 0:0e0631af0305 1059 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1060 Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1061 {
RyoheiHagimoto 0:0e0631af0305 1062 _Tp t = (_Tp)1/b;
RyoheiHagimoto 0:0e0631af0305 1063 a.re *= t; a.im *= t; return a;
RyoheiHagimoto 0:0e0631af0305 1064 }
RyoheiHagimoto 0:0e0631af0305 1065
RyoheiHagimoto 0:0e0631af0305 1066
RyoheiHagimoto 0:0e0631af0305 1067
RyoheiHagimoto 0:0e0631af0305 1068 //////////////////////////////// 2D Point ///////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1069
RyoheiHagimoto 0:0e0631af0305 1070 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1071 Point_<_Tp>::Point_()
RyoheiHagimoto 0:0e0631af0305 1072 : x(0), y(0) {}
RyoheiHagimoto 0:0e0631af0305 1073
RyoheiHagimoto 0:0e0631af0305 1074 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1075 Point_<_Tp>::Point_(_Tp _x, _Tp _y)
RyoheiHagimoto 0:0e0631af0305 1076 : x(_x), y(_y) {}
RyoheiHagimoto 0:0e0631af0305 1077
RyoheiHagimoto 0:0e0631af0305 1078 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1079 Point_<_Tp>::Point_(const Point_& pt)
RyoheiHagimoto 0:0e0631af0305 1080 : x(pt.x), y(pt.y) {}
RyoheiHagimoto 0:0e0631af0305 1081
RyoheiHagimoto 0:0e0631af0305 1082 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1083 Point_<_Tp>::Point_(const Size_<_Tp>& sz)
RyoheiHagimoto 0:0e0631af0305 1084 : x(sz.width), y(sz.height) {}
RyoheiHagimoto 0:0e0631af0305 1085
RyoheiHagimoto 0:0e0631af0305 1086 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1087 Point_<_Tp>::Point_(const Vec<_Tp,2>& v)
RyoheiHagimoto 0:0e0631af0305 1088 : x(v[0]), y(v[1]) {}
RyoheiHagimoto 0:0e0631af0305 1089
RyoheiHagimoto 0:0e0631af0305 1090 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1091 Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt)
RyoheiHagimoto 0:0e0631af0305 1092 {
RyoheiHagimoto 0:0e0631af0305 1093 x = pt.x; y = pt.y;
RyoheiHagimoto 0:0e0631af0305 1094 return *this;
RyoheiHagimoto 0:0e0631af0305 1095 }
RyoheiHagimoto 0:0e0631af0305 1096
RyoheiHagimoto 0:0e0631af0305 1097 template<typename _Tp> template<typename _Tp2> inline
RyoheiHagimoto 0:0e0631af0305 1098 Point_<_Tp>::operator Point_<_Tp2>() const
RyoheiHagimoto 0:0e0631af0305 1099 {
RyoheiHagimoto 0:0e0631af0305 1100 return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y));
RyoheiHagimoto 0:0e0631af0305 1101 }
RyoheiHagimoto 0:0e0631af0305 1102
RyoheiHagimoto 0:0e0631af0305 1103 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1104 Point_<_Tp>::operator Vec<_Tp, 2>() const
RyoheiHagimoto 0:0e0631af0305 1105 {
RyoheiHagimoto 0:0e0631af0305 1106 return Vec<_Tp, 2>(x, y);
RyoheiHagimoto 0:0e0631af0305 1107 }
RyoheiHagimoto 0:0e0631af0305 1108
RyoheiHagimoto 0:0e0631af0305 1109 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1110 _Tp Point_<_Tp>::dot(const Point_& pt) const
RyoheiHagimoto 0:0e0631af0305 1111 {
RyoheiHagimoto 0:0e0631af0305 1112 return saturate_cast<_Tp>(x*pt.x + y*pt.y);
RyoheiHagimoto 0:0e0631af0305 1113 }
RyoheiHagimoto 0:0e0631af0305 1114
RyoheiHagimoto 0:0e0631af0305 1115 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1116 double Point_<_Tp>::ddot(const Point_& pt) const
RyoheiHagimoto 0:0e0631af0305 1117 {
RyoheiHagimoto 0:0e0631af0305 1118 return (double)x*pt.x + (double)y*pt.y;
RyoheiHagimoto 0:0e0631af0305 1119 }
RyoheiHagimoto 0:0e0631af0305 1120
RyoheiHagimoto 0:0e0631af0305 1121 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1122 double Point_<_Tp>::cross(const Point_& pt) const
RyoheiHagimoto 0:0e0631af0305 1123 {
RyoheiHagimoto 0:0e0631af0305 1124 return (double)x*pt.y - (double)y*pt.x;
RyoheiHagimoto 0:0e0631af0305 1125 }
RyoheiHagimoto 0:0e0631af0305 1126
RyoheiHagimoto 0:0e0631af0305 1127 template<typename _Tp> inline bool
RyoheiHagimoto 0:0e0631af0305 1128 Point_<_Tp>::inside( const Rect_<_Tp>& r ) const
RyoheiHagimoto 0:0e0631af0305 1129 {
RyoheiHagimoto 0:0e0631af0305 1130 return r.contains(*this);
RyoheiHagimoto 0:0e0631af0305 1131 }
RyoheiHagimoto 0:0e0631af0305 1132
RyoheiHagimoto 0:0e0631af0305 1133
RyoheiHagimoto 0:0e0631af0305 1134 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1135 Point_<_Tp>& operator += (Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1136 {
RyoheiHagimoto 0:0e0631af0305 1137 a.x += b.x;
RyoheiHagimoto 0:0e0631af0305 1138 a.y += b.y;
RyoheiHagimoto 0:0e0631af0305 1139 return a;
RyoheiHagimoto 0:0e0631af0305 1140 }
RyoheiHagimoto 0:0e0631af0305 1141
RyoheiHagimoto 0:0e0631af0305 1142 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1143 Point_<_Tp>& operator -= (Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1144 {
RyoheiHagimoto 0:0e0631af0305 1145 a.x -= b.x;
RyoheiHagimoto 0:0e0631af0305 1146 a.y -= b.y;
RyoheiHagimoto 0:0e0631af0305 1147 return a;
RyoheiHagimoto 0:0e0631af0305 1148 }
RyoheiHagimoto 0:0e0631af0305 1149
RyoheiHagimoto 0:0e0631af0305 1150 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1151 Point_<_Tp>& operator *= (Point_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1152 {
RyoheiHagimoto 0:0e0631af0305 1153 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1154 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1155 return a;
RyoheiHagimoto 0:0e0631af0305 1156 }
RyoheiHagimoto 0:0e0631af0305 1157
RyoheiHagimoto 0:0e0631af0305 1158 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1159 Point_<_Tp>& operator *= (Point_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1160 {
RyoheiHagimoto 0:0e0631af0305 1161 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1162 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1163 return a;
RyoheiHagimoto 0:0e0631af0305 1164 }
RyoheiHagimoto 0:0e0631af0305 1165
RyoheiHagimoto 0:0e0631af0305 1166 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1167 Point_<_Tp>& operator *= (Point_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1168 {
RyoheiHagimoto 0:0e0631af0305 1169 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1170 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1171 return a;
RyoheiHagimoto 0:0e0631af0305 1172 }
RyoheiHagimoto 0:0e0631af0305 1173
RyoheiHagimoto 0:0e0631af0305 1174 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1175 Point_<_Tp>& operator /= (Point_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1176 {
RyoheiHagimoto 0:0e0631af0305 1177 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1178 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1179 return a;
RyoheiHagimoto 0:0e0631af0305 1180 }
RyoheiHagimoto 0:0e0631af0305 1181
RyoheiHagimoto 0:0e0631af0305 1182 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1183 Point_<_Tp>& operator /= (Point_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1184 {
RyoheiHagimoto 0:0e0631af0305 1185 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1186 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1187 return a;
RyoheiHagimoto 0:0e0631af0305 1188 }
RyoheiHagimoto 0:0e0631af0305 1189
RyoheiHagimoto 0:0e0631af0305 1190 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1191 Point_<_Tp>& operator /= (Point_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1192 {
RyoheiHagimoto 0:0e0631af0305 1193 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1194 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1195 return a;
RyoheiHagimoto 0:0e0631af0305 1196 }
RyoheiHagimoto 0:0e0631af0305 1197
RyoheiHagimoto 0:0e0631af0305 1198 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1199 double norm(const Point_<_Tp>& pt)
RyoheiHagimoto 0:0e0631af0305 1200 {
RyoheiHagimoto 0:0e0631af0305 1201 return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y);
RyoheiHagimoto 0:0e0631af0305 1202 }
RyoheiHagimoto 0:0e0631af0305 1203
RyoheiHagimoto 0:0e0631af0305 1204 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1205 bool operator == (const Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1206 {
RyoheiHagimoto 0:0e0631af0305 1207 return a.x == b.x && a.y == b.y;
RyoheiHagimoto 0:0e0631af0305 1208 }
RyoheiHagimoto 0:0e0631af0305 1209
RyoheiHagimoto 0:0e0631af0305 1210 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1211 bool operator != (const Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1212 {
RyoheiHagimoto 0:0e0631af0305 1213 return a.x != b.x || a.y != b.y;
RyoheiHagimoto 0:0e0631af0305 1214 }
RyoheiHagimoto 0:0e0631af0305 1215
RyoheiHagimoto 0:0e0631af0305 1216 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1217 Point_<_Tp> operator + (const Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1218 {
RyoheiHagimoto 0:0e0631af0305 1219 return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) );
RyoheiHagimoto 0:0e0631af0305 1220 }
RyoheiHagimoto 0:0e0631af0305 1221
RyoheiHagimoto 0:0e0631af0305 1222 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1223 Point_<_Tp> operator - (const Point_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1224 {
RyoheiHagimoto 0:0e0631af0305 1225 return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) );
RyoheiHagimoto 0:0e0631af0305 1226 }
RyoheiHagimoto 0:0e0631af0305 1227
RyoheiHagimoto 0:0e0631af0305 1228 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1229 Point_<_Tp> operator - (const Point_<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 1230 {
RyoheiHagimoto 0:0e0631af0305 1231 return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) );
RyoheiHagimoto 0:0e0631af0305 1232 }
RyoheiHagimoto 0:0e0631af0305 1233
RyoheiHagimoto 0:0e0631af0305 1234 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1235 Point_<_Tp> operator * (const Point_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1236 {
RyoheiHagimoto 0:0e0631af0305 1237 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
RyoheiHagimoto 0:0e0631af0305 1238 }
RyoheiHagimoto 0:0e0631af0305 1239
RyoheiHagimoto 0:0e0631af0305 1240 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1241 Point_<_Tp> operator * (int a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1242 {
RyoheiHagimoto 0:0e0631af0305 1243 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
RyoheiHagimoto 0:0e0631af0305 1244 }
RyoheiHagimoto 0:0e0631af0305 1245
RyoheiHagimoto 0:0e0631af0305 1246 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1247 Point_<_Tp> operator * (const Point_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1248 {
RyoheiHagimoto 0:0e0631af0305 1249 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
RyoheiHagimoto 0:0e0631af0305 1250 }
RyoheiHagimoto 0:0e0631af0305 1251
RyoheiHagimoto 0:0e0631af0305 1252 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1253 Point_<_Tp> operator * (float a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1254 {
RyoheiHagimoto 0:0e0631af0305 1255 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
RyoheiHagimoto 0:0e0631af0305 1256 }
RyoheiHagimoto 0:0e0631af0305 1257
RyoheiHagimoto 0:0e0631af0305 1258 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1259 Point_<_Tp> operator * (const Point_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1260 {
RyoheiHagimoto 0:0e0631af0305 1261 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
RyoheiHagimoto 0:0e0631af0305 1262 }
RyoheiHagimoto 0:0e0631af0305 1263
RyoheiHagimoto 0:0e0631af0305 1264 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1265 Point_<_Tp> operator * (double a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1266 {
RyoheiHagimoto 0:0e0631af0305 1267 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
RyoheiHagimoto 0:0e0631af0305 1268 }
RyoheiHagimoto 0:0e0631af0305 1269
RyoheiHagimoto 0:0e0631af0305 1270 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1271 Point_<_Tp> operator * (const Matx<_Tp, 2, 2>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1272 {
RyoheiHagimoto 0:0e0631af0305 1273 Matx<_Tp, 2, 1> tmp = a * Vec<_Tp,2>(b.x, b.y);
RyoheiHagimoto 0:0e0631af0305 1274 return Point_<_Tp>(tmp.val[0], tmp.val[1]);
RyoheiHagimoto 0:0e0631af0305 1275 }
RyoheiHagimoto 0:0e0631af0305 1276
RyoheiHagimoto 0:0e0631af0305 1277 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1278 Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1279 {
RyoheiHagimoto 0:0e0631af0305 1280 Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, 1);
RyoheiHagimoto 0:0e0631af0305 1281 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
RyoheiHagimoto 0:0e0631af0305 1282 }
RyoheiHagimoto 0:0e0631af0305 1283
RyoheiHagimoto 0:0e0631af0305 1284 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1285 Point_<_Tp> operator / (const Point_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1286 {
RyoheiHagimoto 0:0e0631af0305 1287 Point_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1288 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1289 return tmp;
RyoheiHagimoto 0:0e0631af0305 1290 }
RyoheiHagimoto 0:0e0631af0305 1291
RyoheiHagimoto 0:0e0631af0305 1292 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1293 Point_<_Tp> operator / (const Point_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1294 {
RyoheiHagimoto 0:0e0631af0305 1295 Point_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1296 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1297 return tmp;
RyoheiHagimoto 0:0e0631af0305 1298 }
RyoheiHagimoto 0:0e0631af0305 1299
RyoheiHagimoto 0:0e0631af0305 1300 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1301 Point_<_Tp> operator / (const Point_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1302 {
RyoheiHagimoto 0:0e0631af0305 1303 Point_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1304 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1305 return tmp;
RyoheiHagimoto 0:0e0631af0305 1306 }
RyoheiHagimoto 0:0e0631af0305 1307
RyoheiHagimoto 0:0e0631af0305 1308
RyoheiHagimoto 0:0e0631af0305 1309
RyoheiHagimoto 0:0e0631af0305 1310 //////////////////////////////// 3D Point ///////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1311
RyoheiHagimoto 0:0e0631af0305 1312 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1313 Point3_<_Tp>::Point3_()
RyoheiHagimoto 0:0e0631af0305 1314 : x(0), y(0), z(0) {}
RyoheiHagimoto 0:0e0631af0305 1315
RyoheiHagimoto 0:0e0631af0305 1316 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1317 Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z)
RyoheiHagimoto 0:0e0631af0305 1318 : x(_x), y(_y), z(_z) {}
RyoheiHagimoto 0:0e0631af0305 1319
RyoheiHagimoto 0:0e0631af0305 1320 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1321 Point3_<_Tp>::Point3_(const Point3_& pt)
RyoheiHagimoto 0:0e0631af0305 1322 : x(pt.x), y(pt.y), z(pt.z) {}
RyoheiHagimoto 0:0e0631af0305 1323
RyoheiHagimoto 0:0e0631af0305 1324 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1325 Point3_<_Tp>::Point3_(const Point_<_Tp>& pt)
RyoheiHagimoto 0:0e0631af0305 1326 : x(pt.x), y(pt.y), z(_Tp()) {}
RyoheiHagimoto 0:0e0631af0305 1327
RyoheiHagimoto 0:0e0631af0305 1328 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1329 Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v)
RyoheiHagimoto 0:0e0631af0305 1330 : x(v[0]), y(v[1]), z(v[2]) {}
RyoheiHagimoto 0:0e0631af0305 1331
RyoheiHagimoto 0:0e0631af0305 1332 template<typename _Tp> template<typename _Tp2> inline
RyoheiHagimoto 0:0e0631af0305 1333 Point3_<_Tp>::operator Point3_<_Tp2>() const
RyoheiHagimoto 0:0e0631af0305 1334 {
RyoheiHagimoto 0:0e0631af0305 1335 return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z));
RyoheiHagimoto 0:0e0631af0305 1336 }
RyoheiHagimoto 0:0e0631af0305 1337
RyoheiHagimoto 0:0e0631af0305 1338 #if OPENCV_ABI_COMPATIBILITY > 300
RyoheiHagimoto 0:0e0631af0305 1339 template<typename _Tp> template<typename _Tp2> inline
RyoheiHagimoto 0:0e0631af0305 1340 Point3_<_Tp>::operator Vec<_Tp2, 3>() const
RyoheiHagimoto 0:0e0631af0305 1341 {
RyoheiHagimoto 0:0e0631af0305 1342 return Vec<_Tp2, 3>(x, y, z);
RyoheiHagimoto 0:0e0631af0305 1343 }
RyoheiHagimoto 0:0e0631af0305 1344 #else
RyoheiHagimoto 0:0e0631af0305 1345 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1346 Point3_<_Tp>::operator Vec<_Tp, 3>() const
RyoheiHagimoto 0:0e0631af0305 1347 {
RyoheiHagimoto 0:0e0631af0305 1348 return Vec<_Tp, 3>(x, y, z);
RyoheiHagimoto 0:0e0631af0305 1349 }
RyoheiHagimoto 0:0e0631af0305 1350 #endif
RyoheiHagimoto 0:0e0631af0305 1351
RyoheiHagimoto 0:0e0631af0305 1352 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1353 Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt)
RyoheiHagimoto 0:0e0631af0305 1354 {
RyoheiHagimoto 0:0e0631af0305 1355 x = pt.x; y = pt.y; z = pt.z;
RyoheiHagimoto 0:0e0631af0305 1356 return *this;
RyoheiHagimoto 0:0e0631af0305 1357 }
RyoheiHagimoto 0:0e0631af0305 1358
RyoheiHagimoto 0:0e0631af0305 1359 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1360 _Tp Point3_<_Tp>::dot(const Point3_& pt) const
RyoheiHagimoto 0:0e0631af0305 1361 {
RyoheiHagimoto 0:0e0631af0305 1362 return saturate_cast<_Tp>(x*pt.x + y*pt.y + z*pt.z);
RyoheiHagimoto 0:0e0631af0305 1363 }
RyoheiHagimoto 0:0e0631af0305 1364
RyoheiHagimoto 0:0e0631af0305 1365 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1366 double Point3_<_Tp>::ddot(const Point3_& pt) const
RyoheiHagimoto 0:0e0631af0305 1367 {
RyoheiHagimoto 0:0e0631af0305 1368 return (double)x*pt.x + (double)y*pt.y + (double)z*pt.z;
RyoheiHagimoto 0:0e0631af0305 1369 }
RyoheiHagimoto 0:0e0631af0305 1370
RyoheiHagimoto 0:0e0631af0305 1371 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1372 Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp>& pt) const
RyoheiHagimoto 0:0e0631af0305 1373 {
RyoheiHagimoto 0:0e0631af0305 1374 return Point3_<_Tp>(y*pt.z - z*pt.y, z*pt.x - x*pt.z, x*pt.y - y*pt.x);
RyoheiHagimoto 0:0e0631af0305 1375 }
RyoheiHagimoto 0:0e0631af0305 1376
RyoheiHagimoto 0:0e0631af0305 1377
RyoheiHagimoto 0:0e0631af0305 1378 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1379 Point3_<_Tp>& operator += (Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1380 {
RyoheiHagimoto 0:0e0631af0305 1381 a.x += b.x;
RyoheiHagimoto 0:0e0631af0305 1382 a.y += b.y;
RyoheiHagimoto 0:0e0631af0305 1383 a.z += b.z;
RyoheiHagimoto 0:0e0631af0305 1384 return a;
RyoheiHagimoto 0:0e0631af0305 1385 }
RyoheiHagimoto 0:0e0631af0305 1386
RyoheiHagimoto 0:0e0631af0305 1387 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1388 Point3_<_Tp>& operator -= (Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1389 {
RyoheiHagimoto 0:0e0631af0305 1390 a.x -= b.x;
RyoheiHagimoto 0:0e0631af0305 1391 a.y -= b.y;
RyoheiHagimoto 0:0e0631af0305 1392 a.z -= b.z;
RyoheiHagimoto 0:0e0631af0305 1393 return a;
RyoheiHagimoto 0:0e0631af0305 1394 }
RyoheiHagimoto 0:0e0631af0305 1395
RyoheiHagimoto 0:0e0631af0305 1396 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1397 Point3_<_Tp>& operator *= (Point3_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1398 {
RyoheiHagimoto 0:0e0631af0305 1399 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1400 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1401 a.z = saturate_cast<_Tp>(a.z * b);
RyoheiHagimoto 0:0e0631af0305 1402 return a;
RyoheiHagimoto 0:0e0631af0305 1403 }
RyoheiHagimoto 0:0e0631af0305 1404
RyoheiHagimoto 0:0e0631af0305 1405 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1406 Point3_<_Tp>& operator *= (Point3_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1407 {
RyoheiHagimoto 0:0e0631af0305 1408 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1409 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1410 a.z = saturate_cast<_Tp>(a.z * b);
RyoheiHagimoto 0:0e0631af0305 1411 return a;
RyoheiHagimoto 0:0e0631af0305 1412 }
RyoheiHagimoto 0:0e0631af0305 1413
RyoheiHagimoto 0:0e0631af0305 1414 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1415 Point3_<_Tp>& operator *= (Point3_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1416 {
RyoheiHagimoto 0:0e0631af0305 1417 a.x = saturate_cast<_Tp>(a.x * b);
RyoheiHagimoto 0:0e0631af0305 1418 a.y = saturate_cast<_Tp>(a.y * b);
RyoheiHagimoto 0:0e0631af0305 1419 a.z = saturate_cast<_Tp>(a.z * b);
RyoheiHagimoto 0:0e0631af0305 1420 return a;
RyoheiHagimoto 0:0e0631af0305 1421 }
RyoheiHagimoto 0:0e0631af0305 1422
RyoheiHagimoto 0:0e0631af0305 1423 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1424 Point3_<_Tp>& operator /= (Point3_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1425 {
RyoheiHagimoto 0:0e0631af0305 1426 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1427 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1428 a.z = saturate_cast<_Tp>(a.z / b);
RyoheiHagimoto 0:0e0631af0305 1429 return a;
RyoheiHagimoto 0:0e0631af0305 1430 }
RyoheiHagimoto 0:0e0631af0305 1431
RyoheiHagimoto 0:0e0631af0305 1432 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1433 Point3_<_Tp>& operator /= (Point3_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1434 {
RyoheiHagimoto 0:0e0631af0305 1435 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1436 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1437 a.z = saturate_cast<_Tp>(a.z / b);
RyoheiHagimoto 0:0e0631af0305 1438 return a;
RyoheiHagimoto 0:0e0631af0305 1439 }
RyoheiHagimoto 0:0e0631af0305 1440
RyoheiHagimoto 0:0e0631af0305 1441 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1442 Point3_<_Tp>& operator /= (Point3_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1443 {
RyoheiHagimoto 0:0e0631af0305 1444 a.x = saturate_cast<_Tp>(a.x / b);
RyoheiHagimoto 0:0e0631af0305 1445 a.y = saturate_cast<_Tp>(a.y / b);
RyoheiHagimoto 0:0e0631af0305 1446 a.z = saturate_cast<_Tp>(a.z / b);
RyoheiHagimoto 0:0e0631af0305 1447 return a;
RyoheiHagimoto 0:0e0631af0305 1448 }
RyoheiHagimoto 0:0e0631af0305 1449
RyoheiHagimoto 0:0e0631af0305 1450 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1451 double norm(const Point3_<_Tp>& pt)
RyoheiHagimoto 0:0e0631af0305 1452 {
RyoheiHagimoto 0:0e0631af0305 1453 return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y + (double)pt.z*pt.z);
RyoheiHagimoto 0:0e0631af0305 1454 }
RyoheiHagimoto 0:0e0631af0305 1455
RyoheiHagimoto 0:0e0631af0305 1456 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1457 bool operator == (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1458 {
RyoheiHagimoto 0:0e0631af0305 1459 return a.x == b.x && a.y == b.y && a.z == b.z;
RyoheiHagimoto 0:0e0631af0305 1460 }
RyoheiHagimoto 0:0e0631af0305 1461
RyoheiHagimoto 0:0e0631af0305 1462 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1463 bool operator != (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1464 {
RyoheiHagimoto 0:0e0631af0305 1465 return a.x != b.x || a.y != b.y || a.z != b.z;
RyoheiHagimoto 0:0e0631af0305 1466 }
RyoheiHagimoto 0:0e0631af0305 1467
RyoheiHagimoto 0:0e0631af0305 1468 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1469 Point3_<_Tp> operator + (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1470 {
RyoheiHagimoto 0:0e0631af0305 1471 return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y), saturate_cast<_Tp>(a.z + b.z));
RyoheiHagimoto 0:0e0631af0305 1472 }
RyoheiHagimoto 0:0e0631af0305 1473
RyoheiHagimoto 0:0e0631af0305 1474 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1475 Point3_<_Tp> operator - (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1476 {
RyoheiHagimoto 0:0e0631af0305 1477 return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y), saturate_cast<_Tp>(a.z - b.z));
RyoheiHagimoto 0:0e0631af0305 1478 }
RyoheiHagimoto 0:0e0631af0305 1479
RyoheiHagimoto 0:0e0631af0305 1480 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1481 Point3_<_Tp> operator - (const Point3_<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 1482 {
RyoheiHagimoto 0:0e0631af0305 1483 return Point3_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y), saturate_cast<_Tp>(-a.z) );
RyoheiHagimoto 0:0e0631af0305 1484 }
RyoheiHagimoto 0:0e0631af0305 1485
RyoheiHagimoto 0:0e0631af0305 1486 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1487 Point3_<_Tp> operator * (const Point3_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1488 {
RyoheiHagimoto 0:0e0631af0305 1489 return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b), saturate_cast<_Tp>(a.z*b) );
RyoheiHagimoto 0:0e0631af0305 1490 }
RyoheiHagimoto 0:0e0631af0305 1491
RyoheiHagimoto 0:0e0631af0305 1492 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1493 Point3_<_Tp> operator * (int a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1494 {
RyoheiHagimoto 0:0e0631af0305 1495 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
RyoheiHagimoto 0:0e0631af0305 1496 }
RyoheiHagimoto 0:0e0631af0305 1497
RyoheiHagimoto 0:0e0631af0305 1498 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1499 Point3_<_Tp> operator * (const Point3_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1500 {
RyoheiHagimoto 0:0e0631af0305 1501 return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) );
RyoheiHagimoto 0:0e0631af0305 1502 }
RyoheiHagimoto 0:0e0631af0305 1503
RyoheiHagimoto 0:0e0631af0305 1504 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1505 Point3_<_Tp> operator * (float a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1506 {
RyoheiHagimoto 0:0e0631af0305 1507 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
RyoheiHagimoto 0:0e0631af0305 1508 }
RyoheiHagimoto 0:0e0631af0305 1509
RyoheiHagimoto 0:0e0631af0305 1510 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1511 Point3_<_Tp> operator * (const Point3_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1512 {
RyoheiHagimoto 0:0e0631af0305 1513 return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) );
RyoheiHagimoto 0:0e0631af0305 1514 }
RyoheiHagimoto 0:0e0631af0305 1515
RyoheiHagimoto 0:0e0631af0305 1516 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1517 Point3_<_Tp> operator * (double a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1518 {
RyoheiHagimoto 0:0e0631af0305 1519 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
RyoheiHagimoto 0:0e0631af0305 1520 }
RyoheiHagimoto 0:0e0631af0305 1521
RyoheiHagimoto 0:0e0631af0305 1522 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1523 Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1524 {
RyoheiHagimoto 0:0e0631af0305 1525 Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, b.z);
RyoheiHagimoto 0:0e0631af0305 1526 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
RyoheiHagimoto 0:0e0631af0305 1527 }
RyoheiHagimoto 0:0e0631af0305 1528
RyoheiHagimoto 0:0e0631af0305 1529 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1530 Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1531 {
RyoheiHagimoto 0:0e0631af0305 1532 return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1);
RyoheiHagimoto 0:0e0631af0305 1533 }
RyoheiHagimoto 0:0e0631af0305 1534
RyoheiHagimoto 0:0e0631af0305 1535 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1536 Point3_<_Tp> operator / (const Point3_<_Tp>& a, int b)
RyoheiHagimoto 0:0e0631af0305 1537 {
RyoheiHagimoto 0:0e0631af0305 1538 Point3_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1539 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1540 return tmp;
RyoheiHagimoto 0:0e0631af0305 1541 }
RyoheiHagimoto 0:0e0631af0305 1542
RyoheiHagimoto 0:0e0631af0305 1543 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1544 Point3_<_Tp> operator / (const Point3_<_Tp>& a, float b)
RyoheiHagimoto 0:0e0631af0305 1545 {
RyoheiHagimoto 0:0e0631af0305 1546 Point3_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1547 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1548 return tmp;
RyoheiHagimoto 0:0e0631af0305 1549 }
RyoheiHagimoto 0:0e0631af0305 1550
RyoheiHagimoto 0:0e0631af0305 1551 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1552 Point3_<_Tp> operator / (const Point3_<_Tp>& a, double b)
RyoheiHagimoto 0:0e0631af0305 1553 {
RyoheiHagimoto 0:0e0631af0305 1554 Point3_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1555 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1556 return tmp;
RyoheiHagimoto 0:0e0631af0305 1557 }
RyoheiHagimoto 0:0e0631af0305 1558
RyoheiHagimoto 0:0e0631af0305 1559
RyoheiHagimoto 0:0e0631af0305 1560
RyoheiHagimoto 0:0e0631af0305 1561 ////////////////////////////////// Size /////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1562
RyoheiHagimoto 0:0e0631af0305 1563 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1564 Size_<_Tp>::Size_()
RyoheiHagimoto 0:0e0631af0305 1565 : width(0), height(0) {}
RyoheiHagimoto 0:0e0631af0305 1566
RyoheiHagimoto 0:0e0631af0305 1567 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1568 Size_<_Tp>::Size_(_Tp _width, _Tp _height)
RyoheiHagimoto 0:0e0631af0305 1569 : width(_width), height(_height) {}
RyoheiHagimoto 0:0e0631af0305 1570
RyoheiHagimoto 0:0e0631af0305 1571 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1572 Size_<_Tp>::Size_(const Size_& sz)
RyoheiHagimoto 0:0e0631af0305 1573 : width(sz.width), height(sz.height) {}
RyoheiHagimoto 0:0e0631af0305 1574
RyoheiHagimoto 0:0e0631af0305 1575 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1576 Size_<_Tp>::Size_(const Point_<_Tp>& pt)
RyoheiHagimoto 0:0e0631af0305 1577 : width(pt.x), height(pt.y) {}
RyoheiHagimoto 0:0e0631af0305 1578
RyoheiHagimoto 0:0e0631af0305 1579 template<typename _Tp> template<typename _Tp2> inline
RyoheiHagimoto 0:0e0631af0305 1580 Size_<_Tp>::operator Size_<_Tp2>() const
RyoheiHagimoto 0:0e0631af0305 1581 {
RyoheiHagimoto 0:0e0631af0305 1582 return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
RyoheiHagimoto 0:0e0631af0305 1583 }
RyoheiHagimoto 0:0e0631af0305 1584
RyoheiHagimoto 0:0e0631af0305 1585 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1586 Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz)
RyoheiHagimoto 0:0e0631af0305 1587 {
RyoheiHagimoto 0:0e0631af0305 1588 width = sz.width; height = sz.height;
RyoheiHagimoto 0:0e0631af0305 1589 return *this;
RyoheiHagimoto 0:0e0631af0305 1590 }
RyoheiHagimoto 0:0e0631af0305 1591
RyoheiHagimoto 0:0e0631af0305 1592 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1593 _Tp Size_<_Tp>::area() const
RyoheiHagimoto 0:0e0631af0305 1594 {
RyoheiHagimoto 0:0e0631af0305 1595 return width * height;
RyoheiHagimoto 0:0e0631af0305 1596 }
RyoheiHagimoto 0:0e0631af0305 1597
RyoheiHagimoto 0:0e0631af0305 1598 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1599 Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1600 {
RyoheiHagimoto 0:0e0631af0305 1601 a.width *= b;
RyoheiHagimoto 0:0e0631af0305 1602 a.height *= b;
RyoheiHagimoto 0:0e0631af0305 1603 return a;
RyoheiHagimoto 0:0e0631af0305 1604 }
RyoheiHagimoto 0:0e0631af0305 1605
RyoheiHagimoto 0:0e0631af0305 1606 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1607 Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1608 {
RyoheiHagimoto 0:0e0631af0305 1609 Size_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1610 tmp *= b;
RyoheiHagimoto 0:0e0631af0305 1611 return tmp;
RyoheiHagimoto 0:0e0631af0305 1612 }
RyoheiHagimoto 0:0e0631af0305 1613
RyoheiHagimoto 0:0e0631af0305 1614 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1615 Size_<_Tp>& operator /= (Size_<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1616 {
RyoheiHagimoto 0:0e0631af0305 1617 a.width /= b;
RyoheiHagimoto 0:0e0631af0305 1618 a.height /= b;
RyoheiHagimoto 0:0e0631af0305 1619 return a;
RyoheiHagimoto 0:0e0631af0305 1620 }
RyoheiHagimoto 0:0e0631af0305 1621
RyoheiHagimoto 0:0e0631af0305 1622 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1623 Size_<_Tp> operator / (const Size_<_Tp>& a, _Tp b)
RyoheiHagimoto 0:0e0631af0305 1624 {
RyoheiHagimoto 0:0e0631af0305 1625 Size_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1626 tmp /= b;
RyoheiHagimoto 0:0e0631af0305 1627 return tmp;
RyoheiHagimoto 0:0e0631af0305 1628 }
RyoheiHagimoto 0:0e0631af0305 1629
RyoheiHagimoto 0:0e0631af0305 1630 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1631 Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1632 {
RyoheiHagimoto 0:0e0631af0305 1633 a.width += b.width;
RyoheiHagimoto 0:0e0631af0305 1634 a.height += b.height;
RyoheiHagimoto 0:0e0631af0305 1635 return a;
RyoheiHagimoto 0:0e0631af0305 1636 }
RyoheiHagimoto 0:0e0631af0305 1637
RyoheiHagimoto 0:0e0631af0305 1638 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1639 Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1640 {
RyoheiHagimoto 0:0e0631af0305 1641 Size_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1642 tmp += b;
RyoheiHagimoto 0:0e0631af0305 1643 return tmp;
RyoheiHagimoto 0:0e0631af0305 1644 }
RyoheiHagimoto 0:0e0631af0305 1645
RyoheiHagimoto 0:0e0631af0305 1646 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1647 Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1648 {
RyoheiHagimoto 0:0e0631af0305 1649 a.width -= b.width;
RyoheiHagimoto 0:0e0631af0305 1650 a.height -= b.height;
RyoheiHagimoto 0:0e0631af0305 1651 return a;
RyoheiHagimoto 0:0e0631af0305 1652 }
RyoheiHagimoto 0:0e0631af0305 1653
RyoheiHagimoto 0:0e0631af0305 1654 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1655 Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1656 {
RyoheiHagimoto 0:0e0631af0305 1657 Size_<_Tp> tmp(a);
RyoheiHagimoto 0:0e0631af0305 1658 tmp -= b;
RyoheiHagimoto 0:0e0631af0305 1659 return tmp;
RyoheiHagimoto 0:0e0631af0305 1660 }
RyoheiHagimoto 0:0e0631af0305 1661
RyoheiHagimoto 0:0e0631af0305 1662 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1663 bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1664 {
RyoheiHagimoto 0:0e0631af0305 1665 return a.width == b.width && a.height == b.height;
RyoheiHagimoto 0:0e0631af0305 1666 }
RyoheiHagimoto 0:0e0631af0305 1667
RyoheiHagimoto 0:0e0631af0305 1668 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1669 bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1670 {
RyoheiHagimoto 0:0e0631af0305 1671 return !(a == b);
RyoheiHagimoto 0:0e0631af0305 1672 }
RyoheiHagimoto 0:0e0631af0305 1673
RyoheiHagimoto 0:0e0631af0305 1674
RyoheiHagimoto 0:0e0631af0305 1675
RyoheiHagimoto 0:0e0631af0305 1676 ////////////////////////////////// Rect /////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1677
RyoheiHagimoto 0:0e0631af0305 1678 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1679 Rect_<_Tp>::Rect_()
RyoheiHagimoto 0:0e0631af0305 1680 : x(0), y(0), width(0), height(0) {}
RyoheiHagimoto 0:0e0631af0305 1681
RyoheiHagimoto 0:0e0631af0305 1682 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1683 Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height)
RyoheiHagimoto 0:0e0631af0305 1684 : x(_x), y(_y), width(_width), height(_height) {}
RyoheiHagimoto 0:0e0631af0305 1685
RyoheiHagimoto 0:0e0631af0305 1686 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1687 Rect_<_Tp>::Rect_(const Rect_<_Tp>& r)
RyoheiHagimoto 0:0e0631af0305 1688 : x(r.x), y(r.y), width(r.width), height(r.height) {}
RyoheiHagimoto 0:0e0631af0305 1689
RyoheiHagimoto 0:0e0631af0305 1690 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1691 Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz)
RyoheiHagimoto 0:0e0631af0305 1692 : x(org.x), y(org.y), width(sz.width), height(sz.height) {}
RyoheiHagimoto 0:0e0631af0305 1693
RyoheiHagimoto 0:0e0631af0305 1694 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1695 Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2)
RyoheiHagimoto 0:0e0631af0305 1696 {
RyoheiHagimoto 0:0e0631af0305 1697 x = std::min(pt1.x, pt2.x);
RyoheiHagimoto 0:0e0631af0305 1698 y = std::min(pt1.y, pt2.y);
RyoheiHagimoto 0:0e0631af0305 1699 width = std::max(pt1.x, pt2.x) - x;
RyoheiHagimoto 0:0e0631af0305 1700 height = std::max(pt1.y, pt2.y) - y;
RyoheiHagimoto 0:0e0631af0305 1701 }
RyoheiHagimoto 0:0e0631af0305 1702
RyoheiHagimoto 0:0e0631af0305 1703 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1704 Rect_<_Tp>& Rect_<_Tp>::operator = ( const Rect_<_Tp>& r )
RyoheiHagimoto 0:0e0631af0305 1705 {
RyoheiHagimoto 0:0e0631af0305 1706 x = r.x;
RyoheiHagimoto 0:0e0631af0305 1707 y = r.y;
RyoheiHagimoto 0:0e0631af0305 1708 width = r.width;
RyoheiHagimoto 0:0e0631af0305 1709 height = r.height;
RyoheiHagimoto 0:0e0631af0305 1710 return *this;
RyoheiHagimoto 0:0e0631af0305 1711 }
RyoheiHagimoto 0:0e0631af0305 1712
RyoheiHagimoto 0:0e0631af0305 1713 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1714 Point_<_Tp> Rect_<_Tp>::tl() const
RyoheiHagimoto 0:0e0631af0305 1715 {
RyoheiHagimoto 0:0e0631af0305 1716 return Point_<_Tp>(x,y);
RyoheiHagimoto 0:0e0631af0305 1717 }
RyoheiHagimoto 0:0e0631af0305 1718
RyoheiHagimoto 0:0e0631af0305 1719 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1720 Point_<_Tp> Rect_<_Tp>::br() const
RyoheiHagimoto 0:0e0631af0305 1721 {
RyoheiHagimoto 0:0e0631af0305 1722 return Point_<_Tp>(x + width, y + height);
RyoheiHagimoto 0:0e0631af0305 1723 }
RyoheiHagimoto 0:0e0631af0305 1724
RyoheiHagimoto 0:0e0631af0305 1725 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1726 Size_<_Tp> Rect_<_Tp>::size() const
RyoheiHagimoto 0:0e0631af0305 1727 {
RyoheiHagimoto 0:0e0631af0305 1728 return Size_<_Tp>(width, height);
RyoheiHagimoto 0:0e0631af0305 1729 }
RyoheiHagimoto 0:0e0631af0305 1730
RyoheiHagimoto 0:0e0631af0305 1731 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1732 _Tp Rect_<_Tp>::area() const
RyoheiHagimoto 0:0e0631af0305 1733 {
RyoheiHagimoto 0:0e0631af0305 1734 return width * height;
RyoheiHagimoto 0:0e0631af0305 1735 }
RyoheiHagimoto 0:0e0631af0305 1736
RyoheiHagimoto 0:0e0631af0305 1737 template<typename _Tp> template<typename _Tp2> inline
RyoheiHagimoto 0:0e0631af0305 1738 Rect_<_Tp>::operator Rect_<_Tp2>() const
RyoheiHagimoto 0:0e0631af0305 1739 {
RyoheiHagimoto 0:0e0631af0305 1740 return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
RyoheiHagimoto 0:0e0631af0305 1741 }
RyoheiHagimoto 0:0e0631af0305 1742
RyoheiHagimoto 0:0e0631af0305 1743 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1744 bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const
RyoheiHagimoto 0:0e0631af0305 1745 {
RyoheiHagimoto 0:0e0631af0305 1746 return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height;
RyoheiHagimoto 0:0e0631af0305 1747 }
RyoheiHagimoto 0:0e0631af0305 1748
RyoheiHagimoto 0:0e0631af0305 1749
RyoheiHagimoto 0:0e0631af0305 1750 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1751 Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1752 {
RyoheiHagimoto 0:0e0631af0305 1753 a.x += b.x;
RyoheiHagimoto 0:0e0631af0305 1754 a.y += b.y;
RyoheiHagimoto 0:0e0631af0305 1755 return a;
RyoheiHagimoto 0:0e0631af0305 1756 }
RyoheiHagimoto 0:0e0631af0305 1757
RyoheiHagimoto 0:0e0631af0305 1758 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1759 Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Point_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1760 {
RyoheiHagimoto 0:0e0631af0305 1761 a.x -= b.x;
RyoheiHagimoto 0:0e0631af0305 1762 a.y -= b.y;
RyoheiHagimoto 0:0e0631af0305 1763 return a;
RyoheiHagimoto 0:0e0631af0305 1764 }
RyoheiHagimoto 0:0e0631af0305 1765
RyoheiHagimoto 0:0e0631af0305 1766 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1767 Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1768 {
RyoheiHagimoto 0:0e0631af0305 1769 a.width += b.width;
RyoheiHagimoto 0:0e0631af0305 1770 a.height += b.height;
RyoheiHagimoto 0:0e0631af0305 1771 return a;
RyoheiHagimoto 0:0e0631af0305 1772 }
RyoheiHagimoto 0:0e0631af0305 1773
RyoheiHagimoto 0:0e0631af0305 1774 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1775 Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1776 {
RyoheiHagimoto 0:0e0631af0305 1777 a.width -= b.width;
RyoheiHagimoto 0:0e0631af0305 1778 a.height -= b.height;
RyoheiHagimoto 0:0e0631af0305 1779 return a;
RyoheiHagimoto 0:0e0631af0305 1780 }
RyoheiHagimoto 0:0e0631af0305 1781
RyoheiHagimoto 0:0e0631af0305 1782 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1783 Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1784 {
RyoheiHagimoto 0:0e0631af0305 1785 _Tp x1 = std::max(a.x, b.x);
RyoheiHagimoto 0:0e0631af0305 1786 _Tp y1 = std::max(a.y, b.y);
RyoheiHagimoto 0:0e0631af0305 1787 a.width = std::min(a.x + a.width, b.x + b.width) - x1;
RyoheiHagimoto 0:0e0631af0305 1788 a.height = std::min(a.y + a.height, b.y + b.height) - y1;
RyoheiHagimoto 0:0e0631af0305 1789 a.x = x1;
RyoheiHagimoto 0:0e0631af0305 1790 a.y = y1;
RyoheiHagimoto 0:0e0631af0305 1791 if( a.width <= 0 || a.height <= 0 )
RyoheiHagimoto 0:0e0631af0305 1792 a = Rect();
RyoheiHagimoto 0:0e0631af0305 1793 return a;
RyoheiHagimoto 0:0e0631af0305 1794 }
RyoheiHagimoto 0:0e0631af0305 1795
RyoheiHagimoto 0:0e0631af0305 1796 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1797 Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 1798 {
RyoheiHagimoto 0:0e0631af0305 1799 _Tp x1 = std::min(a.x, b.x);
RyoheiHagimoto 0:0e0631af0305 1800 _Tp y1 = std::min(a.y, b.y);
RyoheiHagimoto 0:0e0631af0305 1801 a.width = std::max(a.x + a.width, b.x + b.width) - x1;
RyoheiHagimoto 0:0e0631af0305 1802 a.height = std::max(a.y + a.height, b.y + b.height) - y1;
RyoheiHagimoto 0:0e0631af0305 1803 a.x = x1;
RyoheiHagimoto 0:0e0631af0305 1804 a.y = y1;
RyoheiHagimoto 0:0e0631af0305 1805 return a;
RyoheiHagimoto 0:0e0631af0305 1806 }
RyoheiHagimoto 0:0e0631af0305 1807
RyoheiHagimoto 0:0e0631af0305 1808 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1809 bool operator == (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1810 {
RyoheiHagimoto 0:0e0631af0305 1811 return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
RyoheiHagimoto 0:0e0631af0305 1812 }
RyoheiHagimoto 0:0e0631af0305 1813
RyoheiHagimoto 0:0e0631af0305 1814 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1815 bool operator != (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1816 {
RyoheiHagimoto 0:0e0631af0305 1817 return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height;
RyoheiHagimoto 0:0e0631af0305 1818 }
RyoheiHagimoto 0:0e0631af0305 1819
RyoheiHagimoto 0:0e0631af0305 1820 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1821 Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1822 {
RyoheiHagimoto 0:0e0631af0305 1823 return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height );
RyoheiHagimoto 0:0e0631af0305 1824 }
RyoheiHagimoto 0:0e0631af0305 1825
RyoheiHagimoto 0:0e0631af0305 1826 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1827 Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Point_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1828 {
RyoheiHagimoto 0:0e0631af0305 1829 return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height );
RyoheiHagimoto 0:0e0631af0305 1830 }
RyoheiHagimoto 0:0e0631af0305 1831
RyoheiHagimoto 0:0e0631af0305 1832 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1833 Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1834 {
RyoheiHagimoto 0:0e0631af0305 1835 return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
RyoheiHagimoto 0:0e0631af0305 1836 }
RyoheiHagimoto 0:0e0631af0305 1837
RyoheiHagimoto 0:0e0631af0305 1838 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1839 Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1840 {
RyoheiHagimoto 0:0e0631af0305 1841 Rect_<_Tp> c = a;
RyoheiHagimoto 0:0e0631af0305 1842 return c &= b;
RyoheiHagimoto 0:0e0631af0305 1843 }
RyoheiHagimoto 0:0e0631af0305 1844
RyoheiHagimoto 0:0e0631af0305 1845 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1846 Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 1847 {
RyoheiHagimoto 0:0e0631af0305 1848 Rect_<_Tp> c = a;
RyoheiHagimoto 0:0e0631af0305 1849 return c |= b;
RyoheiHagimoto 0:0e0631af0305 1850 }
RyoheiHagimoto 0:0e0631af0305 1851
RyoheiHagimoto 0:0e0631af0305 1852 /**
RyoheiHagimoto 0:0e0631af0305 1853 * @brief measure dissimilarity between two sample sets
RyoheiHagimoto 0:0e0631af0305 1854 *
RyoheiHagimoto 0:0e0631af0305 1855 * computes the complement of the Jaccard Index as described in <https://en.wikipedia.org/wiki/Jaccard_index>.
RyoheiHagimoto 0:0e0631af0305 1856 * For rectangles this reduces to computing the intersection over the union.
RyoheiHagimoto 0:0e0631af0305 1857 */
RyoheiHagimoto 0:0e0631af0305 1858 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 1859 double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) {
RyoheiHagimoto 0:0e0631af0305 1860 _Tp Aa = a.area();
RyoheiHagimoto 0:0e0631af0305 1861 _Tp Ab = b.area();
RyoheiHagimoto 0:0e0631af0305 1862
RyoheiHagimoto 0:0e0631af0305 1863 if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) {
RyoheiHagimoto 0:0e0631af0305 1864 // jaccard_index = 1 -> distance = 0
RyoheiHagimoto 0:0e0631af0305 1865 return 0.0;
RyoheiHagimoto 0:0e0631af0305 1866 }
RyoheiHagimoto 0:0e0631af0305 1867
RyoheiHagimoto 0:0e0631af0305 1868 double Aab = (a & b).area();
RyoheiHagimoto 0:0e0631af0305 1869 // distance = 1 - jaccard_index
RyoheiHagimoto 0:0e0631af0305 1870 return 1.0 - Aab / (Aa + Ab - Aab);
RyoheiHagimoto 0:0e0631af0305 1871 }
RyoheiHagimoto 0:0e0631af0305 1872
RyoheiHagimoto 0:0e0631af0305 1873 ////////////////////////////// RotatedRect //////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1874
RyoheiHagimoto 0:0e0631af0305 1875 inline
RyoheiHagimoto 0:0e0631af0305 1876 RotatedRect::RotatedRect()
RyoheiHagimoto 0:0e0631af0305 1877 : center(), size(), angle(0) {}
RyoheiHagimoto 0:0e0631af0305 1878
RyoheiHagimoto 0:0e0631af0305 1879 inline
RyoheiHagimoto 0:0e0631af0305 1880 RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle)
RyoheiHagimoto 0:0e0631af0305 1881 : center(_center), size(_size), angle(_angle) {}
RyoheiHagimoto 0:0e0631af0305 1882
RyoheiHagimoto 0:0e0631af0305 1883
RyoheiHagimoto 0:0e0631af0305 1884
RyoheiHagimoto 0:0e0631af0305 1885 ///////////////////////////////// Range /////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1886
RyoheiHagimoto 0:0e0631af0305 1887 inline
RyoheiHagimoto 0:0e0631af0305 1888 Range::Range()
RyoheiHagimoto 0:0e0631af0305 1889 : start(0), end(0) {}
RyoheiHagimoto 0:0e0631af0305 1890
RyoheiHagimoto 0:0e0631af0305 1891 inline
RyoheiHagimoto 0:0e0631af0305 1892 Range::Range(int _start, int _end)
RyoheiHagimoto 0:0e0631af0305 1893 : start(_start), end(_end) {}
RyoheiHagimoto 0:0e0631af0305 1894
RyoheiHagimoto 0:0e0631af0305 1895 inline
RyoheiHagimoto 0:0e0631af0305 1896 int Range::size() const
RyoheiHagimoto 0:0e0631af0305 1897 {
RyoheiHagimoto 0:0e0631af0305 1898 return end - start;
RyoheiHagimoto 0:0e0631af0305 1899 }
RyoheiHagimoto 0:0e0631af0305 1900
RyoheiHagimoto 0:0e0631af0305 1901 inline
RyoheiHagimoto 0:0e0631af0305 1902 bool Range::empty() const
RyoheiHagimoto 0:0e0631af0305 1903 {
RyoheiHagimoto 0:0e0631af0305 1904 return start == end;
RyoheiHagimoto 0:0e0631af0305 1905 }
RyoheiHagimoto 0:0e0631af0305 1906
RyoheiHagimoto 0:0e0631af0305 1907 inline
RyoheiHagimoto 0:0e0631af0305 1908 Range Range::all()
RyoheiHagimoto 0:0e0631af0305 1909 {
RyoheiHagimoto 0:0e0631af0305 1910 return Range(INT_MIN, INT_MAX);
RyoheiHagimoto 0:0e0631af0305 1911 }
RyoheiHagimoto 0:0e0631af0305 1912
RyoheiHagimoto 0:0e0631af0305 1913
RyoheiHagimoto 0:0e0631af0305 1914 static inline
RyoheiHagimoto 0:0e0631af0305 1915 bool operator == (const Range& r1, const Range& r2)
RyoheiHagimoto 0:0e0631af0305 1916 {
RyoheiHagimoto 0:0e0631af0305 1917 return r1.start == r2.start && r1.end == r2.end;
RyoheiHagimoto 0:0e0631af0305 1918 }
RyoheiHagimoto 0:0e0631af0305 1919
RyoheiHagimoto 0:0e0631af0305 1920 static inline
RyoheiHagimoto 0:0e0631af0305 1921 bool operator != (const Range& r1, const Range& r2)
RyoheiHagimoto 0:0e0631af0305 1922 {
RyoheiHagimoto 0:0e0631af0305 1923 return !(r1 == r2);
RyoheiHagimoto 0:0e0631af0305 1924 }
RyoheiHagimoto 0:0e0631af0305 1925
RyoheiHagimoto 0:0e0631af0305 1926 static inline
RyoheiHagimoto 0:0e0631af0305 1927 bool operator !(const Range& r)
RyoheiHagimoto 0:0e0631af0305 1928 {
RyoheiHagimoto 0:0e0631af0305 1929 return r.start == r.end;
RyoheiHagimoto 0:0e0631af0305 1930 }
RyoheiHagimoto 0:0e0631af0305 1931
RyoheiHagimoto 0:0e0631af0305 1932 static inline
RyoheiHagimoto 0:0e0631af0305 1933 Range operator & (const Range& r1, const Range& r2)
RyoheiHagimoto 0:0e0631af0305 1934 {
RyoheiHagimoto 0:0e0631af0305 1935 Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end));
RyoheiHagimoto 0:0e0631af0305 1936 r.end = std::max(r.end, r.start);
RyoheiHagimoto 0:0e0631af0305 1937 return r;
RyoheiHagimoto 0:0e0631af0305 1938 }
RyoheiHagimoto 0:0e0631af0305 1939
RyoheiHagimoto 0:0e0631af0305 1940 static inline
RyoheiHagimoto 0:0e0631af0305 1941 Range& operator &= (Range& r1, const Range& r2)
RyoheiHagimoto 0:0e0631af0305 1942 {
RyoheiHagimoto 0:0e0631af0305 1943 r1 = r1 & r2;
RyoheiHagimoto 0:0e0631af0305 1944 return r1;
RyoheiHagimoto 0:0e0631af0305 1945 }
RyoheiHagimoto 0:0e0631af0305 1946
RyoheiHagimoto 0:0e0631af0305 1947 static inline
RyoheiHagimoto 0:0e0631af0305 1948 Range operator + (const Range& r1, int delta)
RyoheiHagimoto 0:0e0631af0305 1949 {
RyoheiHagimoto 0:0e0631af0305 1950 return Range(r1.start + delta, r1.end + delta);
RyoheiHagimoto 0:0e0631af0305 1951 }
RyoheiHagimoto 0:0e0631af0305 1952
RyoheiHagimoto 0:0e0631af0305 1953 static inline
RyoheiHagimoto 0:0e0631af0305 1954 Range operator + (int delta, const Range& r1)
RyoheiHagimoto 0:0e0631af0305 1955 {
RyoheiHagimoto 0:0e0631af0305 1956 return Range(r1.start + delta, r1.end + delta);
RyoheiHagimoto 0:0e0631af0305 1957 }
RyoheiHagimoto 0:0e0631af0305 1958
RyoheiHagimoto 0:0e0631af0305 1959 static inline
RyoheiHagimoto 0:0e0631af0305 1960 Range operator - (const Range& r1, int delta)
RyoheiHagimoto 0:0e0631af0305 1961 {
RyoheiHagimoto 0:0e0631af0305 1962 return r1 + (-delta);
RyoheiHagimoto 0:0e0631af0305 1963 }
RyoheiHagimoto 0:0e0631af0305 1964
RyoheiHagimoto 0:0e0631af0305 1965
RyoheiHagimoto 0:0e0631af0305 1966
RyoheiHagimoto 0:0e0631af0305 1967 ///////////////////////////////// Scalar ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 1968
RyoheiHagimoto 0:0e0631af0305 1969 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1970 Scalar_<_Tp>::Scalar_()
RyoheiHagimoto 0:0e0631af0305 1971 {
RyoheiHagimoto 0:0e0631af0305 1972 this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0;
RyoheiHagimoto 0:0e0631af0305 1973 }
RyoheiHagimoto 0:0e0631af0305 1974
RyoheiHagimoto 0:0e0631af0305 1975 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1976 Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
RyoheiHagimoto 0:0e0631af0305 1977 {
RyoheiHagimoto 0:0e0631af0305 1978 this->val[0] = v0;
RyoheiHagimoto 0:0e0631af0305 1979 this->val[1] = v1;
RyoheiHagimoto 0:0e0631af0305 1980 this->val[2] = v2;
RyoheiHagimoto 0:0e0631af0305 1981 this->val[3] = v3;
RyoheiHagimoto 0:0e0631af0305 1982 }
RyoheiHagimoto 0:0e0631af0305 1983
RyoheiHagimoto 0:0e0631af0305 1984 template<typename _Tp> template<typename _Tp2, int cn> inline
RyoheiHagimoto 0:0e0631af0305 1985 Scalar_<_Tp>::Scalar_(const Vec<_Tp2, cn>& v)
RyoheiHagimoto 0:0e0631af0305 1986 {
RyoheiHagimoto 0:0e0631af0305 1987 int i;
RyoheiHagimoto 0:0e0631af0305 1988 for( i = 0; i < (cn < 4 ? cn : 4); i++ )
RyoheiHagimoto 0:0e0631af0305 1989 this->val[i] = cv::saturate_cast<_Tp>(v.val[i]);
RyoheiHagimoto 0:0e0631af0305 1990 for( ; i < 4; i++ )
RyoheiHagimoto 0:0e0631af0305 1991 this->val[i] = 0;
RyoheiHagimoto 0:0e0631af0305 1992 }
RyoheiHagimoto 0:0e0631af0305 1993
RyoheiHagimoto 0:0e0631af0305 1994 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 1995 Scalar_<_Tp>::Scalar_(_Tp v0)
RyoheiHagimoto 0:0e0631af0305 1996 {
RyoheiHagimoto 0:0e0631af0305 1997 this->val[0] = v0;
RyoheiHagimoto 0:0e0631af0305 1998 this->val[1] = this->val[2] = this->val[3] = 0;
RyoheiHagimoto 0:0e0631af0305 1999 }
RyoheiHagimoto 0:0e0631af0305 2000
RyoheiHagimoto 0:0e0631af0305 2001 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 2002 Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0)
RyoheiHagimoto 0:0e0631af0305 2003 {
RyoheiHagimoto 0:0e0631af0305 2004 return Scalar_<_Tp>(v0, v0, v0, v0);
RyoheiHagimoto 0:0e0631af0305 2005 }
RyoheiHagimoto 0:0e0631af0305 2006
RyoheiHagimoto 0:0e0631af0305 2007
RyoheiHagimoto 0:0e0631af0305 2008 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 2009 Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp>& a, double scale ) const
RyoheiHagimoto 0:0e0631af0305 2010 {
RyoheiHagimoto 0:0e0631af0305 2011 return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0] * a.val[0] * scale),
RyoheiHagimoto 0:0e0631af0305 2012 saturate_cast<_Tp>(this->val[1] * a.val[1] * scale),
RyoheiHagimoto 0:0e0631af0305 2013 saturate_cast<_Tp>(this->val[2] * a.val[2] * scale),
RyoheiHagimoto 0:0e0631af0305 2014 saturate_cast<_Tp>(this->val[3] * a.val[3] * scale));
RyoheiHagimoto 0:0e0631af0305 2015 }
RyoheiHagimoto 0:0e0631af0305 2016
RyoheiHagimoto 0:0e0631af0305 2017 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 2018 Scalar_<_Tp> Scalar_<_Tp>::conj() const
RyoheiHagimoto 0:0e0631af0305 2019 {
RyoheiHagimoto 0:0e0631af0305 2020 return Scalar_<_Tp>(saturate_cast<_Tp>( this->val[0]),
RyoheiHagimoto 0:0e0631af0305 2021 saturate_cast<_Tp>(-this->val[1]),
RyoheiHagimoto 0:0e0631af0305 2022 saturate_cast<_Tp>(-this->val[2]),
RyoheiHagimoto 0:0e0631af0305 2023 saturate_cast<_Tp>(-this->val[3]));
RyoheiHagimoto 0:0e0631af0305 2024 }
RyoheiHagimoto 0:0e0631af0305 2025
RyoheiHagimoto 0:0e0631af0305 2026 template<typename _Tp> inline
RyoheiHagimoto 0:0e0631af0305 2027 bool Scalar_<_Tp>::isReal() const
RyoheiHagimoto 0:0e0631af0305 2028 {
RyoheiHagimoto 0:0e0631af0305 2029 return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0;
RyoheiHagimoto 0:0e0631af0305 2030 }
RyoheiHagimoto 0:0e0631af0305 2031
RyoheiHagimoto 0:0e0631af0305 2032
RyoheiHagimoto 0:0e0631af0305 2033 template<typename _Tp> template<typename T2> inline
RyoheiHagimoto 0:0e0631af0305 2034 Scalar_<_Tp>::operator Scalar_<T2>() const
RyoheiHagimoto 0:0e0631af0305 2035 {
RyoheiHagimoto 0:0e0631af0305 2036 return Scalar_<T2>(saturate_cast<T2>(this->val[0]),
RyoheiHagimoto 0:0e0631af0305 2037 saturate_cast<T2>(this->val[1]),
RyoheiHagimoto 0:0e0631af0305 2038 saturate_cast<T2>(this->val[2]),
RyoheiHagimoto 0:0e0631af0305 2039 saturate_cast<T2>(this->val[3]));
RyoheiHagimoto 0:0e0631af0305 2040 }
RyoheiHagimoto 0:0e0631af0305 2041
RyoheiHagimoto 0:0e0631af0305 2042
RyoheiHagimoto 0:0e0631af0305 2043 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2044 Scalar_<_Tp>& operator += (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2045 {
RyoheiHagimoto 0:0e0631af0305 2046 a.val[0] += b.val[0];
RyoheiHagimoto 0:0e0631af0305 2047 a.val[1] += b.val[1];
RyoheiHagimoto 0:0e0631af0305 2048 a.val[2] += b.val[2];
RyoheiHagimoto 0:0e0631af0305 2049 a.val[3] += b.val[3];
RyoheiHagimoto 0:0e0631af0305 2050 return a;
RyoheiHagimoto 0:0e0631af0305 2051 }
RyoheiHagimoto 0:0e0631af0305 2052
RyoheiHagimoto 0:0e0631af0305 2053 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2054 Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2055 {
RyoheiHagimoto 0:0e0631af0305 2056 a.val[0] -= b.val[0];
RyoheiHagimoto 0:0e0631af0305 2057 a.val[1] -= b.val[1];
RyoheiHagimoto 0:0e0631af0305 2058 a.val[2] -= b.val[2];
RyoheiHagimoto 0:0e0631af0305 2059 a.val[3] -= b.val[3];
RyoheiHagimoto 0:0e0631af0305 2060 return a;
RyoheiHagimoto 0:0e0631af0305 2061 }
RyoheiHagimoto 0:0e0631af0305 2062
RyoheiHagimoto 0:0e0631af0305 2063 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2064 Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp v )
RyoheiHagimoto 0:0e0631af0305 2065 {
RyoheiHagimoto 0:0e0631af0305 2066 a.val[0] *= v;
RyoheiHagimoto 0:0e0631af0305 2067 a.val[1] *= v;
RyoheiHagimoto 0:0e0631af0305 2068 a.val[2] *= v;
RyoheiHagimoto 0:0e0631af0305 2069 a.val[3] *= v;
RyoheiHagimoto 0:0e0631af0305 2070 return a;
RyoheiHagimoto 0:0e0631af0305 2071 }
RyoheiHagimoto 0:0e0631af0305 2072
RyoheiHagimoto 0:0e0631af0305 2073 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2074 bool operator == ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 2075 {
RyoheiHagimoto 0:0e0631af0305 2076 return a.val[0] == b.val[0] && a.val[1] == b.val[1] &&
RyoheiHagimoto 0:0e0631af0305 2077 a.val[2] == b.val[2] && a.val[3] == b.val[3];
RyoheiHagimoto 0:0e0631af0305 2078 }
RyoheiHagimoto 0:0e0631af0305 2079
RyoheiHagimoto 0:0e0631af0305 2080 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2081 bool operator != ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b )
RyoheiHagimoto 0:0e0631af0305 2082 {
RyoheiHagimoto 0:0e0631af0305 2083 return a.val[0] != b.val[0] || a.val[1] != b.val[1] ||
RyoheiHagimoto 0:0e0631af0305 2084 a.val[2] != b.val[2] || a.val[3] != b.val[3];
RyoheiHagimoto 0:0e0631af0305 2085 }
RyoheiHagimoto 0:0e0631af0305 2086
RyoheiHagimoto 0:0e0631af0305 2087 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2088 Scalar_<_Tp> operator + (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2089 {
RyoheiHagimoto 0:0e0631af0305 2090 return Scalar_<_Tp>(a.val[0] + b.val[0],
RyoheiHagimoto 0:0e0631af0305 2091 a.val[1] + b.val[1],
RyoheiHagimoto 0:0e0631af0305 2092 a.val[2] + b.val[2],
RyoheiHagimoto 0:0e0631af0305 2093 a.val[3] + b.val[3]);
RyoheiHagimoto 0:0e0631af0305 2094 }
RyoheiHagimoto 0:0e0631af0305 2095
RyoheiHagimoto 0:0e0631af0305 2096 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2097 Scalar_<_Tp> operator - (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2098 {
RyoheiHagimoto 0:0e0631af0305 2099 return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]),
RyoheiHagimoto 0:0e0631af0305 2100 saturate_cast<_Tp>(a.val[1] - b.val[1]),
RyoheiHagimoto 0:0e0631af0305 2101 saturate_cast<_Tp>(a.val[2] - b.val[2]),
RyoheiHagimoto 0:0e0631af0305 2102 saturate_cast<_Tp>(a.val[3] - b.val[3]));
RyoheiHagimoto 0:0e0631af0305 2103 }
RyoheiHagimoto 0:0e0631af0305 2104
RyoheiHagimoto 0:0e0631af0305 2105 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2106 Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, _Tp alpha)
RyoheiHagimoto 0:0e0631af0305 2107 {
RyoheiHagimoto 0:0e0631af0305 2108 return Scalar_<_Tp>(a.val[0] * alpha,
RyoheiHagimoto 0:0e0631af0305 2109 a.val[1] * alpha,
RyoheiHagimoto 0:0e0631af0305 2110 a.val[2] * alpha,
RyoheiHagimoto 0:0e0631af0305 2111 a.val[3] * alpha);
RyoheiHagimoto 0:0e0631af0305 2112 }
RyoheiHagimoto 0:0e0631af0305 2113
RyoheiHagimoto 0:0e0631af0305 2114 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2115 Scalar_<_Tp> operator * (_Tp alpha, const Scalar_<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 2116 {
RyoheiHagimoto 0:0e0631af0305 2117 return a*alpha;
RyoheiHagimoto 0:0e0631af0305 2118 }
RyoheiHagimoto 0:0e0631af0305 2119
RyoheiHagimoto 0:0e0631af0305 2120 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2121 Scalar_<_Tp> operator - (const Scalar_<_Tp>& a)
RyoheiHagimoto 0:0e0631af0305 2122 {
RyoheiHagimoto 0:0e0631af0305 2123 return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]),
RyoheiHagimoto 0:0e0631af0305 2124 saturate_cast<_Tp>(-a.val[1]),
RyoheiHagimoto 0:0e0631af0305 2125 saturate_cast<_Tp>(-a.val[2]),
RyoheiHagimoto 0:0e0631af0305 2126 saturate_cast<_Tp>(-a.val[3]));
RyoheiHagimoto 0:0e0631af0305 2127 }
RyoheiHagimoto 0:0e0631af0305 2128
RyoheiHagimoto 0:0e0631af0305 2129
RyoheiHagimoto 0:0e0631af0305 2130 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2131 Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2132 {
RyoheiHagimoto 0:0e0631af0305 2133 return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]),
RyoheiHagimoto 0:0e0631af0305 2134 saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]),
RyoheiHagimoto 0:0e0631af0305 2135 saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]),
RyoheiHagimoto 0:0e0631af0305 2136 saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0]));
RyoheiHagimoto 0:0e0631af0305 2137 }
RyoheiHagimoto 0:0e0631af0305 2138
RyoheiHagimoto 0:0e0631af0305 2139 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2140 Scalar_<_Tp>& operator *= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2141 {
RyoheiHagimoto 0:0e0631af0305 2142 a = a * b;
RyoheiHagimoto 0:0e0631af0305 2143 return a;
RyoheiHagimoto 0:0e0631af0305 2144 }
RyoheiHagimoto 0:0e0631af0305 2145
RyoheiHagimoto 0:0e0631af0305 2146 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2147 Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, _Tp alpha)
RyoheiHagimoto 0:0e0631af0305 2148 {
RyoheiHagimoto 0:0e0631af0305 2149 return Scalar_<_Tp>(a.val[0] / alpha,
RyoheiHagimoto 0:0e0631af0305 2150 a.val[1] / alpha,
RyoheiHagimoto 0:0e0631af0305 2151 a.val[2] / alpha,
RyoheiHagimoto 0:0e0631af0305 2152 a.val[3] / alpha);
RyoheiHagimoto 0:0e0631af0305 2153 }
RyoheiHagimoto 0:0e0631af0305 2154
RyoheiHagimoto 0:0e0631af0305 2155 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2156 Scalar_<float> operator / (const Scalar_<float>& a, float alpha)
RyoheiHagimoto 0:0e0631af0305 2157 {
RyoheiHagimoto 0:0e0631af0305 2158 float s = 1 / alpha;
RyoheiHagimoto 0:0e0631af0305 2159 return Scalar_<float>(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s);
RyoheiHagimoto 0:0e0631af0305 2160 }
RyoheiHagimoto 0:0e0631af0305 2161
RyoheiHagimoto 0:0e0631af0305 2162 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2163 Scalar_<double> operator / (const Scalar_<double>& a, double alpha)
RyoheiHagimoto 0:0e0631af0305 2164 {
RyoheiHagimoto 0:0e0631af0305 2165 double s = 1 / alpha;
RyoheiHagimoto 0:0e0631af0305 2166 return Scalar_<double>(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s);
RyoheiHagimoto 0:0e0631af0305 2167 }
RyoheiHagimoto 0:0e0631af0305 2168
RyoheiHagimoto 0:0e0631af0305 2169 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2170 Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha)
RyoheiHagimoto 0:0e0631af0305 2171 {
RyoheiHagimoto 0:0e0631af0305 2172 a = a / alpha;
RyoheiHagimoto 0:0e0631af0305 2173 return a;
RyoheiHagimoto 0:0e0631af0305 2174 }
RyoheiHagimoto 0:0e0631af0305 2175
RyoheiHagimoto 0:0e0631af0305 2176 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2177 Scalar_<_Tp> operator / (_Tp a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2178 {
RyoheiHagimoto 0:0e0631af0305 2179 _Tp s = a / (b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]);
RyoheiHagimoto 0:0e0631af0305 2180 return b.conj() * s;
RyoheiHagimoto 0:0e0631af0305 2181 }
RyoheiHagimoto 0:0e0631af0305 2182
RyoheiHagimoto 0:0e0631af0305 2183 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2184 Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2185 {
RyoheiHagimoto 0:0e0631af0305 2186 return a * ((_Tp)1 / b);
RyoheiHagimoto 0:0e0631af0305 2187 }
RyoheiHagimoto 0:0e0631af0305 2188
RyoheiHagimoto 0:0e0631af0305 2189 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2190 Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
RyoheiHagimoto 0:0e0631af0305 2191 {
RyoheiHagimoto 0:0e0631af0305 2192 a = a / b;
RyoheiHagimoto 0:0e0631af0305 2193 return a;
RyoheiHagimoto 0:0e0631af0305 2194 }
RyoheiHagimoto 0:0e0631af0305 2195
RyoheiHagimoto 0:0e0631af0305 2196 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 2197 Scalar operator * (const Matx<_Tp, 4, 4>& a, const Scalar& b)
RyoheiHagimoto 0:0e0631af0305 2198 {
RyoheiHagimoto 0:0e0631af0305 2199 Matx<double, 4, 1> c((Matx<double, 4, 4>)a, b, Matx_MatMulOp());
RyoheiHagimoto 0:0e0631af0305 2200 return reinterpret_cast<const Scalar&>(c);
RyoheiHagimoto 0:0e0631af0305 2201 }
RyoheiHagimoto 0:0e0631af0305 2202
RyoheiHagimoto 0:0e0631af0305 2203 template<> inline
RyoheiHagimoto 0:0e0631af0305 2204 Scalar operator * (const Matx<double, 4, 4>& a, const Scalar& b)
RyoheiHagimoto 0:0e0631af0305 2205 {
RyoheiHagimoto 0:0e0631af0305 2206 Matx<double, 4, 1> c(a, b, Matx_MatMulOp());
RyoheiHagimoto 0:0e0631af0305 2207 return reinterpret_cast<const Scalar&>(c);
RyoheiHagimoto 0:0e0631af0305 2208 }
RyoheiHagimoto 0:0e0631af0305 2209
RyoheiHagimoto 0:0e0631af0305 2210
RyoheiHagimoto 0:0e0631af0305 2211
RyoheiHagimoto 0:0e0631af0305 2212 //////////////////////////////// KeyPoint ///////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2213
RyoheiHagimoto 0:0e0631af0305 2214 inline
RyoheiHagimoto 0:0e0631af0305 2215 KeyPoint::KeyPoint()
RyoheiHagimoto 0:0e0631af0305 2216 : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {}
RyoheiHagimoto 0:0e0631af0305 2217
RyoheiHagimoto 0:0e0631af0305 2218 inline
RyoheiHagimoto 0:0e0631af0305 2219 KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int _class_id)
RyoheiHagimoto 0:0e0631af0305 2220 : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {}
RyoheiHagimoto 0:0e0631af0305 2221
RyoheiHagimoto 0:0e0631af0305 2222 inline
RyoheiHagimoto 0:0e0631af0305 2223 KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
RyoheiHagimoto 0:0e0631af0305 2224 : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {}
RyoheiHagimoto 0:0e0631af0305 2225
RyoheiHagimoto 0:0e0631af0305 2226
RyoheiHagimoto 0:0e0631af0305 2227
RyoheiHagimoto 0:0e0631af0305 2228 ///////////////////////////////// DMatch ////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2229
RyoheiHagimoto 0:0e0631af0305 2230 inline
RyoheiHagimoto 0:0e0631af0305 2231 DMatch::DMatch()
RyoheiHagimoto 0:0e0631af0305 2232 : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {}
RyoheiHagimoto 0:0e0631af0305 2233
RyoheiHagimoto 0:0e0631af0305 2234 inline
RyoheiHagimoto 0:0e0631af0305 2235 DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance)
RyoheiHagimoto 0:0e0631af0305 2236 : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {}
RyoheiHagimoto 0:0e0631af0305 2237
RyoheiHagimoto 0:0e0631af0305 2238 inline
RyoheiHagimoto 0:0e0631af0305 2239 DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance)
RyoheiHagimoto 0:0e0631af0305 2240 : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {}
RyoheiHagimoto 0:0e0631af0305 2241
RyoheiHagimoto 0:0e0631af0305 2242 inline
RyoheiHagimoto 0:0e0631af0305 2243 bool DMatch::operator < (const DMatch &m) const
RyoheiHagimoto 0:0e0631af0305 2244 {
RyoheiHagimoto 0:0e0631af0305 2245 return distance < m.distance;
RyoheiHagimoto 0:0e0631af0305 2246 }
RyoheiHagimoto 0:0e0631af0305 2247
RyoheiHagimoto 0:0e0631af0305 2248
RyoheiHagimoto 0:0e0631af0305 2249
RyoheiHagimoto 0:0e0631af0305 2250 ////////////////////////////// TermCriteria /////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2251
RyoheiHagimoto 0:0e0631af0305 2252 inline
RyoheiHagimoto 0:0e0631af0305 2253 TermCriteria::TermCriteria()
RyoheiHagimoto 0:0e0631af0305 2254 : type(0), maxCount(0), epsilon(0) {}
RyoheiHagimoto 0:0e0631af0305 2255
RyoheiHagimoto 0:0e0631af0305 2256 inline
RyoheiHagimoto 0:0e0631af0305 2257 TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon)
RyoheiHagimoto 0:0e0631af0305 2258 : type(_type), maxCount(_maxCount), epsilon(_epsilon) {}
RyoheiHagimoto 0:0e0631af0305 2259
RyoheiHagimoto 0:0e0631af0305 2260 //! @endcond
RyoheiHagimoto 0:0e0631af0305 2261
RyoheiHagimoto 0:0e0631af0305 2262 } // cv
RyoheiHagimoto 0:0e0631af0305 2263
RyoheiHagimoto 0:0e0631af0305 2264 #endif //OPENCV_CORE_TYPES_HPP