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
private.hpp
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 // Third party copyrights are property of their respective owners. 00017 // 00018 // Redistribution and use in source and binary forms, with or without modification, 00019 // are permitted provided that the following conditions are met: 00020 // 00021 // * Redistribution's of source code must retain the above copyright notice, 00022 // this list of conditions and the following disclaimer. 00023 // 00024 // * Redistribution's in binary form must reproduce the above copyright notice, 00025 // this list of conditions and the following disclaimer in the documentation 00026 // and/or other materials provided with the distribution. 00027 // 00028 // * The name of the copyright holders may not be used to endorse or promote products 00029 // derived from this software without specific prior written permission. 00030 // 00031 // This software is provided by the copyright holders and contributors "as is" and 00032 // any express or implied warranties, including, but not limited to, the implied 00033 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00034 // In no event shall the Intel Corporation or contributors be liable for any direct, 00035 // indirect, incidental, special, exemplary, or consequential damages 00036 // (including, but not limited to, procurement of substitute goods or services; 00037 // loss of use, data, or profits; or business interruption) however caused 00038 // and on any theory of liability, whether in contract, strict liability, 00039 // or tort (including negligence or otherwise) arising in any way out of 00040 // the use of this software, even if advised of the possibility of such damage. 00041 // 00042 //M*/ 00043 00044 #ifndef __OPENCV_CORE_PRIVATE_HPP__ 00045 #define __OPENCV_CORE_PRIVATE_HPP__ 00046 00047 #ifndef __OPENCV_BUILD 00048 //# error this is a private header which should not be used from outside of the OpenCV library 00049 #endif 00050 00051 #include "opencv2/core.hpp" 00052 #include "cvconfig.h" 00053 00054 #ifdef HAVE_EIGEN 00055 # if defined __GNUC__ && defined __APPLE__ 00056 # pragma GCC diagnostic ignored "-Wshadow" 00057 # endif 00058 # include <Eigen/Core> 00059 # include "opencv2/core/eigen.hpp" 00060 #endif 00061 00062 #ifdef HAVE_TBB 00063 # include "tbb/tbb_stddef.h" 00064 # if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 00065 # include "tbb/tbb.h" 00066 # include "tbb/task.h" 00067 # undef min 00068 # undef max 00069 # else 00070 # undef HAVE_TBB 00071 # endif 00072 #endif 00073 00074 //! @cond IGNORED 00075 00076 namespace cv 00077 { 00078 #ifdef HAVE_TBB 00079 00080 typedef tbb::blocked_range<int> BlockedRange; 00081 00082 template<typename Body> static inline 00083 void parallel_for( const BlockedRange& range, const Body& body ) 00084 { 00085 tbb::parallel_for(range, body); 00086 } 00087 00088 typedef tbb::split Split; 00089 00090 template<typename Body> static inline 00091 void parallel_reduce( const BlockedRange& range, Body& body ) 00092 { 00093 tbb::parallel_reduce(range, body); 00094 } 00095 00096 typedef tbb::concurrent_vector<Rect> ConcurrentRectVector; 00097 #else 00098 class BlockedRange 00099 { 00100 public: 00101 BlockedRange() : _begin(0), _end(0), _grainsize(0) {} 00102 BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {} 00103 int begin() const { return _begin; } 00104 int end() const { return _end; } 00105 int grainsize() const { return _grainsize; } 00106 00107 protected: 00108 int _begin, _end, _grainsize; 00109 }; 00110 00111 template<typename Body> static inline 00112 void parallel_for( const BlockedRange& range, const Body& body ) 00113 { 00114 body(range); 00115 } 00116 typedef std::vector<Rect> ConcurrentRectVector; 00117 00118 class Split {}; 00119 00120 template<typename Body> static inline 00121 void parallel_reduce( const BlockedRange& range, Body& body ) 00122 { 00123 body(range); 00124 } 00125 #endif 00126 00127 // Returns a static string if there is a parallel framework, 00128 // NULL otherwise. 00129 CV_EXPORTS const char* currentParallelFramework(); 00130 } //namespace cv 00131 00132 /****************************************************************************************\ 00133 * Common declarations * 00134 \****************************************************************************************/ 00135 00136 /* the alignment of all the allocated buffers */ 00137 #define CV_MALLOC_ALIGN 16 00138 00139 /* IEEE754 constants and macros */ 00140 #define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0)) 00141 #define CV_TOGGLE_DBL(x) ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0)) 00142 00143 static inline void* cvAlignPtr( const void* ptr, int align = 32 ) 00144 { 00145 CV_DbgAssert ( (align & (align-1)) == 0 ); 00146 return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) ); 00147 } 00148 00149 static inline int cvAlign( int size, int align ) 00150 { 00151 CV_DbgAssert( (align & (align-1)) == 0 && size < INT_MAX ); 00152 return (size + align - 1) & -align; 00153 } 00154 00155 #ifdef IPL_DEPTH_8U 00156 static inline cv::Size cvGetMatSize( const CvMat* mat ) 00157 { 00158 return cv::Size(mat->cols, mat->rows); 00159 } 00160 #endif 00161 00162 namespace cv 00163 { 00164 CV_EXPORTS void scalarToRawData(const cv::Scalar & s, void* buf, int type, int unroll_to = 0); 00165 } 00166 00167 // property implementation macros 00168 00169 #define CV_IMPL_PROPERTY_RO(type, name, member) \ 00170 inline type get##name() const { return member; } 00171 00172 #define CV_HELP_IMPL_PROPERTY(r_type, w_type, name, member) \ 00173 CV_IMPL_PROPERTY_RO(r_type, name, member) \ 00174 inline void set##name(w_type val) { member = val; } 00175 00176 #define CV_HELP_WRAP_PROPERTY(r_type, w_type, name, internal_name, internal_obj) \ 00177 r_type get##name() const { return internal_obj.get##internal_name(); } \ 00178 void set##name(w_type val) { internal_obj.set##internal_name(val); } 00179 00180 #define CV_IMPL_PROPERTY(type, name, member) CV_HELP_IMPL_PROPERTY(type, type, name, member) 00181 #define CV_IMPL_PROPERTY_S(type, name, member) CV_HELP_IMPL_PROPERTY(type, const type &, name, member) 00182 00183 #define CV_WRAP_PROPERTY(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, type, name, internal_name, internal_obj) 00184 #define CV_WRAP_PROPERTY_S(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, const type &, name, internal_name, internal_obj) 00185 00186 #define CV_WRAP_SAME_PROPERTY(type, name, internal_obj) CV_WRAP_PROPERTY(type, name, name, internal_obj) 00187 #define CV_WRAP_SAME_PROPERTY_S(type, name, internal_obj) CV_WRAP_PROPERTY_S(type, name, name, internal_obj) 00188 00189 /****************************************************************************************\ 00190 * Structures and macros for integration with IPP * 00191 \****************************************************************************************/ 00192 00193 #ifdef HAVE_IPP 00194 #include "ipp.h" 00195 00196 #ifndef IPP_VERSION_UPDATE // prior to 7.1 00197 #define IPP_VERSION_UPDATE 0 00198 #endif 00199 00200 #define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE) 00201 00202 // General define for ipp function disabling 00203 #define IPP_DISABLE_BLOCK 0 00204 00205 #ifdef CV_MALLOC_ALIGN 00206 #undef CV_MALLOC_ALIGN 00207 #endif 00208 #define CV_MALLOC_ALIGN 32 // required for AVX optimization 00209 00210 #define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__) 00211 00212 static inline IppiSize ippiSize(int width, int height) 00213 { 00214 IppiSize size = { width, height }; 00215 return size; 00216 } 00217 00218 static inline IppiSize ippiSize(const cv::Size & _size) 00219 { 00220 IppiSize size = { _size.width, _size.height }; 00221 return size; 00222 } 00223 00224 static inline IppiBorderType ippiGetBorderType(int borderTypeNI) 00225 { 00226 return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst : 00227 borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap : 00228 borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl : 00229 borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror : 00230 borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1; 00231 } 00232 00233 static inline IppDataType ippiGetDataType(int depth) 00234 { 00235 return depth == CV_8U ? ipp8u : 00236 depth == CV_8S ? ipp8s : 00237 depth == CV_16U ? ipp16u : 00238 depth == CV_16S ? ipp16s : 00239 depth == CV_32S ? ipp32s : 00240 depth == CV_32F ? ipp32f : 00241 depth == CV_64F ? ipp64f : (IppDataType)-1; 00242 } 00243 00244 // IPP temporary buffer hepler 00245 template<typename T> 00246 class IppAutoBuffer 00247 { 00248 public: 00249 IppAutoBuffer() { m_pBuffer = NULL; } 00250 IppAutoBuffer(int size) { Alloc(size); } 00251 ~IppAutoBuffer() { Release(); } 00252 T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; } 00253 void Release() { if(m_pBuffer) ippFree(m_pBuffer); } 00254 inline operator T* () { return (T*)m_pBuffer;} 00255 inline operator const T* () const { return (const T*)m_pBuffer;} 00256 private: 00257 // Disable copy operations 00258 IppAutoBuffer(IppAutoBuffer &) {}; 00259 IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;}; 00260 00261 T* m_pBuffer; 00262 }; 00263 00264 #else 00265 #define IPP_VERSION_X100 0 00266 #endif 00267 00268 // There shoud be no API difference in OpenCV between ICV and IPP since 9.0 00269 #if (defined HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 900 00270 #undef HAVE_IPP_ICV_ONLY 00271 #endif 00272 00273 #ifdef HAVE_IPP_ICV_ONLY 00274 #define HAVE_ICV 1 00275 #else 00276 #define HAVE_ICV 0 00277 #endif 00278 00279 #if defined HAVE_IPP 00280 #if IPP_VERSION_X100 >= 900 00281 #define IPP_INITIALIZER(FEAT) \ 00282 { \ 00283 if(FEAT) \ 00284 ippSetCpuFeatures(FEAT); \ 00285 else \ 00286 ippInit(); \ 00287 } 00288 #elif IPP_VERSION_X100 >= 800 00289 #define IPP_INITIALIZER(FEAT) \ 00290 { \ 00291 ippInit(); \ 00292 } 00293 #else 00294 #define IPP_INITIALIZER(FEAT) \ 00295 { \ 00296 ippStaticInit(); \ 00297 } 00298 #endif 00299 00300 #ifdef CVAPI_EXPORTS 00301 #define IPP_INITIALIZER_AUTO \ 00302 struct __IppInitializer__ \ 00303 { \ 00304 __IppInitializer__() \ 00305 {IPP_INITIALIZER(cv::ipp::getIppFeatures())} \ 00306 }; \ 00307 static struct __IppInitializer__ __ipp_initializer__; 00308 #else 00309 #define IPP_INITIALIZER_AUTO 00310 #endif 00311 #else 00312 #define IPP_INITIALIZER 00313 #define IPP_INITIALIZER_AUTO 00314 #endif 00315 00316 #define CV_IPP_CHECK_COND (cv::ipp::useIPP()) 00317 #define CV_IPP_CHECK() if(CV_IPP_CHECK_COND) 00318 00319 #ifdef HAVE_IPP 00320 00321 #ifdef CV_IPP_RUN_VERBOSE 00322 #define CV_IPP_RUN_(condition, func, ...) \ 00323 { \ 00324 if (cv::ipp::useIPP() && (condition) && func) \ 00325 { \ 00326 printf("%s: IPP implementation is running\n", CV_Func); \ 00327 fflush(stdout); \ 00328 CV_IMPL_ADD(CV_IMPL_IPP); \ 00329 return __VA_ARGS__; \ 00330 } \ 00331 else \ 00332 { \ 00333 printf("%s: Plain implementation is running\n", CV_Func); \ 00334 fflush(stdout); \ 00335 } \ 00336 } 00337 #elif defined CV_IPP_RUN_ASSERT 00338 #define CV_IPP_RUN_(condition, func, ...) \ 00339 { \ 00340 if (cv::ipp::useIPP() && (condition)) \ 00341 { \ 00342 if(func) \ 00343 { \ 00344 CV_IMPL_ADD(CV_IMPL_IPP); \ 00345 } \ 00346 else \ 00347 { \ 00348 setIppErrorStatus(); \ 00349 CV_Error(cv::Error::StsAssert, #func); \ 00350 } \ 00351 return __VA_ARGS__; \ 00352 } \ 00353 } 00354 #else 00355 #define CV_IPP_RUN_(condition, func, ...) \ 00356 if (cv::ipp::useIPP() && (condition) && func) \ 00357 { \ 00358 CV_IMPL_ADD(CV_IMPL_IPP); \ 00359 return __VA_ARGS__; \ 00360 } 00361 #endif 00362 00363 #else 00364 #define CV_IPP_RUN_(condition, func, ...) 00365 #endif 00366 00367 #define CV_IPP_RUN(condition, func, ...) CV_IPP_RUN_(condition, func, __VA_ARGS__) 00368 00369 00370 #ifndef IPPI_CALL 00371 # define IPPI_CALL(func) CV_Assert((func) >= 0) 00372 #endif 00373 00374 /* IPP-compatible return codes */ 00375 typedef enum CvStatus 00376 { 00377 CV_BADMEMBLOCK_ERR = -113, 00378 CV_INPLACE_NOT_SUPPORTED_ERR= -112, 00379 CV_UNMATCHED_ROI_ERR = -111, 00380 CV_NOTFOUND_ERR = -110, 00381 CV_BADCONVERGENCE_ERR = -109, 00382 00383 CV_BADDEPTH_ERR = -107, 00384 CV_BADROI_ERR = -106, 00385 CV_BADHEADER_ERR = -105, 00386 CV_UNMATCHED_FORMATS_ERR = -104, 00387 CV_UNSUPPORTED_COI_ERR = -103, 00388 CV_UNSUPPORTED_CHANNELS_ERR = -102, 00389 CV_UNSUPPORTED_DEPTH_ERR = -101, 00390 CV_UNSUPPORTED_FORMAT_ERR = -100, 00391 00392 CV_BADARG_ERR = -49, //ipp comp 00393 CV_NOTDEFINED_ERR = -48, //ipp comp 00394 00395 CV_BADCHANNELS_ERR = -47, //ipp comp 00396 CV_BADRANGE_ERR = -44, //ipp comp 00397 CV_BADSTEP_ERR = -29, //ipp comp 00398 00399 CV_BADFLAG_ERR = -12, 00400 CV_DIV_BY_ZERO_ERR = -11, //ipp comp 00401 CV_BADCOEF_ERR = -10, 00402 00403 CV_BADFACTOR_ERR = -7, 00404 CV_BADPOINT_ERR = -6, 00405 CV_BADSCALE_ERR = -4, 00406 CV_OUTOFMEM_ERR = -3, 00407 CV_NULLPTR_ERR = -2, 00408 CV_BADSIZE_ERR = -1, 00409 CV_NO_ERR = 0, 00410 CV_OK = CV_NO_ERR 00411 } 00412 CvStatus; 00413 00414 #ifdef HAVE_TEGRA_OPTIMIZATION 00415 namespace tegra { 00416 00417 CV_EXPORTS bool useTegra(); 00418 CV_EXPORTS void setUseTegra(bool flag); 00419 00420 } 00421 #endif 00422 00423 //! @endcond 00424 00425 #endif // __OPENCV_CORE_PRIVATE_HPP__ 00426
Generated on Tue Jul 12 2022 14:47:32 by
1.7.2
