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 // Copyright (C) 2014, Itseez Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 17 // Third party copyrights are property of their respective owners.
RyoheiHagimoto 0:0e0631af0305 18 //
RyoheiHagimoto 0:0e0631af0305 19 // Redistribution and use in source and binary forms, with or without modification,
RyoheiHagimoto 0:0e0631af0305 20 // are permitted provided that the following conditions are met:
RyoheiHagimoto 0:0e0631af0305 21 //
RyoheiHagimoto 0:0e0631af0305 22 // * Redistribution's of source code must retain the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 23 // this list of conditions and the following disclaimer.
RyoheiHagimoto 0:0e0631af0305 24 //
RyoheiHagimoto 0:0e0631af0305 25 // * Redistribution's in binary form must reproduce the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 26 // this list of conditions and the following disclaimer in the documentation
RyoheiHagimoto 0:0e0631af0305 27 // and/or other materials provided with the distribution.
RyoheiHagimoto 0:0e0631af0305 28 //
RyoheiHagimoto 0:0e0631af0305 29 // * The name of the copyright holders may not be used to endorse or promote products
RyoheiHagimoto 0:0e0631af0305 30 // derived from this software without specific prior written permission.
RyoheiHagimoto 0:0e0631af0305 31 //
RyoheiHagimoto 0:0e0631af0305 32 // This software is provided by the copyright holders and contributors "as is" and
RyoheiHagimoto 0:0e0631af0305 33 // any express or implied warranties, including, but not limited to, the implied
RyoheiHagimoto 0:0e0631af0305 34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
RyoheiHagimoto 0:0e0631af0305 35 // In no event shall the Intel Corporation or contributors be liable for any direct,
RyoheiHagimoto 0:0e0631af0305 36 // indirect, incidental, special, exemplary, or consequential damages
RyoheiHagimoto 0:0e0631af0305 37 // (including, but not limited to, procurement of substitute goods or services;
RyoheiHagimoto 0:0e0631af0305 38 // loss of use, data, or profits; or business interruption) however caused
RyoheiHagimoto 0:0e0631af0305 39 // and on any theory of liability, whether in contract, strict liability,
RyoheiHagimoto 0:0e0631af0305 40 // or tort (including negligence or otherwise) arising in any way out of
RyoheiHagimoto 0:0e0631af0305 41 // the use of this software, even if advised of the possibility of such damage.
RyoheiHagimoto 0:0e0631af0305 42 //
RyoheiHagimoto 0:0e0631af0305 43 //M*/
RyoheiHagimoto 0:0e0631af0305 44
RyoheiHagimoto 0:0e0631af0305 45 #ifndef OPENCV_CORE_BASE_HPP
RyoheiHagimoto 0:0e0631af0305 46 #define OPENCV_CORE_BASE_HPP
RyoheiHagimoto 0:0e0631af0305 47
RyoheiHagimoto 0:0e0631af0305 48 #ifndef __cplusplus
RyoheiHagimoto 0:0e0631af0305 49 # error base.hpp header must be compiled as C++
RyoheiHagimoto 0:0e0631af0305 50 #endif
RyoheiHagimoto 0:0e0631af0305 51
RyoheiHagimoto 0:0e0631af0305 52 #include "opencv2/opencv_modules.hpp"
RyoheiHagimoto 0:0e0631af0305 53
RyoheiHagimoto 0:0e0631af0305 54 #include <climits>
RyoheiHagimoto 0:0e0631af0305 55 #include <algorithm>
RyoheiHagimoto 0:0e0631af0305 56
RyoheiHagimoto 0:0e0631af0305 57 #include "opencv2/core/cvdef.h"
RyoheiHagimoto 0:0e0631af0305 58 #include "opencv2/core/cvstd.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_utils
RyoheiHagimoto 0:0e0631af0305 64 //! @{
RyoheiHagimoto 0:0e0631af0305 65
RyoheiHagimoto 0:0e0631af0305 66 namespace Error {
RyoheiHagimoto 0:0e0631af0305 67 //! error codes
RyoheiHagimoto 0:0e0631af0305 68 enum Code {
RyoheiHagimoto 0:0e0631af0305 69 StsOk= 0, //!< everithing is ok
RyoheiHagimoto 0:0e0631af0305 70 StsBackTrace= -1, //!< pseudo error for back trace
RyoheiHagimoto 0:0e0631af0305 71 StsError= -2, //!< unknown /unspecified error
RyoheiHagimoto 0:0e0631af0305 72 StsInternal= -3, //!< internal error (bad state)
RyoheiHagimoto 0:0e0631af0305 73 StsNoMem= -4, //!< insufficient memory
RyoheiHagimoto 0:0e0631af0305 74 StsBadArg= -5, //!< function arg/param is bad
RyoheiHagimoto 0:0e0631af0305 75 StsBadFunc= -6, //!< unsupported function
RyoheiHagimoto 0:0e0631af0305 76 StsNoConv= -7, //!< iter. didn't converge
RyoheiHagimoto 0:0e0631af0305 77 StsAutoTrace= -8, //!< tracing
RyoheiHagimoto 0:0e0631af0305 78 HeaderIsNull= -9, //!< image header is NULL
RyoheiHagimoto 0:0e0631af0305 79 BadImageSize= -10, //!< image size is invalid
RyoheiHagimoto 0:0e0631af0305 80 BadOffset= -11, //!< offset is invalid
RyoheiHagimoto 0:0e0631af0305 81 BadDataPtr= -12, //!<
RyoheiHagimoto 0:0e0631af0305 82 BadStep= -13, //!<
RyoheiHagimoto 0:0e0631af0305 83 BadModelOrChSeq= -14, //!<
RyoheiHagimoto 0:0e0631af0305 84 BadNumChannels= -15, //!<
RyoheiHagimoto 0:0e0631af0305 85 BadNumChannel1U= -16, //!<
RyoheiHagimoto 0:0e0631af0305 86 BadDepth= -17, //!<
RyoheiHagimoto 0:0e0631af0305 87 BadAlphaChannel= -18, //!<
RyoheiHagimoto 0:0e0631af0305 88 BadOrder= -19, //!<
RyoheiHagimoto 0:0e0631af0305 89 BadOrigin= -20, //!<
RyoheiHagimoto 0:0e0631af0305 90 BadAlign= -21, //!<
RyoheiHagimoto 0:0e0631af0305 91 BadCallBack= -22, //!<
RyoheiHagimoto 0:0e0631af0305 92 BadTileSize= -23, //!<
RyoheiHagimoto 0:0e0631af0305 93 BadCOI= -24, //!<
RyoheiHagimoto 0:0e0631af0305 94 BadROISize= -25, //!<
RyoheiHagimoto 0:0e0631af0305 95 MaskIsTiled= -26, //!<
RyoheiHagimoto 0:0e0631af0305 96 StsNullPtr= -27, //!< null pointer
RyoheiHagimoto 0:0e0631af0305 97 StsVecLengthErr= -28, //!< incorrect vector length
RyoheiHagimoto 0:0e0631af0305 98 StsFilterStructContentErr= -29, //!< incorr. filter structure content
RyoheiHagimoto 0:0e0631af0305 99 StsKernelStructContentErr= -30, //!< incorr. transform kernel content
RyoheiHagimoto 0:0e0631af0305 100 StsFilterOffsetErr= -31, //!< incorrect filter ofset value
RyoheiHagimoto 0:0e0631af0305 101 StsBadSize= -201, //!< the input/output structure size is incorrect
RyoheiHagimoto 0:0e0631af0305 102 StsDivByZero= -202, //!< division by zero
RyoheiHagimoto 0:0e0631af0305 103 StsInplaceNotSupported= -203, //!< in-place operation is not supported
RyoheiHagimoto 0:0e0631af0305 104 StsObjectNotFound= -204, //!< request can't be completed
RyoheiHagimoto 0:0e0631af0305 105 StsUnmatchedFormats= -205, //!< formats of input/output arrays differ
RyoheiHagimoto 0:0e0631af0305 106 StsBadFlag= -206, //!< flag is wrong or not supported
RyoheiHagimoto 0:0e0631af0305 107 StsBadPoint= -207, //!< bad CvPoint
RyoheiHagimoto 0:0e0631af0305 108 StsBadMask= -208, //!< bad format of mask (neither 8uC1 nor 8sC1)
RyoheiHagimoto 0:0e0631af0305 109 StsUnmatchedSizes= -209, //!< sizes of input/output structures do not match
RyoheiHagimoto 0:0e0631af0305 110 StsUnsupportedFormat= -210, //!< the data format/type is not supported by the function
RyoheiHagimoto 0:0e0631af0305 111 StsOutOfRange= -211, //!< some of parameters are out of range
RyoheiHagimoto 0:0e0631af0305 112 StsParseError= -212, //!< invalid syntax/structure of the parsed file
RyoheiHagimoto 0:0e0631af0305 113 StsNotImplemented= -213, //!< the requested function/feature is not implemented
RyoheiHagimoto 0:0e0631af0305 114 StsBadMemBlock= -214, //!< an allocated block has been corrupted
RyoheiHagimoto 0:0e0631af0305 115 StsAssert= -215, //!< assertion failed
RyoheiHagimoto 0:0e0631af0305 116 GpuNotSupported= -216,
RyoheiHagimoto 0:0e0631af0305 117 GpuApiCallError= -217,
RyoheiHagimoto 0:0e0631af0305 118 OpenGlNotSupported= -218,
RyoheiHagimoto 0:0e0631af0305 119 OpenGlApiCallError= -219,
RyoheiHagimoto 0:0e0631af0305 120 OpenCLApiCallError= -220,
RyoheiHagimoto 0:0e0631af0305 121 OpenCLDoubleNotSupported= -221,
RyoheiHagimoto 0:0e0631af0305 122 OpenCLInitError= -222,
RyoheiHagimoto 0:0e0631af0305 123 OpenCLNoAMDBlasFft= -223
RyoheiHagimoto 0:0e0631af0305 124 };
RyoheiHagimoto 0:0e0631af0305 125 } //Error
RyoheiHagimoto 0:0e0631af0305 126
RyoheiHagimoto 0:0e0631af0305 127 //! @} core_utils
RyoheiHagimoto 0:0e0631af0305 128
RyoheiHagimoto 0:0e0631af0305 129 //! @addtogroup core_array
RyoheiHagimoto 0:0e0631af0305 130 //! @{
RyoheiHagimoto 0:0e0631af0305 131
RyoheiHagimoto 0:0e0631af0305 132 //! matrix decomposition types
RyoheiHagimoto 0:0e0631af0305 133 enum DecompTypes {
RyoheiHagimoto 0:0e0631af0305 134 /** Gaussian elimination with the optimal pivot element chosen. */
RyoheiHagimoto 0:0e0631af0305 135 DECOMP_LU = 0,
RyoheiHagimoto 0:0e0631af0305 136 /** singular value decomposition (SVD) method; the system can be over-defined and/or the matrix
RyoheiHagimoto 0:0e0631af0305 137 src1 can be singular */
RyoheiHagimoto 0:0e0631af0305 138 DECOMP_SVD = 1,
RyoheiHagimoto 0:0e0631af0305 139 /** eigenvalue decomposition; the matrix src1 must be symmetrical */
RyoheiHagimoto 0:0e0631af0305 140 DECOMP_EIG = 2,
RyoheiHagimoto 0:0e0631af0305 141 /** Cholesky \f$LL^T\f$ factorization; the matrix src1 must be symmetrical and positively
RyoheiHagimoto 0:0e0631af0305 142 defined */
RyoheiHagimoto 0:0e0631af0305 143 DECOMP_CHOLESKY = 3,
RyoheiHagimoto 0:0e0631af0305 144 /** QR factorization; the system can be over-defined and/or the matrix src1 can be singular */
RyoheiHagimoto 0:0e0631af0305 145 DECOMP_QR = 4,
RyoheiHagimoto 0:0e0631af0305 146 /** while all the previous flags are mutually exclusive, this flag can be used together with
RyoheiHagimoto 0:0e0631af0305 147 any of the previous; it means that the normal equations
RyoheiHagimoto 0:0e0631af0305 148 \f$\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}\f$ are
RyoheiHagimoto 0:0e0631af0305 149 solved instead of the original system
RyoheiHagimoto 0:0e0631af0305 150 \f$\texttt{src1}\cdot\texttt{dst}=\texttt{src2}\f$ */
RyoheiHagimoto 0:0e0631af0305 151 DECOMP_NORMAL = 16
RyoheiHagimoto 0:0e0631af0305 152 };
RyoheiHagimoto 0:0e0631af0305 153
RyoheiHagimoto 0:0e0631af0305 154 /** norm types
RyoheiHagimoto 0:0e0631af0305 155 - For one array:
RyoheiHagimoto 0:0e0631af0305 156 \f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
RyoheiHagimoto 0:0e0631af0305 157 { \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
RyoheiHagimoto 0:0e0631af0305 158 { \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 159
RyoheiHagimoto 0:0e0631af0305 160 - Absolute norm for two arrays
RyoheiHagimoto 0:0e0631af0305 161 \f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
RyoheiHagimoto 0:0e0631af0305 162 { \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
RyoheiHagimoto 0:0e0631af0305 163 { \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 164
RyoheiHagimoto 0:0e0631af0305 165 - Relative norm for two arrays
RyoheiHagimoto 0:0e0631af0305 166 \f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
RyoheiHagimoto 0:0e0631af0305 167 { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
RyoheiHagimoto 0:0e0631af0305 168 { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 169
RyoheiHagimoto 0:0e0631af0305 170 As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
RyoheiHagimoto 0:0e0631af0305 171 The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
RyoheiHagimoto 0:0e0631af0305 172 is calculated as follows
RyoheiHagimoto 0:0e0631af0305 173 \f{align*}
RyoheiHagimoto 0:0e0631af0305 174 \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
RyoheiHagimoto 0:0e0631af0305 175 \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
RyoheiHagimoto 0:0e0631af0305 176 \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
RyoheiHagimoto 0:0e0631af0305 177 \f}
RyoheiHagimoto 0:0e0631af0305 178 and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
RyoheiHagimoto 0:0e0631af0305 179 \f{align*}
RyoheiHagimoto 0:0e0631af0305 180 \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
RyoheiHagimoto 0:0e0631af0305 181 \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
RyoheiHagimoto 0:0e0631af0305 182 \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
RyoheiHagimoto 0:0e0631af0305 183 \f}
RyoheiHagimoto 0:0e0631af0305 184 The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$.
RyoheiHagimoto 0:0e0631af0305 185 It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$.
RyoheiHagimoto 0:0e0631af0305 186 ![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png)
RyoheiHagimoto 0:0e0631af0305 187 */
RyoheiHagimoto 0:0e0631af0305 188 enum NormTypes { NORM_INF = 1,
RyoheiHagimoto 0:0e0631af0305 189 NORM_L1 = 2,
RyoheiHagimoto 0:0e0631af0305 190 NORM_L2 = 4,
RyoheiHagimoto 0:0e0631af0305 191 NORM_L2SQR = 5,
RyoheiHagimoto 0:0e0631af0305 192 NORM_HAMMING = 6,
RyoheiHagimoto 0:0e0631af0305 193 NORM_HAMMING2 = 7,
RyoheiHagimoto 0:0e0631af0305 194 NORM_TYPE_MASK = 7,
RyoheiHagimoto 0:0e0631af0305 195 NORM_RELATIVE = 8, //!< flag
RyoheiHagimoto 0:0e0631af0305 196 NORM_MINMAX = 32 //!< flag
RyoheiHagimoto 0:0e0631af0305 197 };
RyoheiHagimoto 0:0e0631af0305 198
RyoheiHagimoto 0:0e0631af0305 199 //! comparison types
RyoheiHagimoto 0:0e0631af0305 200 enum CmpTypes { CMP_EQ = 0, //!< src1 is equal to src2.
RyoheiHagimoto 0:0e0631af0305 201 CMP_GT = 1, //!< src1 is greater than src2.
RyoheiHagimoto 0:0e0631af0305 202 CMP_GE = 2, //!< src1 is greater than or equal to src2.
RyoheiHagimoto 0:0e0631af0305 203 CMP_LT = 3, //!< src1 is less than src2.
RyoheiHagimoto 0:0e0631af0305 204 CMP_LE = 4, //!< src1 is less than or equal to src2.
RyoheiHagimoto 0:0e0631af0305 205 CMP_NE = 5 //!< src1 is unequal to src2.
RyoheiHagimoto 0:0e0631af0305 206 };
RyoheiHagimoto 0:0e0631af0305 207
RyoheiHagimoto 0:0e0631af0305 208 //! generalized matrix multiplication flags
RyoheiHagimoto 0:0e0631af0305 209 enum GemmFlags { GEMM_1_T = 1, //!< transposes src1
RyoheiHagimoto 0:0e0631af0305 210 GEMM_2_T = 2, //!< transposes src2
RyoheiHagimoto 0:0e0631af0305 211 GEMM_3_T = 4 //!< transposes src3
RyoheiHagimoto 0:0e0631af0305 212 };
RyoheiHagimoto 0:0e0631af0305 213
RyoheiHagimoto 0:0e0631af0305 214 enum DftFlags {
RyoheiHagimoto 0:0e0631af0305 215 /** performs an inverse 1D or 2D transform instead of the default forward
RyoheiHagimoto 0:0e0631af0305 216 transform. */
RyoheiHagimoto 0:0e0631af0305 217 DFT_INVERSE = 1,
RyoheiHagimoto 0:0e0631af0305 218 /** scales the result: divide it by the number of array elements. Normally, it is
RyoheiHagimoto 0:0e0631af0305 219 combined with DFT_INVERSE. */
RyoheiHagimoto 0:0e0631af0305 220 DFT_SCALE = 2,
RyoheiHagimoto 0:0e0631af0305 221 /** performs a forward or inverse transform of every individual row of the input
RyoheiHagimoto 0:0e0631af0305 222 matrix; this flag enables you to transform multiple vectors simultaneously and can be used to
RyoheiHagimoto 0:0e0631af0305 223 decrease the overhead (which is sometimes several times larger than the processing itself) to
RyoheiHagimoto 0:0e0631af0305 224 perform 3D and higher-dimensional transformations and so forth.*/
RyoheiHagimoto 0:0e0631af0305 225 DFT_ROWS = 4,
RyoheiHagimoto 0:0e0631af0305 226 /** performs a forward transformation of 1D or 2D real array; the result,
RyoheiHagimoto 0:0e0631af0305 227 though being a complex array, has complex-conjugate symmetry (*CCS*, see the function
RyoheiHagimoto 0:0e0631af0305 228 description below for details), and such an array can be packed into a real array of the same
RyoheiHagimoto 0:0e0631af0305 229 size as input, which is the fastest option and which is what the function does by default;
RyoheiHagimoto 0:0e0631af0305 230 however, you may wish to get a full complex array (for simpler spectrum analysis, and so on) -
RyoheiHagimoto 0:0e0631af0305 231 pass the flag to enable the function to produce a full-size complex output array. */
RyoheiHagimoto 0:0e0631af0305 232 DFT_COMPLEX_OUTPUT = 16,
RyoheiHagimoto 0:0e0631af0305 233 /** performs an inverse transformation of a 1D or 2D complex array; the
RyoheiHagimoto 0:0e0631af0305 234 result is normally a complex array of the same size, however, if the input array has
RyoheiHagimoto 0:0e0631af0305 235 conjugate-complex symmetry (for example, it is a result of forward transformation with
RyoheiHagimoto 0:0e0631af0305 236 DFT_COMPLEX_OUTPUT flag), the output is a real array; while the function itself does not
RyoheiHagimoto 0:0e0631af0305 237 check whether the input is symmetrical or not, you can pass the flag and then the function
RyoheiHagimoto 0:0e0631af0305 238 will assume the symmetry and produce the real output array (note that when the input is packed
RyoheiHagimoto 0:0e0631af0305 239 into a real array and inverse transformation is executed, the function treats the input as a
RyoheiHagimoto 0:0e0631af0305 240 packed complex-conjugate symmetrical array, and the output will also be a real array). */
RyoheiHagimoto 0:0e0631af0305 241 DFT_REAL_OUTPUT = 32,
RyoheiHagimoto 0:0e0631af0305 242 /** performs an inverse 1D or 2D transform instead of the default forward transform. */
RyoheiHagimoto 0:0e0631af0305 243 DCT_INVERSE = DFT_INVERSE,
RyoheiHagimoto 0:0e0631af0305 244 /** performs a forward or inverse transform of every individual row of the input
RyoheiHagimoto 0:0e0631af0305 245 matrix. This flag enables you to transform multiple vectors simultaneously and can be used to
RyoheiHagimoto 0:0e0631af0305 246 decrease the overhead (which is sometimes several times larger than the processing itself) to
RyoheiHagimoto 0:0e0631af0305 247 perform 3D and higher-dimensional transforms and so forth.*/
RyoheiHagimoto 0:0e0631af0305 248 DCT_ROWS = DFT_ROWS
RyoheiHagimoto 0:0e0631af0305 249 };
RyoheiHagimoto 0:0e0631af0305 250
RyoheiHagimoto 0:0e0631af0305 251 //! Various border types, image boundaries are denoted with `|`
RyoheiHagimoto 0:0e0631af0305 252 //! @see borderInterpolate, copyMakeBorder
RyoheiHagimoto 0:0e0631af0305 253 enum BorderTypes {
RyoheiHagimoto 0:0e0631af0305 254 BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
RyoheiHagimoto 0:0e0631af0305 255 BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
RyoheiHagimoto 0:0e0631af0305 256 BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
RyoheiHagimoto 0:0e0631af0305 257 BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
RyoheiHagimoto 0:0e0631af0305 258 BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
RyoheiHagimoto 0:0e0631af0305 259 BORDER_TRANSPARENT = 5, //!< `uvwxyz|absdefgh|ijklmno`
RyoheiHagimoto 0:0e0631af0305 260
RyoheiHagimoto 0:0e0631af0305 261 BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
RyoheiHagimoto 0:0e0631af0305 262 BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
RyoheiHagimoto 0:0e0631af0305 263 BORDER_ISOLATED = 16 //!< do not look outside of ROI
RyoheiHagimoto 0:0e0631af0305 264 };
RyoheiHagimoto 0:0e0631af0305 265
RyoheiHagimoto 0:0e0631af0305 266 //! @} core_array
RyoheiHagimoto 0:0e0631af0305 267
RyoheiHagimoto 0:0e0631af0305 268 //! @addtogroup core_utils
RyoheiHagimoto 0:0e0631af0305 269 //! @{
RyoheiHagimoto 0:0e0631af0305 270
RyoheiHagimoto 0:0e0631af0305 271 //! @cond IGNORED
RyoheiHagimoto 0:0e0631af0305 272
RyoheiHagimoto 0:0e0631af0305 273 //////////////// static assert /////////////////
RyoheiHagimoto 0:0e0631af0305 274 #define CVAUX_CONCAT_EXP(a, b) a##b
RyoheiHagimoto 0:0e0631af0305 275 #define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
RyoheiHagimoto 0:0e0631af0305 276
RyoheiHagimoto 0:0e0631af0305 277 #if defined(__clang__)
RyoheiHagimoto 0:0e0631af0305 278 # ifndef __has_extension
RyoheiHagimoto 0:0e0631af0305 279 # define __has_extension __has_feature /* compatibility, for older versions of clang */
RyoheiHagimoto 0:0e0631af0305 280 # endif
RyoheiHagimoto 0:0e0631af0305 281 # if __has_extension(cxx_static_assert)
RyoheiHagimoto 0:0e0631af0305 282 # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
RyoheiHagimoto 0:0e0631af0305 283 # elif __has_extension(c_static_assert)
RyoheiHagimoto 0:0e0631af0305 284 # define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
RyoheiHagimoto 0:0e0631af0305 285 # endif
RyoheiHagimoto 0:0e0631af0305 286 #elif defined(__GNUC__)
RyoheiHagimoto 0:0e0631af0305 287 # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
RyoheiHagimoto 0:0e0631af0305 288 # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
RyoheiHagimoto 0:0e0631af0305 289 # endif
RyoheiHagimoto 0:0e0631af0305 290 #elif defined(_MSC_VER)
RyoheiHagimoto 0:0e0631af0305 291 # if _MSC_VER >= 1600 /* MSVC 10 */
RyoheiHagimoto 0:0e0631af0305 292 # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
RyoheiHagimoto 0:0e0631af0305 293 # endif
RyoheiHagimoto 0:0e0631af0305 294 #endif
RyoheiHagimoto 0:0e0631af0305 295 #ifndef CV_StaticAssert
RyoheiHagimoto 0:0e0631af0305 296 # if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302)
RyoheiHagimoto 0:0e0631af0305 297 # define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
RyoheiHagimoto 0:0e0631af0305 298 # else
RyoheiHagimoto 0:0e0631af0305 299 template <bool x> struct CV_StaticAssert_failed;
RyoheiHagimoto 0:0e0631af0305 300 template <> struct CV_StaticAssert_failed<true> { enum { val = 1 }; };
RyoheiHagimoto 0:0e0631af0305 301 template<int x> struct CV_StaticAssert_test {};
RyoheiHagimoto 0:0e0631af0305 302 # define CV_StaticAssert(condition, reason)\
RyoheiHagimoto 0:0e0631af0305 303 typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast<bool>(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
RyoheiHagimoto 0:0e0631af0305 304 # endif
RyoheiHagimoto 0:0e0631af0305 305 #endif
RyoheiHagimoto 0:0e0631af0305 306
RyoheiHagimoto 0:0e0631af0305 307 // Suppress warning "-Wdeprecated-declarations" / C4996
RyoheiHagimoto 0:0e0631af0305 308 #if defined(_MSC_VER)
RyoheiHagimoto 0:0e0631af0305 309 #define CV_DO_PRAGMA(x) __pragma(x)
RyoheiHagimoto 0:0e0631af0305 310 #elif defined(__GNUC__)
RyoheiHagimoto 0:0e0631af0305 311 #define CV_DO_PRAGMA(x) _Pragma (#x)
RyoheiHagimoto 0:0e0631af0305 312 #else
RyoheiHagimoto 0:0e0631af0305 313 #define CV_DO_PRAGMA(x)
RyoheiHagimoto 0:0e0631af0305 314 #endif
RyoheiHagimoto 0:0e0631af0305 315
RyoheiHagimoto 0:0e0631af0305 316 #ifdef _MSC_VER
RyoheiHagimoto 0:0e0631af0305 317 #define CV_SUPPRESS_DEPRECATED_START \
RyoheiHagimoto 0:0e0631af0305 318 CV_DO_PRAGMA(warning(push)) \
RyoheiHagimoto 0:0e0631af0305 319 CV_DO_PRAGMA(warning(disable: 4996))
RyoheiHagimoto 0:0e0631af0305 320 #define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop))
RyoheiHagimoto 0:0e0631af0305 321 #elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405))
RyoheiHagimoto 0:0e0631af0305 322 #define CV_SUPPRESS_DEPRECATED_START \
RyoheiHagimoto 0:0e0631af0305 323 CV_DO_PRAGMA(GCC diagnostic push) \
RyoheiHagimoto 0:0e0631af0305 324 CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
RyoheiHagimoto 0:0e0631af0305 325 #define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop)
RyoheiHagimoto 0:0e0631af0305 326 #else
RyoheiHagimoto 0:0e0631af0305 327 #define CV_SUPPRESS_DEPRECATED_START
RyoheiHagimoto 0:0e0631af0305 328 #define CV_SUPPRESS_DEPRECATED_END
RyoheiHagimoto 0:0e0631af0305 329 #endif
RyoheiHagimoto 0:0e0631af0305 330 #define CV_UNUSED(name) (void)name
RyoheiHagimoto 0:0e0631af0305 331 //! @endcond
RyoheiHagimoto 0:0e0631af0305 332
RyoheiHagimoto 0:0e0631af0305 333 /*! @brief Signals an error and raises the exception.
RyoheiHagimoto 0:0e0631af0305 334
RyoheiHagimoto 0:0e0631af0305 335 By default the function prints information about the error to stderr,
RyoheiHagimoto 0:0e0631af0305 336 then it either stops if setBreakOnError() had been called before or raises the exception.
RyoheiHagimoto 0:0e0631af0305 337 It is possible to alternate error processing by using redirectError().
RyoheiHagimoto 0:0e0631af0305 338 @param _code - error code (Error::Code)
RyoheiHagimoto 0:0e0631af0305 339 @param _err - error description
RyoheiHagimoto 0:0e0631af0305 340 @param _func - function name. Available only when the compiler supports getting it
RyoheiHagimoto 0:0e0631af0305 341 @param _file - source file name where the error has occured
RyoheiHagimoto 0:0e0631af0305 342 @param _line - line number in the source file where the error has occured
RyoheiHagimoto 0:0e0631af0305 343 @see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
RyoheiHagimoto 0:0e0631af0305 344 */
RyoheiHagimoto 0:0e0631af0305 345 CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
RyoheiHagimoto 0:0e0631af0305 346
RyoheiHagimoto 0:0e0631af0305 347 #ifdef __GNUC__
RyoheiHagimoto 0:0e0631af0305 348 # if defined __clang__ || defined __APPLE__
RyoheiHagimoto 0:0e0631af0305 349 # pragma GCC diagnostic push
RyoheiHagimoto 0:0e0631af0305 350 # pragma GCC diagnostic ignored "-Winvalid-noreturn"
RyoheiHagimoto 0:0e0631af0305 351 # endif
RyoheiHagimoto 0:0e0631af0305 352 #endif
RyoheiHagimoto 0:0e0631af0305 353
RyoheiHagimoto 0:0e0631af0305 354 /** same as cv::error, but does not return */
RyoheiHagimoto 0:0e0631af0305 355 CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
RyoheiHagimoto 0:0e0631af0305 356 {
RyoheiHagimoto 0:0e0631af0305 357 error(_code, _err, _func, _file, _line);
RyoheiHagimoto 0:0e0631af0305 358 #ifdef __GNUC__
RyoheiHagimoto 0:0e0631af0305 359 # if !defined __clang__ && !defined __APPLE__
RyoheiHagimoto 0:0e0631af0305 360 // this suppresses this warning: "noreturn" function does return [enabled by default]
RyoheiHagimoto 0:0e0631af0305 361 __builtin_trap();
RyoheiHagimoto 0:0e0631af0305 362 // or use infinite loop: for (;;) {}
RyoheiHagimoto 0:0e0631af0305 363 # endif
RyoheiHagimoto 0:0e0631af0305 364 #endif
RyoheiHagimoto 0:0e0631af0305 365 }
RyoheiHagimoto 0:0e0631af0305 366 #ifdef __GNUC__
RyoheiHagimoto 0:0e0631af0305 367 # if defined __clang__ || defined __APPLE__
RyoheiHagimoto 0:0e0631af0305 368 # pragma GCC diagnostic pop
RyoheiHagimoto 0:0e0631af0305 369 # endif
RyoheiHagimoto 0:0e0631af0305 370 #endif
RyoheiHagimoto 0:0e0631af0305 371
RyoheiHagimoto 0:0e0631af0305 372 #if defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 373 #define CV_Func __func__
RyoheiHagimoto 0:0e0631af0305 374 #elif defined _MSC_VER
RyoheiHagimoto 0:0e0631af0305 375 #define CV_Func __FUNCTION__
RyoheiHagimoto 0:0e0631af0305 376 #else
RyoheiHagimoto 0:0e0631af0305 377 #define CV_Func ""
RyoheiHagimoto 0:0e0631af0305 378 #endif
RyoheiHagimoto 0:0e0631af0305 379
RyoheiHagimoto 0:0e0631af0305 380 /** @brief Call the error handler.
RyoheiHagimoto 0:0e0631af0305 381
RyoheiHagimoto 0:0e0631af0305 382 Currently, the error handler prints the error code and the error message to the standard
RyoheiHagimoto 0:0e0631af0305 383 error stream `stderr`. In the Debug configuration, it then provokes memory access violation, so that
RyoheiHagimoto 0:0e0631af0305 384 the execution stack and all the parameters can be analyzed by the debugger. In the Release
RyoheiHagimoto 0:0e0631af0305 385 configuration, the exception is thrown.
RyoheiHagimoto 0:0e0631af0305 386
RyoheiHagimoto 0:0e0631af0305 387 @param code one of Error::Code
RyoheiHagimoto 0:0e0631af0305 388 @param msg error message
RyoheiHagimoto 0:0e0631af0305 389 */
RyoheiHagimoto 0:0e0631af0305 390 #define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ )
RyoheiHagimoto 0:0e0631af0305 391
RyoheiHagimoto 0:0e0631af0305 392 /** @brief Call the error handler.
RyoheiHagimoto 0:0e0631af0305 393
RyoheiHagimoto 0:0e0631af0305 394 This macro can be used to construct an error message on-fly to include some dynamic information,
RyoheiHagimoto 0:0e0631af0305 395 for example:
RyoheiHagimoto 0:0e0631af0305 396 @code
RyoheiHagimoto 0:0e0631af0305 397 // note the extra parentheses around the formatted text message
RyoheiHagimoto 0:0e0631af0305 398 CV_Error_( CV_StsOutOfRange,
RyoheiHagimoto 0:0e0631af0305 399 ("the value at (%d, %d)=%g is out of range", badPt.x, badPt.y, badValue));
RyoheiHagimoto 0:0e0631af0305 400 @endcode
RyoheiHagimoto 0:0e0631af0305 401 @param code one of Error::Code
RyoheiHagimoto 0:0e0631af0305 402 @param args printf-like formatted error message in parentheses
RyoheiHagimoto 0:0e0631af0305 403 */
RyoheiHagimoto 0:0e0631af0305 404 #define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
RyoheiHagimoto 0:0e0631af0305 405
RyoheiHagimoto 0:0e0631af0305 406 /** @brief Checks a condition at runtime and throws exception if it fails
RyoheiHagimoto 0:0e0631af0305 407
RyoheiHagimoto 0:0e0631af0305 408 The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
RyoheiHagimoto 0:0e0631af0305 409 raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
RyoheiHagimoto 0:0e0631af0305 410 configurations while CV_DbgAssert is only retained in the Debug configuration.
RyoheiHagimoto 0:0e0631af0305 411 */
RyoheiHagimoto 0:0e0631af0305 412 #define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
RyoheiHagimoto 0:0e0631af0305 413
RyoheiHagimoto 0:0e0631af0305 414 /** same as CV_Error(code,msg), but does not return */
RyoheiHagimoto 0:0e0631af0305 415 #define CV_ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
RyoheiHagimoto 0:0e0631af0305 416
RyoheiHagimoto 0:0e0631af0305 417 /** same as CV_Error_(code,args), but does not return */
RyoheiHagimoto 0:0e0631af0305 418 #define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
RyoheiHagimoto 0:0e0631af0305 419
RyoheiHagimoto 0:0e0631af0305 420 /** replaced with CV_Assert(expr) in Debug configuration */
RyoheiHagimoto 0:0e0631af0305 421 #ifdef _DEBUG
RyoheiHagimoto 0:0e0631af0305 422 # define CV_DbgAssert(expr) CV_Assert(expr)
RyoheiHagimoto 0:0e0631af0305 423 #else
RyoheiHagimoto 0:0e0631af0305 424 # define CV_DbgAssert(expr)
RyoheiHagimoto 0:0e0631af0305 425 #endif
RyoheiHagimoto 0:0e0631af0305 426
RyoheiHagimoto 0:0e0631af0305 427 /*
RyoheiHagimoto 0:0e0631af0305 428 * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor
RyoheiHagimoto 0:0e0631af0305 429 * bit count of A exclusive XOR'ed with B
RyoheiHagimoto 0:0e0631af0305 430 */
RyoheiHagimoto 0:0e0631af0305 431 struct CV_EXPORTS Hamming
RyoheiHagimoto 0:0e0631af0305 432 {
RyoheiHagimoto 0:0e0631af0305 433 enum { normType = NORM_HAMMING };
RyoheiHagimoto 0:0e0631af0305 434 typedef unsigned char ValueType;
RyoheiHagimoto 0:0e0631af0305 435 typedef int ResultType;
RyoheiHagimoto 0:0e0631af0305 436
RyoheiHagimoto 0:0e0631af0305 437 /** this will count the bits in a ^ b
RyoheiHagimoto 0:0e0631af0305 438 */
RyoheiHagimoto 0:0e0631af0305 439 ResultType operator()( const unsigned char* a, const unsigned char* b, int size ) const;
RyoheiHagimoto 0:0e0631af0305 440 };
RyoheiHagimoto 0:0e0631af0305 441
RyoheiHagimoto 0:0e0631af0305 442 typedef Hamming HammingLUT;
RyoheiHagimoto 0:0e0631af0305 443
RyoheiHagimoto 0:0e0631af0305 444 /////////////////////////////////// inline norms ////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 445
RyoheiHagimoto 0:0e0631af0305 446 template<typename _Tp> inline _Tp cv_abs(_Tp x) { return std::abs(x); }
RyoheiHagimoto 0:0e0631af0305 447 inline int cv_abs(uchar x) { return x; }
RyoheiHagimoto 0:0e0631af0305 448 inline int cv_abs(schar x) { return std::abs(x); }
RyoheiHagimoto 0:0e0631af0305 449 inline int cv_abs(ushort x) { return x; }
RyoheiHagimoto 0:0e0631af0305 450 inline int cv_abs(short x) { return std::abs(x); }
RyoheiHagimoto 0:0e0631af0305 451
RyoheiHagimoto 0:0e0631af0305 452 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 453 _AccTp normL2Sqr(const _Tp* a, int n)
RyoheiHagimoto 0:0e0631af0305 454 {
RyoheiHagimoto 0:0e0631af0305 455 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 456 int i=0;
RyoheiHagimoto 0:0e0631af0305 457 #if CV_ENABLE_UNROLLED
RyoheiHagimoto 0:0e0631af0305 458 for( ; i <= n - 4; i += 4 )
RyoheiHagimoto 0:0e0631af0305 459 {
RyoheiHagimoto 0:0e0631af0305 460 _AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3];
RyoheiHagimoto 0:0e0631af0305 461 s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
RyoheiHagimoto 0:0e0631af0305 462 }
RyoheiHagimoto 0:0e0631af0305 463 #endif
RyoheiHagimoto 0:0e0631af0305 464 for( ; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 465 {
RyoheiHagimoto 0:0e0631af0305 466 _AccTp v = a[i];
RyoheiHagimoto 0:0e0631af0305 467 s += v*v;
RyoheiHagimoto 0:0e0631af0305 468 }
RyoheiHagimoto 0:0e0631af0305 469 return s;
RyoheiHagimoto 0:0e0631af0305 470 }
RyoheiHagimoto 0:0e0631af0305 471
RyoheiHagimoto 0:0e0631af0305 472 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 473 _AccTp normL1(const _Tp* a, int n)
RyoheiHagimoto 0:0e0631af0305 474 {
RyoheiHagimoto 0:0e0631af0305 475 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 476 int i = 0;
RyoheiHagimoto 0:0e0631af0305 477 #if CV_ENABLE_UNROLLED
RyoheiHagimoto 0:0e0631af0305 478 for(; i <= n - 4; i += 4 )
RyoheiHagimoto 0:0e0631af0305 479 {
RyoheiHagimoto 0:0e0631af0305 480 s += (_AccTp)cv_abs(a[i]) + (_AccTp)cv_abs(a[i+1]) +
RyoheiHagimoto 0:0e0631af0305 481 (_AccTp)cv_abs(a[i+2]) + (_AccTp)cv_abs(a[i+3]);
RyoheiHagimoto 0:0e0631af0305 482 }
RyoheiHagimoto 0:0e0631af0305 483 #endif
RyoheiHagimoto 0:0e0631af0305 484 for( ; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 485 s += cv_abs(a[i]);
RyoheiHagimoto 0:0e0631af0305 486 return s;
RyoheiHagimoto 0:0e0631af0305 487 }
RyoheiHagimoto 0:0e0631af0305 488
RyoheiHagimoto 0:0e0631af0305 489 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 490 _AccTp normInf(const _Tp* a, int n)
RyoheiHagimoto 0:0e0631af0305 491 {
RyoheiHagimoto 0:0e0631af0305 492 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 493 for( int i = 0; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 494 s = std::max(s, (_AccTp)cv_abs(a[i]));
RyoheiHagimoto 0:0e0631af0305 495 return s;
RyoheiHagimoto 0:0e0631af0305 496 }
RyoheiHagimoto 0:0e0631af0305 497
RyoheiHagimoto 0:0e0631af0305 498 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 499 _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n)
RyoheiHagimoto 0:0e0631af0305 500 {
RyoheiHagimoto 0:0e0631af0305 501 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 502 int i= 0;
RyoheiHagimoto 0:0e0631af0305 503 #if CV_ENABLE_UNROLLED
RyoheiHagimoto 0:0e0631af0305 504 for(; i <= n - 4; i += 4 )
RyoheiHagimoto 0:0e0631af0305 505 {
RyoheiHagimoto 0:0e0631af0305 506 _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
RyoheiHagimoto 0:0e0631af0305 507 s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
RyoheiHagimoto 0:0e0631af0305 508 }
RyoheiHagimoto 0:0e0631af0305 509 #endif
RyoheiHagimoto 0:0e0631af0305 510 for( ; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 511 {
RyoheiHagimoto 0:0e0631af0305 512 _AccTp v = _AccTp(a[i] - b[i]);
RyoheiHagimoto 0:0e0631af0305 513 s += v*v;
RyoheiHagimoto 0:0e0631af0305 514 }
RyoheiHagimoto 0:0e0631af0305 515 return s;
RyoheiHagimoto 0:0e0631af0305 516 }
RyoheiHagimoto 0:0e0631af0305 517
RyoheiHagimoto 0:0e0631af0305 518 static inline float normL2Sqr(const float* a, const float* b, int n)
RyoheiHagimoto 0:0e0631af0305 519 {
RyoheiHagimoto 0:0e0631af0305 520 float s = 0.f;
RyoheiHagimoto 0:0e0631af0305 521 for( int i = 0; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 522 {
RyoheiHagimoto 0:0e0631af0305 523 float v = a[i] - b[i];
RyoheiHagimoto 0:0e0631af0305 524 s += v*v;
RyoheiHagimoto 0:0e0631af0305 525 }
RyoheiHagimoto 0:0e0631af0305 526 return s;
RyoheiHagimoto 0:0e0631af0305 527 }
RyoheiHagimoto 0:0e0631af0305 528
RyoheiHagimoto 0:0e0631af0305 529 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 530 _AccTp normL1(const _Tp* a, const _Tp* b, int n)
RyoheiHagimoto 0:0e0631af0305 531 {
RyoheiHagimoto 0:0e0631af0305 532 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 533 int i= 0;
RyoheiHagimoto 0:0e0631af0305 534 #if CV_ENABLE_UNROLLED
RyoheiHagimoto 0:0e0631af0305 535 for(; i <= n - 4; i += 4 )
RyoheiHagimoto 0:0e0631af0305 536 {
RyoheiHagimoto 0:0e0631af0305 537 _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
RyoheiHagimoto 0:0e0631af0305 538 s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3);
RyoheiHagimoto 0:0e0631af0305 539 }
RyoheiHagimoto 0:0e0631af0305 540 #endif
RyoheiHagimoto 0:0e0631af0305 541 for( ; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 542 {
RyoheiHagimoto 0:0e0631af0305 543 _AccTp v = _AccTp(a[i] - b[i]);
RyoheiHagimoto 0:0e0631af0305 544 s += std::abs(v);
RyoheiHagimoto 0:0e0631af0305 545 }
RyoheiHagimoto 0:0e0631af0305 546 return s;
RyoheiHagimoto 0:0e0631af0305 547 }
RyoheiHagimoto 0:0e0631af0305 548
RyoheiHagimoto 0:0e0631af0305 549 inline float normL1(const float* a, const float* b, int n)
RyoheiHagimoto 0:0e0631af0305 550 {
RyoheiHagimoto 0:0e0631af0305 551 float s = 0.f;
RyoheiHagimoto 0:0e0631af0305 552 for( int i = 0; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 553 {
RyoheiHagimoto 0:0e0631af0305 554 s += std::abs(a[i] - b[i]);
RyoheiHagimoto 0:0e0631af0305 555 }
RyoheiHagimoto 0:0e0631af0305 556 return s;
RyoheiHagimoto 0:0e0631af0305 557 }
RyoheiHagimoto 0:0e0631af0305 558
RyoheiHagimoto 0:0e0631af0305 559 inline int normL1(const uchar* a, const uchar* b, int n)
RyoheiHagimoto 0:0e0631af0305 560 {
RyoheiHagimoto 0:0e0631af0305 561 int s = 0;
RyoheiHagimoto 0:0e0631af0305 562 for( int i = 0; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 563 {
RyoheiHagimoto 0:0e0631af0305 564 s += std::abs(a[i] - b[i]);
RyoheiHagimoto 0:0e0631af0305 565 }
RyoheiHagimoto 0:0e0631af0305 566 return s;
RyoheiHagimoto 0:0e0631af0305 567 }
RyoheiHagimoto 0:0e0631af0305 568
RyoheiHagimoto 0:0e0631af0305 569 template<typename _Tp, typename _AccTp> static inline
RyoheiHagimoto 0:0e0631af0305 570 _AccTp normInf(const _Tp* a, const _Tp* b, int n)
RyoheiHagimoto 0:0e0631af0305 571 {
RyoheiHagimoto 0:0e0631af0305 572 _AccTp s = 0;
RyoheiHagimoto 0:0e0631af0305 573 for( int i = 0; i < n; i++ )
RyoheiHagimoto 0:0e0631af0305 574 {
RyoheiHagimoto 0:0e0631af0305 575 _AccTp v0 = a[i] - b[i];
RyoheiHagimoto 0:0e0631af0305 576 s = std::max(s, std::abs(v0));
RyoheiHagimoto 0:0e0631af0305 577 }
RyoheiHagimoto 0:0e0631af0305 578 return s;
RyoheiHagimoto 0:0e0631af0305 579 }
RyoheiHagimoto 0:0e0631af0305 580
RyoheiHagimoto 0:0e0631af0305 581 /** @brief Computes the cube root of an argument.
RyoheiHagimoto 0:0e0631af0305 582
RyoheiHagimoto 0:0e0631af0305 583 The function cubeRoot computes \f$\sqrt[3]{\texttt{val}}\f$. Negative arguments are handled correctly.
RyoheiHagimoto 0:0e0631af0305 584 NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for
RyoheiHagimoto 0:0e0631af0305 585 single-precision data.
RyoheiHagimoto 0:0e0631af0305 586 @param val A function argument.
RyoheiHagimoto 0:0e0631af0305 587 */
RyoheiHagimoto 0:0e0631af0305 588 CV_EXPORTS_W float cubeRoot(float val);
RyoheiHagimoto 0:0e0631af0305 589
RyoheiHagimoto 0:0e0631af0305 590 /** @brief Calculates the angle of a 2D vector in degrees.
RyoheiHagimoto 0:0e0631af0305 591
RyoheiHagimoto 0:0e0631af0305 592 The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured
RyoheiHagimoto 0:0e0631af0305 593 in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees.
RyoheiHagimoto 0:0e0631af0305 594 @param x x-coordinate of the vector.
RyoheiHagimoto 0:0e0631af0305 595 @param y y-coordinate of the vector.
RyoheiHagimoto 0:0e0631af0305 596 */
RyoheiHagimoto 0:0e0631af0305 597 CV_EXPORTS_W float fastAtan2(float y, float x);
RyoheiHagimoto 0:0e0631af0305 598
RyoheiHagimoto 0:0e0631af0305 599 /** proxy for hal::LU */
RyoheiHagimoto 0:0e0631af0305 600 CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n);
RyoheiHagimoto 0:0e0631af0305 601 /** proxy for hal::LU */
RyoheiHagimoto 0:0e0631af0305 602 CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n);
RyoheiHagimoto 0:0e0631af0305 603 /** proxy for hal::Cholesky */
RyoheiHagimoto 0:0e0631af0305 604 CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n);
RyoheiHagimoto 0:0e0631af0305 605 /** proxy for hal::Cholesky */
RyoheiHagimoto 0:0e0631af0305 606 CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n);
RyoheiHagimoto 0:0e0631af0305 607
RyoheiHagimoto 0:0e0631af0305 608 ////////////////// forward declarations for important OpenCV types //////////////////
RyoheiHagimoto 0:0e0631af0305 609
RyoheiHagimoto 0:0e0631af0305 610 //! @cond IGNORED
RyoheiHagimoto 0:0e0631af0305 611
RyoheiHagimoto 0:0e0631af0305 612 template<typename _Tp, int cn> class Vec;
RyoheiHagimoto 0:0e0631af0305 613 template<typename _Tp, int m, int n> class Matx;
RyoheiHagimoto 0:0e0631af0305 614
RyoheiHagimoto 0:0e0631af0305 615 template<typename _Tp> class Complex;
RyoheiHagimoto 0:0e0631af0305 616 template<typename _Tp> class Point_;
RyoheiHagimoto 0:0e0631af0305 617 template<typename _Tp> class Point3_;
RyoheiHagimoto 0:0e0631af0305 618 template<typename _Tp> class Size_;
RyoheiHagimoto 0:0e0631af0305 619 template<typename _Tp> class Rect_;
RyoheiHagimoto 0:0e0631af0305 620 template<typename _Tp> class Scalar_;
RyoheiHagimoto 0:0e0631af0305 621
RyoheiHagimoto 0:0e0631af0305 622 class CV_EXPORTS RotatedRect;
RyoheiHagimoto 0:0e0631af0305 623 class CV_EXPORTS Range;
RyoheiHagimoto 0:0e0631af0305 624 class CV_EXPORTS TermCriteria;
RyoheiHagimoto 0:0e0631af0305 625 class CV_EXPORTS KeyPoint;
RyoheiHagimoto 0:0e0631af0305 626 class CV_EXPORTS DMatch;
RyoheiHagimoto 0:0e0631af0305 627 class CV_EXPORTS RNG;
RyoheiHagimoto 0:0e0631af0305 628
RyoheiHagimoto 0:0e0631af0305 629 class CV_EXPORTS Mat;
RyoheiHagimoto 0:0e0631af0305 630 class CV_EXPORTS MatExpr;
RyoheiHagimoto 0:0e0631af0305 631
RyoheiHagimoto 0:0e0631af0305 632 class CV_EXPORTS UMat;
RyoheiHagimoto 0:0e0631af0305 633
RyoheiHagimoto 0:0e0631af0305 634 class CV_EXPORTS SparseMat;
RyoheiHagimoto 0:0e0631af0305 635 typedef Mat MatND;
RyoheiHagimoto 0:0e0631af0305 636
RyoheiHagimoto 0:0e0631af0305 637 template<typename _Tp> class Mat_;
RyoheiHagimoto 0:0e0631af0305 638 template<typename _Tp> class SparseMat_;
RyoheiHagimoto 0:0e0631af0305 639
RyoheiHagimoto 0:0e0631af0305 640 class CV_EXPORTS MatConstIterator;
RyoheiHagimoto 0:0e0631af0305 641 class CV_EXPORTS SparseMatIterator;
RyoheiHagimoto 0:0e0631af0305 642 class CV_EXPORTS SparseMatConstIterator;
RyoheiHagimoto 0:0e0631af0305 643 template<typename _Tp> class MatIterator_;
RyoheiHagimoto 0:0e0631af0305 644 template<typename _Tp> class MatConstIterator_;
RyoheiHagimoto 0:0e0631af0305 645 template<typename _Tp> class SparseMatIterator_;
RyoheiHagimoto 0:0e0631af0305 646 template<typename _Tp> class SparseMatConstIterator_;
RyoheiHagimoto 0:0e0631af0305 647
RyoheiHagimoto 0:0e0631af0305 648 namespace ogl
RyoheiHagimoto 0:0e0631af0305 649 {
RyoheiHagimoto 0:0e0631af0305 650 class CV_EXPORTS Buffer;
RyoheiHagimoto 0:0e0631af0305 651 class CV_EXPORTS Texture2D;
RyoheiHagimoto 0:0e0631af0305 652 class CV_EXPORTS Arrays;
RyoheiHagimoto 0:0e0631af0305 653 }
RyoheiHagimoto 0:0e0631af0305 654
RyoheiHagimoto 0:0e0631af0305 655 namespace cuda
RyoheiHagimoto 0:0e0631af0305 656 {
RyoheiHagimoto 0:0e0631af0305 657 class CV_EXPORTS GpuMat;
RyoheiHagimoto 0:0e0631af0305 658 class CV_EXPORTS HostMem;
RyoheiHagimoto 0:0e0631af0305 659 class CV_EXPORTS Stream;
RyoheiHagimoto 0:0e0631af0305 660 class CV_EXPORTS Event;
RyoheiHagimoto 0:0e0631af0305 661 }
RyoheiHagimoto 0:0e0631af0305 662
RyoheiHagimoto 0:0e0631af0305 663 namespace cudev
RyoheiHagimoto 0:0e0631af0305 664 {
RyoheiHagimoto 0:0e0631af0305 665 template <typename _Tp> class GpuMat_;
RyoheiHagimoto 0:0e0631af0305 666 }
RyoheiHagimoto 0:0e0631af0305 667
RyoheiHagimoto 0:0e0631af0305 668 namespace ipp
RyoheiHagimoto 0:0e0631af0305 669 {
RyoheiHagimoto 0:0e0631af0305 670 CV_EXPORTS int getIppFeatures();
RyoheiHagimoto 0:0e0631af0305 671 CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
RyoheiHagimoto 0:0e0631af0305 672 int line = 0);
RyoheiHagimoto 0:0e0631af0305 673 CV_EXPORTS int getIppStatus();
RyoheiHagimoto 0:0e0631af0305 674 CV_EXPORTS String getIppErrorLocation();
RyoheiHagimoto 0:0e0631af0305 675 CV_EXPORTS bool useIPP();
RyoheiHagimoto 0:0e0631af0305 676 CV_EXPORTS void setUseIPP(bool flag);
RyoheiHagimoto 0:0e0631af0305 677
RyoheiHagimoto 0:0e0631af0305 678 } // ipp
RyoheiHagimoto 0:0e0631af0305 679
RyoheiHagimoto 0:0e0631af0305 680 //! @endcond
RyoheiHagimoto 0:0e0631af0305 681
RyoheiHagimoto 0:0e0631af0305 682 //! @} core_utils
RyoheiHagimoto 0:0e0631af0305 683
RyoheiHagimoto 0:0e0631af0305 684
RyoheiHagimoto 0:0e0631af0305 685
RyoheiHagimoto 0:0e0631af0305 686
RyoheiHagimoto 0:0e0631af0305 687 } // cv
RyoheiHagimoto 0:0e0631af0305 688
RyoheiHagimoto 0:0e0631af0305 689 #include "opencv2/core/neon_utils.hpp"
RyoheiHagimoto 0:0e0631af0305 690
RyoheiHagimoto 0:0e0631af0305 691 #endif //OPENCV_CORE_BASE_HPP