Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project-sd-card by
cvdef.h
00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Copyright (C) 2013, OpenCV Foundation, all rights reserved. 00016 // Copyright (C) 2015, Itseez Inc., all rights reserved. 00017 // Third party copyrights are property of their respective owners. 00018 // 00019 // Redistribution and use in source and binary forms, with or without modification, 00020 // are permitted provided that the following conditions are met: 00021 // 00022 // * Redistribution's of source code must retain the above copyright notice, 00023 // this list of conditions and the following disclaimer. 00024 // 00025 // * Redistribution's in binary form must reproduce the above copyright notice, 00026 // this list of conditions and the following disclaimer in the documentation 00027 // and/or other materials provided with the distribution. 00028 // 00029 // * The name of the copyright holders may not be used to endorse or promote products 00030 // derived from this software without specific prior written permission. 00031 // 00032 // This software is provided by the copyright holders and contributors "as is" and 00033 // any express or implied warranties, including, but not limited to, the implied 00034 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00035 // In no event shall the Intel Corporation or contributors be liable for any direct, 00036 // indirect, incidental, special, exemplary, or consequential damages 00037 // (including, but not limited to, procurement of substitute goods or services; 00038 // loss of use, data, or profits; or business interruption) however caused 00039 // and on any theory of liability, whether in contract, strict liability, 00040 // or tort (including negligence or otherwise) arising in any way out of 00041 // the use of this software, even if advised of the possibility of such damage. 00042 // 00043 //M*/ 00044 00045 #ifndef __OPENCV_CORE_CVDEF_H__ 00046 #define __OPENCV_CORE_CVDEF_H__ 00047 00048 //! @addtogroup core_utils 00049 //! @{ 00050 00051 #if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300 00052 # define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */ 00053 #endif 00054 00055 // undef problematic defines sometimes defined by system headers (windows.h in particular) 00056 #undef small 00057 #undef min 00058 #undef max 00059 #undef abs 00060 #undef Complex 00061 00062 #if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300 00063 # define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */ 00064 #endif 00065 00066 #include <limits.h> 00067 #include "opencv2/core/hal/interface.h" 00068 00069 #if defined __ICL 00070 # define CV_ICC __ICL 00071 #elif defined __ICC 00072 # define CV_ICC __ICC 00073 #elif defined __ECL 00074 # define CV_ICC __ECL 00075 #elif defined __ECC 00076 # define CV_ICC __ECC 00077 #elif defined __INTEL_COMPILER 00078 # define CV_ICC __INTEL_COMPILER 00079 #endif 00080 00081 #ifndef CV_INLINE 00082 # if defined __cplusplus 00083 # define CV_INLINE static inline 00084 # elif defined _MSC_VER 00085 # define CV_INLINE __inline 00086 # else 00087 # define CV_INLINE static 00088 # endif 00089 #endif 00090 00091 #if defined CV_ICC && !defined CV_ENABLE_UNROLLED 00092 # define CV_ENABLE_UNROLLED 0 00093 #else 00094 # define CV_ENABLE_UNROLLED 1 00095 #endif 00096 00097 #ifdef __GNUC__ 00098 # define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x))) 00099 #elif defined _MSC_VER 00100 # define CV_DECL_ALIGNED(x) __declspec(align(x)) 00101 #else 00102 # define CV_DECL_ALIGNED(x) 00103 #endif 00104 00105 /* CPU features and intrinsics support */ 00106 #define CV_CPU_NONE 0 00107 #define CV_CPU_MMX 1 00108 #define CV_CPU_SSE 2 00109 #define CV_CPU_SSE2 3 00110 #define CV_CPU_SSE3 4 00111 #define CV_CPU_SSSE3 5 00112 #define CV_CPU_SSE4_1 6 00113 #define CV_CPU_SSE4_2 7 00114 #define CV_CPU_POPCNT 8 00115 00116 #define CV_CPU_AVX 10 00117 #define CV_CPU_AVX2 11 00118 #define CV_CPU_FMA3 12 00119 00120 #define CV_CPU_AVX_512F 13 00121 #define CV_CPU_AVX_512BW 14 00122 #define CV_CPU_AVX_512CD 15 00123 #define CV_CPU_AVX_512DQ 16 00124 #define CV_CPU_AVX_512ER 17 00125 #define CV_CPU_AVX_512IFMA512 18 00126 #define CV_CPU_AVX_512PF 19 00127 #define CV_CPU_AVX_512VBMI 20 00128 #define CV_CPU_AVX_512VL 21 00129 00130 #define CV_CPU_NEON 100 00131 00132 // when adding to this list remember to update the following enum 00133 #define CV_HARDWARE_MAX_FEATURE 255 00134 00135 /** @brief Available CPU features. 00136 */ 00137 enum CpuFeatures { 00138 CPU_MMX = 1, 00139 CPU_SSE = 2, 00140 CPU_SSE2 = 3, 00141 CPU_SSE3 = 4, 00142 CPU_SSSE3 = 5, 00143 CPU_SSE4_1 = 6, 00144 CPU_SSE4_2 = 7, 00145 CPU_POPCNT = 8, 00146 00147 CPU_AVX = 10, 00148 CPU_AVX2 = 11, 00149 CPU_FMA3 = 12, 00150 00151 CPU_AVX_512F = 13, 00152 CPU_AVX_512BW = 14, 00153 CPU_AVX_512CD = 15, 00154 CPU_AVX_512DQ = 16, 00155 CPU_AVX_512ER = 17, 00156 CPU_AVX_512IFMA512 = 18, 00157 CPU_AVX_512PF = 19, 00158 CPU_AVX_512VBMI = 20, 00159 CPU_AVX_512VL = 21, 00160 00161 CPU_NEON = 100 00162 }; 00163 00164 // do not include SSE/AVX/NEON headers for NVCC compiler 00165 #ifndef __CUDACC__ 00166 00167 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) 00168 # include <emmintrin.h> 00169 # define CV_MMX 1 00170 # define CV_SSE 1 00171 # define CV_SSE2 1 00172 # if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500) 00173 # include <pmmintrin.h> 00174 # define CV_SSE3 1 00175 # endif 00176 # if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500) 00177 # include <tmmintrin.h> 00178 # define CV_SSSE3 1 00179 # endif 00180 # if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500) 00181 # include <smmintrin.h> 00182 # define CV_SSE4_1 1 00183 # endif 00184 # if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500) 00185 # include <nmmintrin.h> 00186 # define CV_SSE4_2 1 00187 # endif 00188 # if defined __POPCNT__ || (defined _MSC_VER && _MSC_VER >= 1500) 00189 # ifdef _MSC_VER 00190 # include <nmmintrin.h> 00191 # else 00192 # include <popcntintrin.h> 00193 # endif 00194 # define CV_POPCNT 1 00195 # endif 00196 # if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600 && 0) 00197 // MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX 00198 // See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32 00199 # include <immintrin.h> 00200 # define CV_AVX 1 00201 # if defined(_XCR_XFEATURE_ENABLED_MASK) 00202 # define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK) 00203 # else 00204 # define __xgetbv() 0 00205 # endif 00206 # endif 00207 # if defined __AVX2__ || (defined _MSC_VER && _MSC_VER >= 1800 && 0) 00208 # include <immintrin.h> 00209 # define CV_AVX2 1 00210 # if defined __FMA__ 00211 # define CV_FMA3 1 00212 # endif 00213 # endif 00214 #endif 00215 00216 #if (defined WIN32 || defined _WIN32) && defined(_M_ARM) 00217 # include <Intrin.h> 00218 # include "arm_neon.h" 00219 # define CV_NEON 1 00220 # define CPU_HAS_NEON_FEATURE (true) 00221 #elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) 00222 # include <arm_neon.h> 00223 # define CV_NEON 1 00224 #endif 00225 00226 #if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ 00227 # define CV_VFP 1 00228 #endif 00229 00230 #endif // __CUDACC__ 00231 00232 #ifndef CV_POPCNT 00233 #define CV_POPCNT 0 00234 #endif 00235 #ifndef CV_MMX 00236 # define CV_MMX 0 00237 #endif 00238 #ifndef CV_SSE 00239 # define CV_SSE 0 00240 #endif 00241 #ifndef CV_SSE2 00242 # define CV_SSE2 0 00243 #endif 00244 #ifndef CV_SSE3 00245 # define CV_SSE3 0 00246 #endif 00247 #ifndef CV_SSSE3 00248 # define CV_SSSE3 0 00249 #endif 00250 #ifndef CV_SSE4_1 00251 # define CV_SSE4_1 0 00252 #endif 00253 #ifndef CV_SSE4_2 00254 # define CV_SSE4_2 0 00255 #endif 00256 #ifndef CV_AVX 00257 # define CV_AVX 0 00258 #endif 00259 #ifndef CV_AVX2 00260 # define CV_AVX2 0 00261 #endif 00262 #ifndef CV_FMA3 00263 # define CV_FMA3 0 00264 #endif 00265 #ifndef CV_AVX_512F 00266 # define CV_AVX_512F 0 00267 #endif 00268 #ifndef CV_AVX_512BW 00269 # define CV_AVX_512BW 0 00270 #endif 00271 #ifndef CV_AVX_512CD 00272 # define CV_AVX_512CD 0 00273 #endif 00274 #ifndef CV_AVX_512DQ 00275 # define CV_AVX_512DQ 0 00276 #endif 00277 #ifndef CV_AVX_512ER 00278 # define CV_AVX_512ER 0 00279 #endif 00280 #ifndef CV_AVX_512IFMA512 00281 # define CV_AVX_512IFMA512 0 00282 #endif 00283 #ifndef CV_AVX_512PF 00284 # define CV_AVX_512PF 0 00285 #endif 00286 #ifndef CV_AVX_512VBMI 00287 # define CV_AVX_512VBMI 0 00288 #endif 00289 #ifndef CV_AVX_512VL 00290 # define CV_AVX_512VL 0 00291 #endif 00292 00293 #ifndef CV_NEON 00294 # define CV_NEON 0 00295 #endif 00296 00297 #ifndef CV_VFP 00298 # define CV_VFP 0 00299 #endif 00300 00301 /* fundamental constants */ 00302 #define CV_PI 3.1415926535897932384626433832795 00303 #define CV_2PI 6.283185307179586476925286766559 00304 #define CV_LOG2 0.69314718055994530941723212145818 00305 00306 typedef union Cv32suf 00307 { 00308 int i; 00309 unsigned u; 00310 float f; 00311 } 00312 Cv32suf; 00313 00314 typedef union Cv64suf 00315 { 00316 int64 i; 00317 uint64 u; 00318 double f; 00319 } 00320 Cv64suf; 00321 00322 #define OPENCV_ABI_COMPATIBILITY 300 00323 00324 #ifdef __OPENCV_BUILD 00325 # define DISABLE_OPENCV_24_COMPATIBILITY 00326 #endif 00327 00328 #if (defined WIN32 || defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS 00329 # define CV_EXPORTS __declspec(dllexport) 00330 #elif defined __GNUC__ && __GNUC__ >= 4 00331 # define CV_EXPORTS __attribute__ ((visibility ("default"))) 00332 #else 00333 # define CV_EXPORTS 00334 #endif 00335 00336 #ifndef CV_EXTERN_C 00337 # ifdef __cplusplus 00338 # define CV_EXTERN_C extern "C" 00339 # else 00340 # define CV_EXTERN_C 00341 # endif 00342 #endif 00343 00344 /* special informative macros for wrapper generators */ 00345 #define CV_EXPORTS_W CV_EXPORTS 00346 #define CV_EXPORTS_W_SIMPLE CV_EXPORTS 00347 #define CV_EXPORTS_AS(synonym) CV_EXPORTS 00348 #define CV_EXPORTS_W_MAP CV_EXPORTS 00349 #define CV_IN_OUT 00350 #define CV_OUT 00351 #define CV_PROP 00352 #define CV_PROP_RW 00353 #define CV_WRAP 00354 #define CV_WRAP_AS(synonym) 00355 00356 /****************************************************************************************\ 00357 * Matrix type (Mat) * 00358 \****************************************************************************************/ 00359 00360 #define CV_CN_MAX 512 00361 #define CV_CN_SHIFT 3 00362 #define CV_DEPTH_MAX (1 << CV_CN_SHIFT) 00363 00364 #define CV_8U 0 00365 #define CV_8S 1 00366 #define CV_16U 2 00367 #define CV_16S 3 00368 #define CV_32S 4 00369 #define CV_32F 5 00370 #define CV_64F 6 00371 #define CV_USRTYPE1 7 00372 00373 #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) 00374 #define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) 00375 00376 #define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) 00377 #define CV_MAKE_TYPE CV_MAKETYPE 00378 00379 #define CV_8UC1 CV_MAKETYPE(CV_8U,1) 00380 #define CV_8UC2 CV_MAKETYPE(CV_8U,2) 00381 #define CV_8UC3 CV_MAKETYPE(CV_8U,3) 00382 #define CV_8UC4 CV_MAKETYPE(CV_8U,4) 00383 #define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) 00384 00385 #define CV_8SC1 CV_MAKETYPE(CV_8S,1) 00386 #define CV_8SC2 CV_MAKETYPE(CV_8S,2) 00387 #define CV_8SC3 CV_MAKETYPE(CV_8S,3) 00388 #define CV_8SC4 CV_MAKETYPE(CV_8S,4) 00389 #define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) 00390 00391 #define CV_16UC1 CV_MAKETYPE(CV_16U,1) 00392 #define CV_16UC2 CV_MAKETYPE(CV_16U,2) 00393 #define CV_16UC3 CV_MAKETYPE(CV_16U,3) 00394 #define CV_16UC4 CV_MAKETYPE(CV_16U,4) 00395 #define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) 00396 00397 #define CV_16SC1 CV_MAKETYPE(CV_16S,1) 00398 #define CV_16SC2 CV_MAKETYPE(CV_16S,2) 00399 #define CV_16SC3 CV_MAKETYPE(CV_16S,3) 00400 #define CV_16SC4 CV_MAKETYPE(CV_16S,4) 00401 #define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) 00402 00403 #define CV_32SC1 CV_MAKETYPE(CV_32S,1) 00404 #define CV_32SC2 CV_MAKETYPE(CV_32S,2) 00405 #define CV_32SC3 CV_MAKETYPE(CV_32S,3) 00406 #define CV_32SC4 CV_MAKETYPE(CV_32S,4) 00407 #define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) 00408 00409 #define CV_32FC1 CV_MAKETYPE(CV_32F,1) 00410 #define CV_32FC2 CV_MAKETYPE(CV_32F,2) 00411 #define CV_32FC3 CV_MAKETYPE(CV_32F,3) 00412 #define CV_32FC4 CV_MAKETYPE(CV_32F,4) 00413 #define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) 00414 00415 #define CV_64FC1 CV_MAKETYPE(CV_64F,1) 00416 #define CV_64FC2 CV_MAKETYPE(CV_64F,2) 00417 #define CV_64FC3 CV_MAKETYPE(CV_64F,3) 00418 #define CV_64FC4 CV_MAKETYPE(CV_64F,4) 00419 #define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) 00420 00421 #define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) 00422 #define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) 00423 #define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) 00424 #define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) 00425 #define CV_MAT_CONT_FLAG_SHIFT 14 00426 #define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) 00427 #define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) 00428 #define CV_IS_CONT_MAT CV_IS_MAT_CONT 00429 #define CV_SUBMAT_FLAG_SHIFT 15 00430 #define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) 00431 #define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) 00432 00433 /** Size of each channel item, 00434 0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ 00435 #define CV_ELEM_SIZE1(type) \ 00436 ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) 00437 00438 /** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ 00439 #define CV_ELEM_SIZE(type) \ 00440 (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) 00441 00442 #ifndef MIN 00443 # define MIN(a,b) ((a) > (b) ? (b) : (a)) 00444 #endif 00445 00446 #ifndef MAX 00447 # define MAX(a,b) ((a) < (b) ? (b) : (a)) 00448 #endif 00449 00450 /****************************************************************************************\ 00451 * exchange-add operation for atomic operations on reference counters * 00452 \****************************************************************************************/ 00453 00454 #if defined __INTEL_COMPILER && !(defined WIN32 || defined _WIN32) 00455 // atomic increment on the linux version of the Intel(tm) compiler 00456 # define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta) 00457 #elif defined __GNUC__ 00458 # if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) 00459 # ifdef __ATOMIC_ACQ_REL 00460 # define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL) 00461 # else 00462 # define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4) 00463 # endif 00464 # else 00465 # if defined __ATOMIC_ACQ_REL && !defined __clang__ 00466 // version for gcc >= 4.7 00467 # define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL) 00468 # else 00469 # define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta)) 00470 # endif 00471 # endif 00472 #elif defined _MSC_VER && !defined RC_INVOKED 00473 # include <intrin.h> 00474 # define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta) 00475 #else 00476 CV_INLINE CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } 00477 #endif 00478 00479 00480 /****************************************************************************************\ 00481 * CV_NORETURN attribute * 00482 \****************************************************************************************/ 00483 00484 #ifndef CV_NORETURN 00485 # if defined(__GNUC__) 00486 # define CV_NORETURN __attribute__((__noreturn__)) 00487 # elif defined(_MSC_VER) && (_MSC_VER >= 1300) 00488 # define CV_NORETURN __declspec(noreturn) 00489 # else 00490 # define CV_NORETURN /* nothing by default */ 00491 # endif 00492 #endif 00493 00494 00495 /****************************************************************************************\ 00496 * C++ Move semantics * 00497 \****************************************************************************************/ 00498 00499 #ifndef CV_CXX_MOVE_SEMANTICS 00500 # if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) && _MSC_VER >= 1600 00501 # define CV_CXX_MOVE_SEMANTICS 1 00502 # elif defined(__clang) 00503 # if __has_feature(cxx_rvalue_references) 00504 # define CV_CXX_MOVE_SEMANTICS 1 00505 # endif 00506 # endif 00507 #else 00508 # if CV_CXX_MOVE_SEMANTICS == 0 00509 # undef CV_CXX_MOVE_SEMANTICS 00510 # endif 00511 #endif 00512 00513 //! @} 00514 00515 #endif // __OPENCV_CORE_CVDEF_H__ 00516
Generated on Tue Jul 12 2022 14:46:32 by
