EstervQrCode 2.0.0
Library for qr code manipulation
Loading...
Searching...
No Matches
types.hpp
1/*M///////////////////////////////////////////////////////////////////////////////////////
2//
3// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4//
5// By downloading, copying, installing or using the software you agree to this license.
6// If you do not agree to this license, do not download, install,
7// copy or use the software.
8//
9//
10// License Agreement
11// For Open Source Computer Vision Library
12//
13// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16// Third party copyrights are property of their respective owners.
17//
18// Redistribution and use in source and binary forms, with or without modification,
19// are permitted provided that the following conditions are met:
20//
21// * Redistribution's of source code must retain the above copyright notice,
22// this list of conditions and the following disclaimer.
23//
24// * Redistribution's in binary form must reproduce the above copyright notice,
25// this list of conditions and the following disclaimer in the documentation
26// and/or other materials provided with the distribution.
27//
28// * The name of the copyright holders may not be used to endorse or promote products
29// derived from this software without specific prior written permission.
30//
31// This software is provided by the copyright holders and contributors "as is" and
32// any express or implied warranties, including, but not limited to, the implied
33// warranties of merchantability and fitness for a particular purpose are disclaimed.
34// In no event shall the Intel Corporation or contributors be liable for any direct,
35// indirect, incidental, special, exemplary, or consequential damages
36// (including, but not limited to, procurement of substitute goods or services;
37// loss of use, data, or profits; or business interruption) however caused
38// and on any theory of liability, whether in contract, strict liability,
39// or tort (including negligence or otherwise) arising in any way out of
40// the use of this software, even if advised of the possibility of such damage.
41//
42//M*/
43
44#ifndef OPENCV_CORE_TYPES_HPP
45#define OPENCV_CORE_TYPES_HPP
46
47#ifndef __cplusplus
48# error types.hpp header must be compiled as C++
49#endif
50
51#include <climits>
52#include <cfloat>
53#include <vector>
54#include <limits>
55
56#include "opencv2/core/cvdef.h"
57#include "opencv2/core/cvstd.hpp"
58#include "opencv2/core/matx.hpp"
59
60#ifdef _MSC_VER
61#pragma warning(push)
62#pragma warning(disable: 4459) // declaration of '...' hides global declaration
63#endif
64
65namespace cv
66{
67
70
72
79template<typename _Tp> class Complex
80{
81public:
82
85 Complex( _Tp _re, _Tp _im = 0 );
86
88 template<typename T2> operator Complex<T2>() const;
90 Complex conj() const;
91
92 _Tp re, im;
93};
94
97
98template<typename _Tp> class DataType< Complex<_Tp> >
99{
100public:
103 typedef _Tp channel_type;
104
105 enum { generic_type = 0,
107 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
108#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
111#endif
112 };
113
115};
116
117namespace traits {
118template<typename _Tp>
119struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; };
120template<typename _Tp>
121struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
122} // namespace
123
124
126
162template<typename _Tp> class Point_
163{
164public:
165 typedef _Tp value_type;
166
169 Point_(_Tp _x, _Tp _y);
170#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837
171 Point_(const Point_& pt);
172 Point_(Point_&& pt) CV_NOEXCEPT = default;
173#elif OPENCV_ABI_COMPATIBILITY < 500
174 Point_(const Point_& pt) = default;
176#endif
177 Point_(const Size_<_Tp>& sz);
179
180#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837
181 Point_& operator = (const Point_& pt);
182 Point_& operator = (Point_&& pt) CV_NOEXCEPT = default;
183#elif OPENCV_ABI_COMPATIBILITY < 500
184 Point_& operator = (const Point_& pt) = default;
186#endif
188 template<typename _Tp2> operator Point_<_Tp2>() const;
189
191 operator Vec<_Tp, 2>() const;
192
194 _Tp dot(const Point_& pt) const;
196 double ddot(const Point_& pt) const;
198 double cross(const Point_& pt) const;
200 bool inside(const Rect_<_Tp>& r) const;
201 _Tp x;
202 _Tp y;
203};
204
210
211template<typename _Tp> class DataType< Point_<_Tp> >
212{
213public:
216 typedef _Tp channel_type;
217
218 enum { generic_type = 0,
221#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
224#endif
225 };
226
228};
229
230namespace traits {
231template<typename _Tp>
232struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; };
233template<typename _Tp>
234struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
235} // namespace
236
237
239
254template<typename _Tp> class Point3_
255{
256public:
257 typedef _Tp value_type;
258
261 Point3_(_Tp _x, _Tp _y, _Tp _z);
262#if OPENCV_ABI_COMPATIBILITY < 500
263 Point3_(const Point3_& pt) = default;
265#endif
266 explicit Point3_(const Point_<_Tp>& pt);
268
269#if OPENCV_ABI_COMPATIBILITY < 500
270 Point3_& operator = (const Point3_& pt) = default;
272#endif
274 template<typename _Tp2> operator Point3_<_Tp2>() const;
276 operator Vec<_Tp, 3>() const;
277
279 _Tp dot(const Point3_& pt) const;
281 double ddot(const Point3_& pt) const;
283 Point3_ cross(const Point3_& pt) const;
284 _Tp x;
285 _Tp y;
286 _Tp z;
287};
288
292
293template<typename _Tp> class DataType< Point3_<_Tp> >
294{
295public:
298 typedef _Tp channel_type;
299
300 enum { generic_type = 0,
303#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
306#endif
307 };
308
310};
311
312namespace traits {
313template<typename _Tp>
314struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; };
315template<typename _Tp>
316struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; };
317} // namespace
318
320
334template<typename _Tp> class Size_
335{
336public:
337 typedef _Tp value_type;
338
341 Size_(_Tp _width, _Tp _height);
342#if OPENCV_ABI_COMPATIBILITY < 500
343 Size_(const Size_& sz) = default;
344 Size_(Size_&& sz) CV_NOEXCEPT = default;
345#endif
347
348#if OPENCV_ABI_COMPATIBILITY < 500
349 Size_& operator = (const Size_& sz) = default;
351#endif
353 _Tp area() const;
355 double aspectRatio() const;
357 bool empty() const;
358
360 template<typename _Tp2> operator Size_<_Tp2>() const;
361
362 _Tp width;
363 _Tp height;
364};
365
370typedef Size2i Size;
371
372template<typename _Tp> class DataType< Size_<_Tp> >
373{
374public:
377 typedef _Tp channel_type;
378
379 enum { generic_type = 0,
381 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
382#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
385#endif
386 };
387
389};
390
391namespace traits {
392template<typename _Tp>
393struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; };
394template<typename _Tp>
395struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
396} // namespace
397
399
443template<typename _Tp> class Rect_
444{
445public:
446 typedef _Tp value_type;
447
450 Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
451#if OPENCV_ABI_COMPATIBILITY < 500
452 Rect_(const Rect_& r) = default;
453 Rect_(Rect_&& r) CV_NOEXCEPT = default;
454#endif
455 Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz);
457
458#if OPENCV_ABI_COMPATIBILITY < 500
459 Rect_& operator = (const Rect_& r) = default;
461#endif
466
470 _Tp area() const;
472 bool empty() const;
473
475 template<typename _Tp2> operator Rect_<_Tp2>() const;
476
478 bool contains(const Point_<_Tp>& pt) const;
479
480 _Tp x;
481 _Tp y;
482 _Tp width;
483 _Tp height;
484};
485
489typedef Rect2i Rect;
490
491template<typename _Tp> class DataType< Rect_<_Tp> >
492{
493public:
496 typedef _Tp channel_type;
497
498 enum { generic_type = 0,
501#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
504#endif
505 };
506
508};
509
510namespace traits {
511template<typename _Tp>
512struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; };
513template<typename _Tp>
514struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; };
515} // namespace
516
518
569
570template<> class DataType< RotatedRect >
571{
572public:
575 typedef float channel_type;
576
577 enum { generic_type = 0,
578 channels = (int)sizeof(value_type)/sizeof(channel_type), // 5
580#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
583#endif
584 };
585
587};
588
589namespace traits {
590template<>
591struct Depth< RotatedRect > { enum { value = Depth<float>::value }; };
592template<>
593struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth<float>::value, (int)sizeof(RotatedRect)/sizeof(float)) }; };
594} // namespace
595
596
598
623{
624public:
626 Range(int _start, int _end);
627 int size() const;
628 bool empty() const;
629 static Range all();
630
631 int start, end;
632};
633
634template<> class DataType<Range>
635{
636public:
639 typedef int channel_type;
640
641 enum { generic_type = 0,
644#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
647#endif
648 };
649
651};
652
653namespace traits {
654template<>
655struct Depth< Range > { enum { value = Depth<int>::value }; };
656template<>
657struct Type< Range > { enum { value = CV_MAKETYPE(Depth<int>::value, 2) }; };
658} // namespace
659
660
662
669template<typename _Tp> class Scalar_ : public Vec<_Tp, 4>
670{
671public:
674 Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0);
675 Scalar_(_Tp v0);
676
677 Scalar_(const Scalar_& s);
679
682
683 template<typename _Tp2, int cn>
685
687 static Scalar_<_Tp> all(_Tp v0);
688
690 template<typename T2> operator Scalar_<T2>() const;
691
693 Scalar_<_Tp> mul(const Scalar_<_Tp>& a, double scale=1 ) const;
694
697
699 bool isReal() const;
700};
701
703
704template<typename _Tp> class DataType< Scalar_<_Tp> >
705{
706public:
709 typedef _Tp channel_type;
710
711 enum { generic_type = 0,
714#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
717#endif
718 };
719
721};
722
723namespace traits {
724template<typename _Tp>
725struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; };
726template<typename _Tp>
727struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; };
728} // namespace
729
730
732
745{
746public:
757 KeyPoint(Point2f pt, float size, float angle=-1, float response=0, int octave=0, int class_id=-1);
767 CV_WRAP KeyPoint(float x, float y, float size, float angle=-1, float response=0, int octave=0, int class_id=-1);
768
769 size_t hash() const;
770
780 CV_WRAP static void convert(const std::vector<KeyPoint>& keypoints,
782 const std::vector<int>& keypointIndexes=std::vector<int>());
791 CV_WRAP static void convert(const std::vector<Point2f>& points2f,
792 CV_OUT std::vector<KeyPoint>& keypoints,
793 float size=1, float response=1, int octave=0, int class_id=-1);
794
802 CV_WRAP static float overlap(const KeyPoint& kp1, const KeyPoint& kp2);
803
812};
813
814#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
815template<> class DataType<KeyPoint>
816{
817public:
818 typedef KeyPoint value_type;
819 typedef float work_type;
820 typedef float channel_type;
821
822 enum { generic_type = 0,
824 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7
825 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
827 };
828
829 typedef Vec<channel_type, channels> vec_type;
830};
831#endif
832
833
835
842{
843public:
845 CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance);
846 CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance);
847
851
853
854 // less is better
855 bool operator<(const DMatch &m) const;
856};
857
858#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
859template<> class DataType<DMatch>
860{
861public:
862 typedef DMatch value_type;
863 typedef int work_type;
864 typedef int channel_type;
865
866 enum { generic_type = 0,
868 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4
869 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
871 };
872
873 typedef Vec<channel_type, channels> vec_type;
874};
875#endif
876
877
879
886{
887public:
891 enum Type
892 {
893 COUNT=1,
894 MAX_ITER=COUNT,
895 EPS=2
896 };
897
905 TermCriteria(int type, int maxCount, double epsilon);
906
907 inline bool isValid() const
908 {
909 const bool isCount = (type & COUNT) && maxCount > 0;
910 const bool isEps = (type & EPS) && !cvIsNaN(epsilon);
911 return isCount || isEps;
912 }
913
914 int type;
916 double epsilon;
917};
918
919
921
923
926
960{
961public:
965 Moments(double m00, double m10, double m01, double m20, double m11,
966 double m02, double m30, double m21, double m12, double m03 );
968 //Moments( const CvMoments& moments );
970 //operator CvMoments() const;
971
974 CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
976
979 CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
981
984 CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
986};
987
988template<> class DataType<Moments>
989{
990public:
992 typedef double work_type;
993 typedef double channel_type;
994
995 enum { generic_type = 0,
996 channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24
997 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
998#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
1001#endif
1003
1005};
1006
1007namespace traits {
1008template<>
1009struct Depth< Moments > { enum { value = Depth<double>::value }; };
1010template<>
1011struct Type< Moments > { enum { value = CV_MAKETYPE(Depth<double>::value, (int)(sizeof(Moments)/sizeof(double))) }; };
1012} // namespace
1013
1015
1017
1021
1023
1024template<typename _Tp> inline
1026 : re(0), im(0) {}
1027
1028template<typename _Tp> inline
1029Complex<_Tp>::Complex( _Tp _re, _Tp _im )
1030 : re(_re), im(_im) {}
1031
1032template<typename _Tp> template<typename T2> inline
1033Complex<_Tp>::operator Complex<T2>() const
1034{
1035 return Complex<T2>(saturate_cast<T2>(re), saturate_cast<T2>(im));
1036}
1037
1038template<typename _Tp> inline
1039Complex<_Tp> Complex<_Tp>::conj() const
1040{
1041 return Complex<_Tp>(re, -im);
1042}
1043
1044
1045template<typename _Tp> static inline
1046bool operator == (const Complex<_Tp>& a, const Complex<_Tp>& b)
1047{
1048 return a.re == b.re && a.im == b.im;
1049}
1050
1051template<typename _Tp> static inline
1052bool operator != (const Complex<_Tp>& a, const Complex<_Tp>& b)
1053{
1054 return a.re != b.re || a.im != b.im;
1055}
1056
1057template<typename _Tp> static inline
1058Complex<_Tp> operator + (const Complex<_Tp>& a, const Complex<_Tp>& b)
1059{
1060 return Complex<_Tp>( a.re + b.re, a.im + b.im );
1061}
1062
1063template<typename _Tp> static inline
1064Complex<_Tp>& operator += (Complex<_Tp>& a, const Complex<_Tp>& b)
1065{
1066 a.re += b.re; a.im += b.im;
1067 return a;
1068}
1069
1070template<typename _Tp> static inline
1071Complex<_Tp> operator - (const Complex<_Tp>& a, const Complex<_Tp>& b)
1072{
1073 return Complex<_Tp>( a.re - b.re, a.im - b.im );
1074}
1075
1076template<typename _Tp> static inline
1077Complex<_Tp>& operator -= (Complex<_Tp>& a, const Complex<_Tp>& b)
1078{
1079 a.re -= b.re; a.im -= b.im;
1080 return a;
1081}
1082
1083template<typename _Tp> static inline
1084Complex<_Tp> operator - (const Complex<_Tp>& a)
1085{
1086 return Complex<_Tp>(-a.re, -a.im);
1087}
1088
1089template<typename _Tp> static inline
1090Complex<_Tp> operator * (const Complex<_Tp>& a, const Complex<_Tp>& b)
1091{
1092 return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
1093}
1094
1095template<typename _Tp> static inline
1096Complex<_Tp> operator * (const Complex<_Tp>& a, _Tp b)
1097{
1098 return Complex<_Tp>( a.re*b, a.im*b );
1099}
1100
1101template<typename _Tp> static inline
1102Complex<_Tp> operator * (_Tp b, const Complex<_Tp>& a)
1103{
1104 return Complex<_Tp>( a.re*b, a.im*b );
1105}
1106
1107template<typename _Tp> static inline
1108Complex<_Tp> operator + (const Complex<_Tp>& a, _Tp b)
1109{
1110 return Complex<_Tp>( a.re + b, a.im );
1111}
1112
1113template<typename _Tp> static inline
1114Complex<_Tp> operator - (const Complex<_Tp>& a, _Tp b)
1115{ return Complex<_Tp>( a.re - b, a.im ); }
1116
1117template<typename _Tp> static inline
1118Complex<_Tp> operator + (_Tp b, const Complex<_Tp>& a)
1119{
1120 return Complex<_Tp>( a.re + b, a.im );
1121}
1122
1123template<typename _Tp> static inline
1124Complex<_Tp> operator - (_Tp b, const Complex<_Tp>& a)
1125{
1126 return Complex<_Tp>( b - a.re, -a.im );
1127}
1128
1129template<typename _Tp> static inline
1130Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b)
1131{
1132 a.re += b; return a;
1133}
1134
1135template<typename _Tp> static inline
1136Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b)
1137{
1138 a.re -= b; return a;
1139}
1140
1141template<typename _Tp> static inline
1142Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b)
1143{
1144 a.re *= b; a.im *= b; return a;
1145}
1146
1147template<typename _Tp> static inline
1148double abs(const Complex<_Tp>& a)
1149{
1150 return std::sqrt( (double)a.re*a.re + (double)a.im*a.im);
1151}
1152
1153template<typename _Tp> static inline
1154Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b)
1155{
1156 double t = 1./((double)b.re*b.re + (double)b.im*b.im);
1157 return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t),
1158 (_Tp)((-a.re*b.im + a.im*b.re)*t) );
1159}
1160
1161template<typename _Tp> static inline
1162Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b)
1163{
1164 a = a / b;
1165 return a;
1166}
1167
1168template<typename _Tp> static inline
1169Complex<_Tp> operator / (const Complex<_Tp>& a, _Tp b)
1170{
1171 _Tp t = (_Tp)1/b;
1172 return Complex<_Tp>( a.re*t, a.im*t );
1173}
1174
1175template<typename _Tp> static inline
1176Complex<_Tp> operator / (_Tp b, const Complex<_Tp>& a)
1177{
1178 return Complex<_Tp>(b)/a;
1179}
1180
1181template<typename _Tp> static inline
1182Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b)
1183{
1184 _Tp t = (_Tp)1/b;
1185 a.re *= t; a.im *= t; return a;
1186}
1187
1188
1189
1191
1192template<typename _Tp> inline
1194 : x(0), y(0) {}
1195
1196template<typename _Tp> inline
1197Point_<_Tp>::Point_(_Tp _x, _Tp _y)
1198 : x(_x), y(_y) {}
1199
1200#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837
1201template<typename _Tp> inline
1202Point_<_Tp>::Point_(const Point_& pt)
1203 : x(pt.x), y(pt.y) {}
1204#endif
1205
1206template<typename _Tp> inline
1207Point_<_Tp>::Point_(const Size_<_Tp>& sz)
1208 : x(sz.width), y(sz.height) {}
1209
1210template<typename _Tp> inline
1211Point_<_Tp>::Point_(const Vec<_Tp,2>& v)
1212 : x(v[0]), y(v[1]) {}
1213
1214#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837
1215template<typename _Tp> inline
1216Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt)
1217{
1218 x = pt.x; y = pt.y;
1219 return *this;
1220}
1221#endif
1222
1223template<typename _Tp> template<typename _Tp2> inline
1224Point_<_Tp>::operator Point_<_Tp2>() const
1225{
1226 return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y));
1227}
1228
1229template<typename _Tp> inline
1230Point_<_Tp>::operator Vec<_Tp, 2>() const
1231{
1232 return Vec<_Tp, 2>(x, y);
1233}
1234
1235template<typename _Tp> inline
1236_Tp Point_<_Tp>::dot(const Point_& pt) const
1237{
1238 return saturate_cast<_Tp>(x*pt.x + y*pt.y);
1239}
1240
1241template<typename _Tp> inline
1242double Point_<_Tp>::ddot(const Point_& pt) const
1243{
1244 return (double)x*(double)(pt.x) + (double)y*(double)(pt.y);
1245}
1246
1247template<typename _Tp> inline
1248double Point_<_Tp>::cross(const Point_& pt) const
1249{
1250 return (double)x*pt.y - (double)y*pt.x;
1251}
1252
1253template<typename _Tp> inline bool
1254Point_<_Tp>::inside( const Rect_<_Tp>& r ) const
1255{
1256 return r.contains(*this);
1257}
1258
1259
1260template<typename _Tp> static inline
1261Point_<_Tp>& operator += (Point_<_Tp>& a, const Point_<_Tp>& b)
1262{
1263 a.x += b.x;
1264 a.y += b.y;
1265 return a;
1266}
1267
1268template<typename _Tp> static inline
1269Point_<_Tp>& operator -= (Point_<_Tp>& a, const Point_<_Tp>& b)
1270{
1271 a.x -= b.x;
1272 a.y -= b.y;
1273 return a;
1274}
1275
1276template<typename _Tp> static inline
1277Point_<_Tp>& operator *= (Point_<_Tp>& a, int b)
1278{
1279 a.x = saturate_cast<_Tp>(a.x * b);
1280 a.y = saturate_cast<_Tp>(a.y * b);
1281 return a;
1282}
1283
1284template<typename _Tp> static inline
1285Point_<_Tp>& operator *= (Point_<_Tp>& a, float b)
1286{
1287 a.x = saturate_cast<_Tp>(a.x * b);
1288 a.y = saturate_cast<_Tp>(a.y * b);
1289 return a;
1290}
1291
1292template<typename _Tp> static inline
1293Point_<_Tp>& operator *= (Point_<_Tp>& a, double b)
1294{
1295 a.x = saturate_cast<_Tp>(a.x * b);
1296 a.y = saturate_cast<_Tp>(a.y * b);
1297 return a;
1298}
1299
1300template<typename _Tp> static inline
1301Point_<_Tp>& operator /= (Point_<_Tp>& a, int b)
1302{
1303 a.x = saturate_cast<_Tp>(a.x / b);
1304 a.y = saturate_cast<_Tp>(a.y / b);
1305 return a;
1306}
1307
1308template<typename _Tp> static inline
1309Point_<_Tp>& operator /= (Point_<_Tp>& a, float b)
1310{
1311 a.x = saturate_cast<_Tp>(a.x / b);
1312 a.y = saturate_cast<_Tp>(a.y / b);
1313 return a;
1314}
1315
1316template<typename _Tp> static inline
1317Point_<_Tp>& operator /= (Point_<_Tp>& a, double b)
1318{
1319 a.x = saturate_cast<_Tp>(a.x / b);
1320 a.y = saturate_cast<_Tp>(a.y / b);
1321 return a;
1322}
1323
1324template<typename _Tp> static inline
1325double norm(const Point_<_Tp>& pt)
1326{
1327 return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y);
1328}
1329
1330template<typename _Tp> static inline
1331bool operator == (const Point_<_Tp>& a, const Point_<_Tp>& b)
1332{
1333 return a.x == b.x && a.y == b.y;
1334}
1335
1336template<typename _Tp> static inline
1337bool operator != (const Point_<_Tp>& a, const Point_<_Tp>& b)
1338{
1339 return a.x != b.x || a.y != b.y;
1340}
1341
1342template<typename _Tp> static inline
1343Point_<_Tp> operator + (const Point_<_Tp>& a, const Point_<_Tp>& b)
1344{
1345 return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) );
1346}
1347
1348template<typename _Tp> static inline
1349Point_<_Tp> operator - (const Point_<_Tp>& a, const Point_<_Tp>& b)
1350{
1351 return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) );
1352}
1353
1354template<typename _Tp> static inline
1355Point_<_Tp> operator - (const Point_<_Tp>& a)
1356{
1357 return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) );
1358}
1359
1360template<typename _Tp> static inline
1361Point_<_Tp> operator * (const Point_<_Tp>& a, int b)
1362{
1363 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
1364}
1365
1366template<typename _Tp> static inline
1367Point_<_Tp> operator * (int a, const Point_<_Tp>& b)
1368{
1369 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
1370}
1371
1372template<typename _Tp> static inline
1373Point_<_Tp> operator * (const Point_<_Tp>& a, float b)
1374{
1375 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
1376}
1377
1378template<typename _Tp> static inline
1379Point_<_Tp> operator * (float a, const Point_<_Tp>& b)
1380{
1381 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
1382}
1383
1384template<typename _Tp> static inline
1385Point_<_Tp> operator * (const Point_<_Tp>& a, double b)
1386{
1387 return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) );
1388}
1389
1390template<typename _Tp> static inline
1391Point_<_Tp> operator * (double a, const Point_<_Tp>& b)
1392{
1393 return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) );
1394}
1395
1396template<typename _Tp> static inline
1397Point_<_Tp> operator * (const Matx<_Tp, 2, 2>& a, const Point_<_Tp>& b)
1398{
1399 Matx<_Tp, 2, 1> tmp = a * Vec<_Tp,2>(b.x, b.y);
1400 return Point_<_Tp>(tmp.val[0], tmp.val[1]);
1401}
1402
1403template<typename _Tp> static inline
1404Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b)
1405{
1406 Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, 1);
1407 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
1408}
1409
1410template<typename _Tp> static inline
1411Point_<_Tp> operator / (const Point_<_Tp>& a, int b)
1412{
1413 Point_<_Tp> tmp(a);
1414 tmp /= b;
1415 return tmp;
1416}
1417
1418template<typename _Tp> static inline
1419Point_<_Tp> operator / (const Point_<_Tp>& a, float b)
1420{
1421 Point_<_Tp> tmp(a);
1422 tmp /= b;
1423 return tmp;
1424}
1425
1426template<typename _Tp> static inline
1427Point_<_Tp> operator / (const Point_<_Tp>& a, double b)
1428{
1429 Point_<_Tp> tmp(a);
1430 tmp /= b;
1431 return tmp;
1432}
1433
1434
1435template<typename _AccTp> static inline _AccTp normL2Sqr(const Point_<int>& pt);
1436template<typename _AccTp> static inline _AccTp normL2Sqr(const Point_<int64>& pt);
1437template<typename _AccTp> static inline _AccTp normL2Sqr(const Point_<float>& pt);
1438template<typename _AccTp> static inline _AccTp normL2Sqr(const Point_<double>& pt);
1439
1440template<> inline int normL2Sqr<int>(const Point_<int>& pt) { return pt.dot(pt); }
1441template<> inline int64 normL2Sqr<int64>(const Point_<int64>& pt) { return pt.dot(pt); }
1442template<> inline float normL2Sqr<float>(const Point_<float>& pt) { return pt.dot(pt); }
1443template<> inline double normL2Sqr<double>(const Point_<int>& pt) { return pt.dot(pt); }
1444
1445template<> inline double normL2Sqr<double>(const Point_<float>& pt) { return pt.ddot(pt); }
1446template<> inline double normL2Sqr<double>(const Point_<double>& pt) { return pt.ddot(pt); }
1447
1448
1449
1451
1452template<typename _Tp> inline
1454 : x(0), y(0), z(0) {}
1455
1456template<typename _Tp> inline
1457Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z)
1458 : x(_x), y(_y), z(_z) {}
1459
1460template<typename _Tp> inline
1461Point3_<_Tp>::Point3_(const Point_<_Tp>& pt)
1462 : x(pt.x), y(pt.y), z(_Tp()) {}
1463
1464template<typename _Tp> inline
1465Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v)
1466 : x(v[0]), y(v[1]), z(v[2]) {}
1467
1468template<typename _Tp> template<typename _Tp2> inline
1469Point3_<_Tp>::operator Point3_<_Tp2>() const
1470{
1471 return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z));
1472}
1473
1474template<typename _Tp> inline
1475Point3_<_Tp>::operator Vec<_Tp, 3>() const
1476{
1477 return Vec<_Tp, 3>(x, y, z);
1478}
1479
1480template<typename _Tp> inline
1481_Tp Point3_<_Tp>::dot(const Point3_& pt) const
1482{
1483 return saturate_cast<_Tp>(x*pt.x + y*pt.y + z*pt.z);
1484}
1485
1486template<typename _Tp> inline
1487double Point3_<_Tp>::ddot(const Point3_& pt) const
1488{
1489 return (double)x*pt.x + (double)y*pt.y + (double)z*pt.z;
1490}
1491
1492template<typename _Tp> inline
1493Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp>& pt) const
1494{
1495 return Point3_<_Tp>(y*pt.z - z*pt.y, z*pt.x - x*pt.z, x*pt.y - y*pt.x);
1496}
1497
1498
1499template<typename _Tp> static inline
1500Point3_<_Tp>& operator += (Point3_<_Tp>& a, const Point3_<_Tp>& b)
1501{
1502 a.x += b.x;
1503 a.y += b.y;
1504 a.z += b.z;
1505 return a;
1506}
1507
1508template<typename _Tp> static inline
1509Point3_<_Tp>& operator -= (Point3_<_Tp>& a, const Point3_<_Tp>& b)
1510{
1511 a.x -= b.x;
1512 a.y -= b.y;
1513 a.z -= b.z;
1514 return a;
1515}
1516
1517template<typename _Tp> static inline
1518Point3_<_Tp>& operator *= (Point3_<_Tp>& a, int b)
1519{
1520 a.x = saturate_cast<_Tp>(a.x * b);
1521 a.y = saturate_cast<_Tp>(a.y * b);
1522 a.z = saturate_cast<_Tp>(a.z * b);
1523 return a;
1524}
1525
1526template<typename _Tp> static inline
1527Point3_<_Tp>& operator *= (Point3_<_Tp>& a, float b)
1528{
1529 a.x = saturate_cast<_Tp>(a.x * b);
1530 a.y = saturate_cast<_Tp>(a.y * b);
1531 a.z = saturate_cast<_Tp>(a.z * b);
1532 return a;
1533}
1534
1535template<typename _Tp> static inline
1536Point3_<_Tp>& operator *= (Point3_<_Tp>& a, double b)
1537{
1538 a.x = saturate_cast<_Tp>(a.x * b);
1539 a.y = saturate_cast<_Tp>(a.y * b);
1540 a.z = saturate_cast<_Tp>(a.z * b);
1541 return a;
1542}
1543
1544template<typename _Tp> static inline
1545Point3_<_Tp>& operator /= (Point3_<_Tp>& a, int b)
1546{
1547 a.x = saturate_cast<_Tp>(a.x / b);
1548 a.y = saturate_cast<_Tp>(a.y / b);
1549 a.z = saturate_cast<_Tp>(a.z / b);
1550 return a;
1551}
1552
1553template<typename _Tp> static inline
1554Point3_<_Tp>& operator /= (Point3_<_Tp>& a, float b)
1555{
1556 a.x = saturate_cast<_Tp>(a.x / b);
1557 a.y = saturate_cast<_Tp>(a.y / b);
1558 a.z = saturate_cast<_Tp>(a.z / b);
1559 return a;
1560}
1561
1562template<typename _Tp> static inline
1563Point3_<_Tp>& operator /= (Point3_<_Tp>& a, double b)
1564{
1565 a.x = saturate_cast<_Tp>(a.x / b);
1566 a.y = saturate_cast<_Tp>(a.y / b);
1567 a.z = saturate_cast<_Tp>(a.z / b);
1568 return a;
1569}
1570
1571template<typename _Tp> static inline
1572double norm(const Point3_<_Tp>& pt)
1573{
1574 return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y + (double)pt.z*pt.z);
1575}
1576
1577template<typename _Tp> static inline
1578bool operator == (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
1579{
1580 return a.x == b.x && a.y == b.y && a.z == b.z;
1581}
1582
1583template<typename _Tp> static inline
1584bool operator != (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
1585{
1586 return a.x != b.x || a.y != b.y || a.z != b.z;
1587}
1588
1589template<typename _Tp> static inline
1590Point3_<_Tp> operator + (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
1591{
1592 return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y), saturate_cast<_Tp>(a.z + b.z));
1593}
1594
1595template<typename _Tp> static inline
1596Point3_<_Tp> operator - (const Point3_<_Tp>& a, const Point3_<_Tp>& b)
1597{
1598 return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y), saturate_cast<_Tp>(a.z - b.z));
1599}
1600
1601template<typename _Tp> static inline
1602Point3_<_Tp> operator - (const Point3_<_Tp>& a)
1603{
1604 return Point3_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y), saturate_cast<_Tp>(-a.z) );
1605}
1606
1607template<typename _Tp> static inline
1608Point3_<_Tp> operator * (const Point3_<_Tp>& a, int b)
1609{
1610 return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b), saturate_cast<_Tp>(a.z*b) );
1611}
1612
1613template<typename _Tp> static inline
1614Point3_<_Tp> operator * (int a, const Point3_<_Tp>& b)
1615{
1616 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
1617}
1618
1619template<typename _Tp> static inline
1620Point3_<_Tp> operator * (const Point3_<_Tp>& a, float b)
1621{
1622 return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) );
1623}
1624
1625template<typename _Tp> static inline
1626Point3_<_Tp> operator * (float a, const Point3_<_Tp>& b)
1627{
1628 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
1629}
1630
1631template<typename _Tp> static inline
1632Point3_<_Tp> operator * (const Point3_<_Tp>& a, double b)
1633{
1634 return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) );
1635}
1636
1637template<typename _Tp> static inline
1638Point3_<_Tp> operator * (double a, const Point3_<_Tp>& b)
1639{
1640 return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) );
1641}
1642
1643template<typename _Tp> static inline
1644Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point3_<_Tp>& b)
1645{
1646 Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, b.z);
1647 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
1648}
1649
1650template<typename _Tp> static inline
1651Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b)
1652{
1653 return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1);
1654}
1655
1656template<typename _Tp> static inline
1657Point3_<_Tp> operator / (const Point3_<_Tp>& a, int b)
1658{
1659 Point3_<_Tp> tmp(a);
1660 tmp /= b;
1661 return tmp;
1662}
1663
1664template<typename _Tp> static inline
1665Point3_<_Tp> operator / (const Point3_<_Tp>& a, float b)
1666{
1667 Point3_<_Tp> tmp(a);
1668 tmp /= b;
1669 return tmp;
1670}
1671
1672template<typename _Tp> static inline
1673Point3_<_Tp> operator / (const Point3_<_Tp>& a, double b)
1674{
1675 Point3_<_Tp> tmp(a);
1676 tmp /= b;
1677 return tmp;
1678}
1679
1680
1681
1683
1684template<typename _Tp> inline
1686 : width(0), height(0) {}
1687
1688template<typename _Tp> inline
1689Size_<_Tp>::Size_(_Tp _width, _Tp _height)
1690 : width(_width), height(_height) {}
1691
1692template<typename _Tp> inline
1693Size_<_Tp>::Size_(const Point_<_Tp>& pt)
1694 : width(pt.x), height(pt.y) {}
1695
1696template<typename _Tp> template<typename _Tp2> inline
1697Size_<_Tp>::operator Size_<_Tp2>() const
1698{
1699 return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
1700}
1701
1702template<typename _Tp> inline
1703_Tp Size_<_Tp>::area() const
1704{
1705 const _Tp result = width * height;
1707 || width == 0 || result / width == height); // make sure the result fits in the return value
1708 return result;
1709}
1710
1711template<typename _Tp> inline
1712double Size_<_Tp>::aspectRatio() const
1713{
1714 return width / static_cast<double>(height);
1715}
1716
1717template<typename _Tp> inline
1718bool Size_<_Tp>::empty() const
1719{
1720 return width <= 0 || height <= 0;
1721}
1722
1723
1724template<typename _Tp> static inline
1725Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b)
1726{
1727 a.width *= b;
1728 a.height *= b;
1729 return a;
1730}
1731
1732template<typename _Tp> static inline
1733Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b)
1734{
1735 Size_<_Tp> tmp(a);
1736 tmp *= b;
1737 return tmp;
1738}
1739
1740template<typename _Tp> static inline
1741Size_<_Tp>& operator /= (Size_<_Tp>& a, _Tp b)
1742{
1743 a.width /= b;
1744 a.height /= b;
1745 return a;
1746}
1747
1748template<typename _Tp> static inline
1749Size_<_Tp> operator / (const Size_<_Tp>& a, _Tp b)
1750{
1751 Size_<_Tp> tmp(a);
1752 tmp /= b;
1753 return tmp;
1754}
1755
1756template<typename _Tp> static inline
1757Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b)
1758{
1759 a.width += b.width;
1760 a.height += b.height;
1761 return a;
1762}
1763
1764template<typename _Tp> static inline
1765Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b)
1766{
1767 Size_<_Tp> tmp(a);
1768 tmp += b;
1769 return tmp;
1770}
1771
1772template<typename _Tp> static inline
1773Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b)
1774{
1775 a.width -= b.width;
1776 a.height -= b.height;
1777 return a;
1778}
1779
1780template<typename _Tp> static inline
1781Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b)
1782{
1783 Size_<_Tp> tmp(a);
1784 tmp -= b;
1785 return tmp;
1786}
1787
1788template<typename _Tp> static inline
1789bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b)
1790{
1791 return a.width == b.width && a.height == b.height;
1792}
1793
1794template<typename _Tp> static inline
1795bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b)
1796{
1797 return !(a == b);
1798}
1799
1800
1801
1803
1804template<typename _Tp> inline
1806 : x(0), y(0), width(0), height(0) {}
1807
1808template<typename _Tp> inline
1809Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height)
1810 : x(_x), y(_y), width(_width), height(_height) {}
1811
1812template<typename _Tp> inline
1813Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz)
1814 : x(org.x), y(org.y), width(sz.width), height(sz.height) {}
1815
1816template<typename _Tp> inline
1817Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2)
1818{
1819 x = std::min(pt1.x, pt2.x);
1820 y = std::min(pt1.y, pt2.y);
1821 width = std::max(pt1.x, pt2.x) - x;
1822 height = std::max(pt1.y, pt2.y) - y;
1823}
1824
1825template<typename _Tp> inline
1826Point_<_Tp> Rect_<_Tp>::tl() const
1827{
1828 return Point_<_Tp>(x,y);
1829}
1830
1831template<typename _Tp> inline
1832Point_<_Tp> Rect_<_Tp>::br() const
1833{
1834 return Point_<_Tp>(x + width, y + height);
1835}
1836
1837template<typename _Tp> inline
1838Size_<_Tp> Rect_<_Tp>::size() const
1839{
1840 return Size_<_Tp>(width, height);
1841}
1842
1843template<typename _Tp> inline
1844_Tp Rect_<_Tp>::area() const
1845{
1846 const _Tp result = width * height;
1848 || width == 0 || result / width == height); // make sure the result fits in the return value
1849 return result;
1850}
1851
1852template<typename _Tp> inline
1853bool Rect_<_Tp>::empty() const
1854{
1855 return width <= 0 || height <= 0;
1856}
1857
1858template<typename _Tp> template<typename _Tp2> inline
1859Rect_<_Tp>::operator Rect_<_Tp2>() const
1860{
1861 return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
1862}
1863
1864template<typename _Tp> inline
1865bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const
1866{
1867 return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height;
1868}
1869
1870
1871template<typename _Tp> static inline
1872Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b )
1873{
1874 a.x += b.x;
1875 a.y += b.y;
1876 return a;
1877}
1878
1879template<typename _Tp> static inline
1880Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Point_<_Tp>& b )
1881{
1882 a.x -= b.x;
1883 a.y -= b.y;
1884 return a;
1885}
1886
1887template<typename _Tp> static inline
1888Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b )
1889{
1890 a.width += b.width;
1891 a.height += b.height;
1892 return a;
1893}
1894
1895template<typename _Tp> static inline
1896Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
1897{
1898 const _Tp width = a.width - b.width;
1899 const _Tp height = a.height - b.height;
1900 CV_DbgAssert(width >= 0 && height >= 0);
1901 a.width = width;
1902 a.height = height;
1903 return a;
1904}
1905
1906template<typename _Tp> static inline
1907Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
1908{
1909 if (a.empty() || b.empty()) {
1910 a = Rect();
1911 return a;
1912 }
1913 const Rect_<_Tp>& Rx_min = (a.x < b.x) ? a : b;
1914 const Rect_<_Tp>& Rx_max = (a.x < b.x) ? b : a;
1915 const Rect_<_Tp>& Ry_min = (a.y < b.y) ? a : b;
1916 const Rect_<_Tp>& Ry_max = (a.y < b.y) ? b : a;
1917 // Looking at the formula below, we will compute Rx_min.width - (Rx_max.x - Rx_min.x)
1918 // but we want to avoid overflows. Rx_min.width >= 0 and (Rx_max.x - Rx_min.x) >= 0
1919 // by definition so the difference does not overflow. The only thing that can overflow
1920 // is (Rx_max.x - Rx_min.x). And it can only overflow if Rx_min.x < 0.
1921 // Let us first deal with the following case.
1922 if ((Rx_min.x < 0 && Rx_min.x + Rx_min.width < Rx_max.x) ||
1923 (Ry_min.y < 0 && Ry_min.y + Ry_min.height < Ry_max.y)) {
1924 a = Rect();
1925 return a;
1926 }
1927 // We now know that either Rx_min.x >= 0, or
1928 // Rx_min.x < 0 && Rx_min.x + Rx_min.width >= Rx_max.x and therefore
1929 // Rx_min.width >= (Rx_max.x - Rx_min.x) which means (Rx_max.x - Rx_min.x)
1930 // is inferior to a valid int and therefore does not overflow.
1931 a.width = std::min(Rx_min.width - (Rx_max.x - Rx_min.x), Rx_max.width);
1932 a.height = std::min(Ry_min.height - (Ry_max.y - Ry_min.y), Ry_max.height);
1933 a.x = Rx_max.x;
1934 a.y = Ry_max.y;
1935 if (a.empty())
1936 a = Rect();
1937 return a;
1938}
1939
1940template<typename _Tp> static inline
1941Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
1942{
1943 if (a.empty()) {
1944 a = b;
1945 }
1946 else if (!b.empty()) {
1947 _Tp x1 = std::min(a.x, b.x);
1948 _Tp y1 = std::min(a.y, b.y);
1949 a.width = std::max(a.x + a.width, b.x + b.width) - x1;
1950 a.height = std::max(a.y + a.height, b.y + b.height) - y1;
1951 a.x = x1;
1952 a.y = y1;
1953 }
1954 return a;
1955}
1956
1957template<typename _Tp> static inline
1958bool operator == (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
1959{
1960 return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
1961}
1962
1963template<typename _Tp> static inline
1964bool operator != (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
1965{
1966 return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height;
1967}
1968
1969template<typename _Tp> static inline
1970Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Point_<_Tp>& b)
1971{
1972 return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height );
1973}
1974
1975template<typename _Tp> static inline
1976Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Point_<_Tp>& b)
1977{
1978 return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height );
1979}
1980
1981template<typename _Tp> static inline
1982Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b)
1983{
1984 return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
1985}
1986
1987template<typename _Tp> static inline
1988Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Size_<_Tp>& b)
1989{
1990 const _Tp width = a.width - b.width;
1991 const _Tp height = a.height - b.height;
1992 CV_DbgAssert(width >= 0 && height >= 0);
1993 return Rect_<_Tp>( a.x, a.y, width, height );
1994}
1995
1996template<typename _Tp> static inline
1997Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
1998{
1999 Rect_<_Tp> c = a;
2000 return c &= b;
2001}
2002
2003template<typename _Tp> static inline
2004Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
2005{
2006 Rect_<_Tp> c = a;
2007 return c |= b;
2008}
2009
2016template<typename _Tp> static inline
2017double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) {
2018 _Tp Aa = a.area();
2019 _Tp Ab = b.area();
2020
2021 if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) {
2022 // jaccard_index = 1 -> distance = 0
2023 return 0.0;
2024 }
2025
2026 double Aab = (a & b).area();
2027 // distance = 1 - jaccard_index
2028 return 1.0 - Aab / (Aa + Ab - Aab);
2029}
2030
2038CV_EXPORTS_W inline double rectangleIntersectionArea(const Rect2d& a, const Rect2d& b) { return (a & b).area(); }
2039
2041
2042inline
2044 : center(), size(), angle(0) {}
2045
2046inline
2047RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle)
2048 : center(_center), size(_size), angle(_angle) {}
2049
2051
2052inline
2054 : start(0), end(0) {}
2055
2056inline
2057Range::Range(int _start, int _end)
2058 : start(_start), end(_end) {}
2059
2060inline
2061int Range::size() const
2062{
2063 return end - start;
2064}
2065
2066inline
2067bool Range::empty() const
2068{
2069 return start == end;
2070}
2071
2072inline
2073Range Range::all()
2074{
2075 return Range(INT_MIN, INT_MAX);
2076}
2077
2078
2079static inline
2080bool operator == (const Range& r1, const Range& r2)
2081{
2082 return r1.start == r2.start && r1.end == r2.end;
2083}
2084
2085static inline
2086bool operator != (const Range& r1, const Range& r2)
2087{
2088 return !(r1 == r2);
2089}
2090
2091static inline
2092bool operator !(const Range& r)
2093{
2094 return r.start == r.end;
2095}
2096
2097static inline
2098Range operator & (const Range& r1, const Range& r2)
2099{
2100 Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end));
2101 r.end = std::max(r.end, r.start);
2102 return r;
2103}
2104
2105static inline
2106Range& operator &= (Range& r1, const Range& r2)
2107{
2108 r1 = r1 & r2;
2109 return r1;
2110}
2111
2112static inline
2113Range operator + (const Range& r1, int delta)
2114{
2115 return Range(r1.start + delta, r1.end + delta);
2116}
2117
2118static inline
2119Range operator + (int delta, const Range& r1)
2120{
2121 return Range(r1.start + delta, r1.end + delta);
2122}
2123
2124static inline
2125Range operator - (const Range& r1, int delta)
2126{
2127 return r1 + (-delta);
2128}
2129
2130
2131
2133
2134template<typename _Tp> inline
2136{
2137 this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0;
2138}
2139
2140template<typename _Tp> inline
2141Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
2142{
2143 this->val[0] = v0;
2144 this->val[1] = v1;
2145 this->val[2] = v2;
2146 this->val[3] = v3;
2147}
2148
2149template<typename _Tp> inline
2150Scalar_<_Tp>::Scalar_(const Scalar_<_Tp>& s) : Vec<_Tp, 4>(s) {
2151}
2152
2153template<typename _Tp> inline
2154Scalar_<_Tp>::Scalar_(Scalar_<_Tp>&& s) CV_NOEXCEPT {
2155 this->val[0] = std::move(s.val[0]);
2156 this->val[1] = std::move(s.val[1]);
2157 this->val[2] = std::move(s.val[2]);
2158 this->val[3] = std::move(s.val[3]);
2159}
2160
2161template<typename _Tp> inline
2162Scalar_<_Tp>& Scalar_<_Tp>::operator=(const Scalar_<_Tp>& s) {
2163 this->val[0] = s.val[0];
2164 this->val[1] = s.val[1];
2165 this->val[2] = s.val[2];
2166 this->val[3] = s.val[3];
2167 return *this;
2168}
2169
2170template<typename _Tp> inline
2171Scalar_<_Tp>& Scalar_<_Tp>::operator=(Scalar_<_Tp>&& s) CV_NOEXCEPT {
2172 this->val[0] = std::move(s.val[0]);
2173 this->val[1] = std::move(s.val[1]);
2174 this->val[2] = std::move(s.val[2]);
2175 this->val[3] = std::move(s.val[3]);
2176 return *this;
2177}
2178
2179template<typename _Tp> template<typename _Tp2, int cn> inline
2180Scalar_<_Tp>::Scalar_(const Vec<_Tp2, cn>& v)
2181{
2182 int i;
2183 for( i = 0; i < (cn < 4 ? cn : 4); i++ )
2184 this->val[i] = cv::saturate_cast<_Tp>(v.val[i]);
2185 for( ; i < 4; i++ )
2186 this->val[i] = 0;
2187}
2188
2189template<typename _Tp> inline
2191{
2192 this->val[0] = v0;
2193 this->val[1] = this->val[2] = this->val[3] = 0;
2194}
2195
2196template<typename _Tp> inline
2197Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0)
2198{
2199 return Scalar_<_Tp>(v0, v0, v0, v0);
2200}
2201
2202
2203template<typename _Tp> inline
2204Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp>& a, double scale ) const
2205{
2206 return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0] * a.val[0] * scale),
2207 saturate_cast<_Tp>(this->val[1] * a.val[1] * scale),
2208 saturate_cast<_Tp>(this->val[2] * a.val[2] * scale),
2209 saturate_cast<_Tp>(this->val[3] * a.val[3] * scale));
2210}
2211
2212template<typename _Tp> inline
2213Scalar_<_Tp> Scalar_<_Tp>::conj() const
2214{
2215 return Scalar_<_Tp>(saturate_cast<_Tp>( this->val[0]),
2216 saturate_cast<_Tp>(-this->val[1]),
2217 saturate_cast<_Tp>(-this->val[2]),
2218 saturate_cast<_Tp>(-this->val[3]));
2219}
2220
2221template<typename _Tp> inline
2222bool Scalar_<_Tp>::isReal() const
2223{
2224 return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0;
2225}
2226
2227
2228template<typename _Tp> template<typename T2> inline
2229Scalar_<_Tp>::operator Scalar_<T2>() const
2230{
2231 return Scalar_<T2>(saturate_cast<T2>(this->val[0]),
2232 saturate_cast<T2>(this->val[1]),
2233 saturate_cast<T2>(this->val[2]),
2234 saturate_cast<T2>(this->val[3]));
2235}
2236
2237
2238template<typename _Tp> static inline
2239Scalar_<_Tp>& operator += (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2240{
2241 a.val[0] += b.val[0];
2242 a.val[1] += b.val[1];
2243 a.val[2] += b.val[2];
2244 a.val[3] += b.val[3];
2245 return a;
2246}
2247
2248template<typename _Tp> static inline
2249Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2250{
2251 a.val[0] -= b.val[0];
2252 a.val[1] -= b.val[1];
2253 a.val[2] -= b.val[2];
2254 a.val[3] -= b.val[3];
2255 return a;
2256}
2257
2258template<typename _Tp> static inline
2259Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp v )
2260{
2261 a.val[0] *= v;
2262 a.val[1] *= v;
2263 a.val[2] *= v;
2264 a.val[3] *= v;
2265 return a;
2266}
2267
2268template<typename _Tp> static inline
2269bool operator == ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b )
2270{
2271 return a.val[0] == b.val[0] && a.val[1] == b.val[1] &&
2272 a.val[2] == b.val[2] && a.val[3] == b.val[3];
2273}
2274
2275template<typename _Tp> static inline
2276bool operator != ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b )
2277{
2278 return a.val[0] != b.val[0] || a.val[1] != b.val[1] ||
2279 a.val[2] != b.val[2] || a.val[3] != b.val[3];
2280}
2281
2282template<typename _Tp> static inline
2283Scalar_<_Tp> operator + (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2284{
2285 return Scalar_<_Tp>(a.val[0] + b.val[0],
2286 a.val[1] + b.val[1],
2287 a.val[2] + b.val[2],
2288 a.val[3] + b.val[3]);
2289}
2290
2291template<typename _Tp> static inline
2292Scalar_<_Tp> operator - (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2293{
2294 return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]),
2295 saturate_cast<_Tp>(a.val[1] - b.val[1]),
2296 saturate_cast<_Tp>(a.val[2] - b.val[2]),
2297 saturate_cast<_Tp>(a.val[3] - b.val[3]));
2298}
2299
2300template<typename _Tp> static inline
2301Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, _Tp alpha)
2302{
2303 return Scalar_<_Tp>(a.val[0] * alpha,
2304 a.val[1] * alpha,
2305 a.val[2] * alpha,
2306 a.val[3] * alpha);
2307}
2308
2309template<typename _Tp> static inline
2310Scalar_<_Tp> operator * (_Tp alpha, const Scalar_<_Tp>& a)
2311{
2312 return a*alpha;
2313}
2314
2315template<typename _Tp> static inline
2316Scalar_<_Tp> operator - (const Scalar_<_Tp>& a)
2317{
2318 return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]),
2319 saturate_cast<_Tp>(-a.val[1]),
2320 saturate_cast<_Tp>(-a.val[2]),
2321 saturate_cast<_Tp>(-a.val[3]));
2322}
2323
2324
2325template<typename _Tp> static inline
2326Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2327{
2328 return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]),
2329 saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]),
2330 saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]),
2331 saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0]));
2332}
2333
2334template<typename _Tp> static inline
2335Scalar_<_Tp>& operator *= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2336{
2337 a = a * b;
2338 return a;
2339}
2340
2341template<typename _Tp> static inline
2342Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, _Tp alpha)
2343{
2344 return Scalar_<_Tp>(a.val[0] / alpha,
2345 a.val[1] / alpha,
2346 a.val[2] / alpha,
2347 a.val[3] / alpha);
2348}
2349
2350template<typename _Tp> static inline
2351Scalar_<float> operator / (const Scalar_<float>& a, float alpha)
2352{
2353 float s = 1 / alpha;
2354 return Scalar_<float>(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s);
2355}
2356
2357template<typename _Tp> static inline
2358Scalar_<double> operator / (const Scalar_<double>& a, double alpha)
2359{
2360 double s = 1 / alpha;
2361 return Scalar_<double>(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s);
2362}
2363
2364template<typename _Tp> static inline
2365Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha)
2366{
2367 a = a / alpha;
2368 return a;
2369}
2370
2371template<typename _Tp> static inline
2372Scalar_<_Tp> operator / (_Tp a, const Scalar_<_Tp>& b)
2373{
2374 _Tp s = a / (b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]);
2375 return b.conj() * s;
2376}
2377
2378template<typename _Tp> static inline
2379Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2380{
2381 return a * ((_Tp)1 / b);
2382}
2383
2384template<typename _Tp> static inline
2385Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b)
2386{
2387 a = a / b;
2388 return a;
2389}
2390
2391template<typename _Tp> static inline
2392Scalar operator * (const Matx<_Tp, 4, 4>& a, const Scalar& b)
2393{
2394 Matx<double, 4, 1> c((Matx<double, 4, 4>)a, b, Matx_MatMulOp());
2395 return reinterpret_cast<const Scalar&>(c);
2396}
2397
2398template<> inline
2399Scalar operator * (const Matx<double, 4, 4>& a, const Scalar& b)
2400{
2401 Matx<double, 4, 1> c(a, b, Matx_MatMulOp());
2402 return reinterpret_cast<const Scalar&>(c);
2403}
2404
2405
2406
2408
2409inline
2411 : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {}
2412
2413inline
2414KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int _class_id)
2415 : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {}
2416
2417inline
2418KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
2419 : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {}
2420
2421
2422
2424
2425inline
2427 : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {}
2428
2429inline
2430DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance)
2431 : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {}
2432
2433inline
2434DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance)
2435 : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {}
2436
2437inline
2438bool DMatch::operator < (const DMatch &m) const
2439{
2440 return distance < m.distance;
2441}
2442
2443
2444
2446
2447inline
2449 : type(0), maxCount(0), epsilon(0) {}
2450
2451inline
2452TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon)
2453 : type(_type), maxCount(_maxCount), epsilon(_epsilon) {}
2454
2456
2457} // cv
2458
2459#ifdef _MSC_VER
2460#pragma warning(pop)
2461#endif
2462
2463#endif //OPENCV_CORE_TYPES_HPP
A complex number class.
Definition types.hpp:80
Complex conj() const
conjugation
_Tp im
the real and the imaginary parts
Definition types.hpp:92
_Tp re
Definition types.hpp:92
Complex(_Tp _re, _Tp _im=0)
Complex()
default constructor
Class for matching keypoint descriptors.
Definition types.hpp:842
CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance)
CV_PROP_RW int queryIdx
query descriptor index
Definition types.hpp:848
bool operator<(const DMatch &m) const
CV_PROP_RW float distance
Definition types.hpp:852
CV_PROP_RW int imgIdx
train image index
Definition types.hpp:850
CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance)
CV_WRAP DMatch()
CV_PROP_RW int trainIdx
train descriptor index
Definition types.hpp:849
value_type work_type
Definition types.hpp:102
_Tp channel_type
Definition types.hpp:103
Vec< channel_type, channels > vec_type
Definition types.hpp:114
Complex< _Tp > value_type
Definition types.hpp:101
Vec< channel_type, channels > vec_type
Definition types.hpp:1004
double channel_type
Definition types.hpp:993
double work_type
Definition types.hpp:992
Moments value_type
Definition types.hpp:991
Point3_< typename DataType< _Tp >::work_type > work_type
Definition types.hpp:297
Point3_< _Tp > value_type
Definition types.hpp:296
_Tp channel_type
Definition types.hpp:298
Vec< channel_type, channels > vec_type
Definition types.hpp:309
Point_< _Tp > value_type
Definition types.hpp:214
Point_< typename DataType< _Tp >::work_type > work_type
Definition types.hpp:215
_Tp channel_type
Definition types.hpp:216
Vec< channel_type, channels > vec_type
Definition types.hpp:227
Vec< channel_type, channels > vec_type
Definition types.hpp:650
value_type work_type
Definition types.hpp:638
Range value_type
Definition types.hpp:637
int channel_type
Definition types.hpp:639
Vec< channel_type, channels > vec_type
Definition types.hpp:507
Rect_< typename DataType< _Tp >::work_type > work_type
Definition types.hpp:495
Rect_< _Tp > value_type
Definition types.hpp:494
_Tp channel_type
Definition types.hpp:496
RotatedRect value_type
Definition types.hpp:573
float channel_type
Definition types.hpp:575
Vec< channel_type, channels > vec_type
Definition types.hpp:586
value_type work_type
Definition types.hpp:574
_Tp channel_type
Definition types.hpp:709
Scalar_< _Tp > value_type
Definition types.hpp:707
Scalar_< typename DataType< _Tp >::work_type > work_type
Definition types.hpp:708
Vec< channel_type, channels > vec_type
Definition types.hpp:720
Size_< _Tp > value_type
Definition types.hpp:375
_Tp channel_type
Definition types.hpp:377
Size_< typename DataType< _Tp >::work_type > work_type
Definition types.hpp:376
Vec< channel_type, channels > vec_type
Definition types.hpp:388
Template "trait" class for OpenCV primitive data types.
Definition traits.hpp:113
Data structure for salient point detectors.
Definition types.hpp:745
CV_WRAP KeyPoint()
the default constructor
static CV_WRAP float overlap(const KeyPoint &kp1, const KeyPoint &kp2)
static CV_WRAP void convert(const std::vector< Point2f > &points2f, CV_OUT std::vector< KeyPoint > &keypoints, float size=1, float response=1, int octave=0, int class_id=-1)
CV_PROP_RW float angle
Definition types.hpp:806
KeyPoint(Point2f pt, float size, float angle=-1, float response=0, int octave=0, int class_id=-1)
CV_PROP_RW Point2f pt
coordinates of the keypoints
Definition types.hpp:804
CV_PROP_RW int octave
octave (pyramid layer) from which the keypoint has been extracted
Definition types.hpp:810
size_t hash() const
CV_PROP_RW float response
the response by which the most strong keypoints have been selected. Can be used for the further sorti...
Definition types.hpp:809
static CV_WRAP void convert(const std::vector< KeyPoint > &keypoints, CV_OUT std::vector< Point2f > &points2f, const std::vector< int > &keypointIndexes=std::vector< int >())
CV_PROP_RW int class_id
object class (if the keypoints need to be clustered by an object they belong to)
Definition types.hpp:811
CV_PROP_RW float size
diameter of the meaningful keypoint neighborhood
Definition types.hpp:805
CV_WRAP KeyPoint(float x, float y, float size, float angle=-1, float response=0, int octave=0, int class_id=-1)
_Tp val[m *n]
matrix elements
Definition matx.hpp:218
struct returned by cv::moments
Definition types.hpp:960
Moments()
the default constructor
CV_PROP_RW double nu02
Definition types.hpp:984
CV_PROP_RW double m00
Definition types.hpp:974
CV_PROP_RW double mu02
Definition types.hpp:979
Moments(double m00, double m10, double m01, double m20, double m11, double m02, double m30, double m21, double m12, double m03)
the full constructor
Template class for 3D points specified by its coordinates x, y and z.
Definition types.hpp:255
_Tp value_type
Definition types.hpp:257
_Tp z
z coordinate of the 3D point
Definition types.hpp:286
_Tp dot(const Point3_ &pt) const
dot product
_Tp x
x coordinate of the 3D point
Definition types.hpp:284
Point3_(const Point_< _Tp > &pt)
Point3_(_Tp _x, _Tp _y, _Tp _z)
Point3_(const Point3_ &pt)=default
Point3_(const Vec< _Tp, 3 > &v)
Point3_ cross(const Point3_ &pt) const
cross product of the 2 3D points
double ddot(const Point3_ &pt) const
dot product computed in double-precision arithmetics
Point3_ & operator=(const Point3_ &pt)=default
Point3_()
default constructor
_Tp y
y coordinate of the 3D point
Definition types.hpp:285
Point3_(Point3_ &&pt) CV_NOEXCEPT=default
Template class for 2D points specified by its coordinates x and y.
Definition types.hpp:163
_Tp y
y coordinate of the point
Definition types.hpp:202
Point_(const Size_< _Tp > &sz)
Point_()
default constructor
_Tp dot(const Point_ &pt) const
dot product
bool inside(const Rect_< _Tp > &r) const
checks whether the point is inside the specified rectangle
_Tp x
x coordinate of the point
Definition types.hpp:201
Point_(const Vec< _Tp, 2 > &v)
Point_ & operator=(const Point_ &pt)=default
double ddot(const Point_ &pt) const
dot product computed in double-precision arithmetics
Point_(_Tp _x, _Tp _y)
double cross(const Point_ &pt) const
cross-product
Point_(const Point_ &pt)=default
Point_(Point_ &&pt) CV_NOEXCEPT=default
_Tp value_type
Definition types.hpp:165
Template class specifying a continuous subsequence (slice) of a sequence.
Definition types.hpp:623
int size() const
int end
Definition types.hpp:631
Range(int _start, int _end)
bool empty() const
static Range all()
Template class for 2D rectangles.
Definition types.hpp:444
_Tp area() const
area (width*height) of the rectangle
Point_< _Tp > tl() const
the top-left corner
Rect_(Rect_ &&r) CV_NOEXCEPT=default
Rect_ & operator=(const Rect_ &r)=default
_Tp x
x coordinate of the top-left corner
Definition types.hpp:480
bool contains(const Point_< _Tp > &pt) const
checks whether the rectangle contains the point
Rect_(const Point_< _Tp > &pt1, const Point_< _Tp > &pt2)
_Tp value_type
Definition types.hpp:446
Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height)
_Tp y
y coordinate of the top-left corner
Definition types.hpp:481
bool empty() const
true if empty
_Tp width
width of the rectangle
Definition types.hpp:482
_Tp height
height of the rectangle
Definition types.hpp:483
Rect_(const Rect_ &r)=default
Point_< _Tp > br() const
the bottom-right corner
Size_< _Tp > size() const
size (width, height) of the rectangle
Rect_(const Point_< _Tp > &org, const Size_< _Tp > &sz)
Rect_()
default constructor
The class represents rotated (i.e. not up-right) rectangles on a plane.
Definition types.hpp:531
CV_WRAP RotatedRect()
default constructor
CV_PROP_RW float angle
returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right...
Definition types.hpp:567
CV_PROP_RW Size2f size
returns width and height of the rectangle
Definition types.hpp:565
CV_WRAP void points(CV_OUT std::vector< Point2f > &pts) const
CV_WRAP RotatedRect(const Point2f &center, const Size2f &size, float angle)
void points(Point2f pts[]) const
CV_PROP_RW Point2f center
returns the rectangle mass center
Definition types.hpp:563
CV_WRAP RotatedRect(const Point2f &point1, const Point2f &point2, const Point2f &point3)
CV_WRAP Rect2f boundingRect2f() const
returns the minimal (exact) floating point rectangle containing the rotated rectangle,...
CV_WRAP Rect boundingRect() const
returns the minimal up-right integer rectangle containing the rotated rectangle
Template class for a 4-element vector derived from Vec.
Definition types.hpp:670
Scalar_(const Scalar_ &s)
Scalar_(Scalar_ &&s) CV_NOEXCEPT
Scalar_ & operator=(Scalar_ &&s) CV_NOEXCEPT
Scalar_(_Tp v0)
Scalar_ & operator=(const Scalar_ &s)
Scalar_< _Tp > mul(const Scalar_< _Tp > &a, double scale=1) const
per-element product
Scalar_(const Vec< _Tp2, cn > &v)
static Scalar_< _Tp > all(_Tp v0)
returns a scalar with all elements set to v0
Scalar_()
default constructor
bool isReal() const
returns true iff v1 == v2 == v3 == 0
Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0)
Scalar_< _Tp > conj() const
returns (v0, -v1, -v2, -v3)
Template class for specifying the size of an image or rectangle.
Definition types.hpp:335
bool empty() const
true if empty
Size_(Size_ &&sz) CV_NOEXCEPT=default
_Tp height
the height
Definition types.hpp:363
double aspectRatio() const
aspect ratio (width/height)
Size_(const Point_< _Tp > &pt)
Size_(const Size_ &sz)=default
Size_(_Tp _width, _Tp _height)
_Tp value_type
Definition types.hpp:337
_Tp area() const
the area (width*height)
_Tp width
the width
Definition types.hpp:362
Size_ & operator=(const Size_ &sz)=default
Size_()
default constructor
The class defining termination criteria for iterative algorithms.
Definition types.hpp:886
int type
the type of termination criteria: COUNT, EPS or COUNT + EPS
Definition types.hpp:914
int maxCount
the maximum number of iterations/elements
Definition types.hpp:915
Type
Definition types.hpp:892
bool isValid() const
Definition types.hpp:907
TermCriteria(int type, int maxCount, double epsilon)
double epsilon
the desired accuracy
Definition types.hpp:916
TermCriteria()
default constructor
Template class for short numerical vectors, a partial case of Matx.
Definition matx.hpp:369
T distance(T... args)
CV_EXPORTS_W double norm(InputArray src1, int normType=NORM_L2, InputArray mask=noArray())
Calculates the absolute norm of an array.
Point_< int > Point2i
Definition types.hpp:205
Rect2i Rect
Definition types.hpp:489
Size_< int64 > Size2l
Definition types.hpp:367
Point3_< double > Point3d
Definition types.hpp:291
Point2i Point
Definition types.hpp:209
Rect_< float > Rect2f
Definition types.hpp:487
Point_< int64 > Point2l
Definition types.hpp:206
Point_< double > Point2d
Definition types.hpp:208
Size2i Size
Definition types.hpp:370
Complex< double > Complexd
Definition types.hpp:96
Point3_< float > Point3f
Definition types.hpp:290
static bool operator!=(const Matx< _Tp, m, n > &a, const Matx< _Tp, m, n > &b)
Scalar_< double > Scalar
Definition types.hpp:702
static bool operator==(const Matx< _Tp, m, n > &a, const Matx< _Tp, m, n > &b)
Size_< int > Size2i
Definition types.hpp:366
Point_< float > Point2f
Definition types.hpp:207
Rect_< double > Rect2d
Definition types.hpp:488
Rect_< int > Rect2i
Definition types.hpp:486
Complex< float > Complexf
Definition types.hpp:95
Size_< float > Size2f
Definition types.hpp:368
Point3_< int > Point3i
Definition types.hpp:289
Size_< double > Size2d
Definition types.hpp:369
int int channels
Definition core_c.h:100
double double end
Definition core_c.h:1381
double start
Definition core_c.h:1381
CvScalar scale
Definition core_c.h:1088
const CvArr * angle
Definition core_c.h:1194
CvSize size
Definition core_c.h:112
int int type
Definition core_c.h:221
int depth
Definition core_c.h:100
const CvArr CvArr * x
Definition core_c.h:1195
double alpha
Definition core_c.h:1093
const CvArr const CvArr CvArr * result
Definition core_c.h:1423
const CvArr * y
Definition core_c.h:1187
int64_t int64
Definition interface.h:61
#define CV_MAKETYPE(depth, cn)
Definition interface.h:85
CV_INLINE v_reg< _Tp, n > operator|(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Bitwise OR.
CV_INLINE v_reg< _Tp, n > operator&(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Bitwise AND.
CV_INLINE v_reg< _Tp, n > & operator|=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator/=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > operator/(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Divide values.
CV_INLINE v_reg< _Tp, n > & operator&=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator-=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator+=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator*=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
softfloat abs(softfloat a)
Absolute value.
Definition softfloat.hpp:444
CV_INLINE int cvIsNaN(double value)
Determines if the argument is Not A Number.
Definition fast_math.hpp:284
#define CV_EXPORTS_W_SIMPLE
Definition cvdef.h:473
#define CV_EXPORTS
Definition cvdef.h:435
#define CV_OUT
Definition cvdef.h:478
#define CV_EXPORTS_W
Definition cvdef.h:472
#define CV_NOEXCEPT
Definition cvdef.h:800
#define CV_PROP_RW
Definition cvdef.h:480
#define CV_WRAP
Definition cvdef.h:481
static _AccTp normL2Sqr(const _Tp *a, int n)
Definition base.hpp:404
#define CV_DbgAssert(expr)
Definition base.hpp:375
#define CV_EXPORTS_W_MAP
Definition cvdef.h:475
CvPoint2D32f pt[4]
Definition imgproc_c.h:571
CvPoint pt1
Definition imgproc_c.h:357
CvRect r
Definition imgproc_c.h:984
CvSize int int int CvPoint int delta
Definition imgproc_c.h:1168
const char CvPoint org
Definition imgproc_c.h:1143
CvPoint CvPoint pt2
Definition imgproc_c.h:357
const CvPoint * pts
Definition imgproc_c.h:1026
CvArr CvPoint2D32f center
Definition imgproc_c.h:270
T max(T... args)
T min(T... args)
T move(T... args)
"black box" representation of the file storage associated with a file on disk.
Definition calib3d.hpp:441
DualQuat< T > operator-(const DualQuat< T > &q, const T a)
Definition dualquaternion.inl.hpp:255
DualQuat< T > operator+(const T a, const DualQuat< T > &q)
Definition dualquaternion.inl.hpp:243
DualQuat< T > operator*(const T a, const DualQuat< T > &q)
Definition dualquaternion.inl.hpp:274
T sqrt(T... args)
float x
Definition types_c.h:978
float y
Definition types_c.h:979
int y
Definition types_c.h:937
int x
Definition types_c.h:936
int x
Definition types_c.h:833
Definition traits.hpp:382
@ value
Definition traits.hpp:382
Definition traits.hpp:402
Definition traits.hpp:386
@ value
Definition traits.hpp:386