opencv on mbed

Dependencies:   mbed

Committer:
joeverbout
Date:
Thu Mar 31 21:16:38 2016 +0000
Revision:
0:ea44dc9ed014
OpenCV on mbed attempt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeverbout 0:ea44dc9ed014 1 /*M///////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 2 //
joeverbout 0:ea44dc9ed014 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
joeverbout 0:ea44dc9ed014 4 //
joeverbout 0:ea44dc9ed014 5 // By downloading, copying, installing or using the software you agree to this license.
joeverbout 0:ea44dc9ed014 6 // If you do not agree to this license, do not download, install,
joeverbout 0:ea44dc9ed014 7 // copy or use the software.
joeverbout 0:ea44dc9ed014 8 //
joeverbout 0:ea44dc9ed014 9 //
joeverbout 0:ea44dc9ed014 10 // License Agreement
joeverbout 0:ea44dc9ed014 11 // For Open Source Computer Vision Library
joeverbout 0:ea44dc9ed014 12 //
joeverbout 0:ea44dc9ed014 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
joeverbout 0:ea44dc9ed014 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
joeverbout 0:ea44dc9ed014 16 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 17 //
joeverbout 0:ea44dc9ed014 18 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 19 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 20 //
joeverbout 0:ea44dc9ed014 21 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 22 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 23 //
joeverbout 0:ea44dc9ed014 24 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 25 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 26 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 27 //
joeverbout 0:ea44dc9ed014 28 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 29 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 30 //
joeverbout 0:ea44dc9ed014 31 // This software is provided by the copyright holders and contributors "as is" and
joeverbout 0:ea44dc9ed014 32 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 34 // In no event shall the Intel Corporation or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 35 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 36 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 37 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 38 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 39 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 40 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 41 //
joeverbout 0:ea44dc9ed014 42 //M*/
joeverbout 0:ea44dc9ed014 43
joeverbout 0:ea44dc9ed014 44 #ifndef __OPENCV_CORE_PRIVATE_HPP__
joeverbout 0:ea44dc9ed014 45 #define __OPENCV_CORE_PRIVATE_HPP__
joeverbout 0:ea44dc9ed014 46
joeverbout 0:ea44dc9ed014 47 #ifndef __OPENCV_BUILD
joeverbout 0:ea44dc9ed014 48 # error this is a private header which should not be used from outside of the OpenCV library
joeverbout 0:ea44dc9ed014 49 #endif
joeverbout 0:ea44dc9ed014 50
joeverbout 0:ea44dc9ed014 51 #include "opencv2/core.hpp"
joeverbout 0:ea44dc9ed014 52 #include "cvconfig.h"
joeverbout 0:ea44dc9ed014 53
joeverbout 0:ea44dc9ed014 54 #ifdef HAVE_EIGEN
joeverbout 0:ea44dc9ed014 55 # if defined __GNUC__ && defined __APPLE__
joeverbout 0:ea44dc9ed014 56 # pragma GCC diagnostic ignored "-Wshadow"
joeverbout 0:ea44dc9ed014 57 # endif
joeverbout 0:ea44dc9ed014 58 # include <Eigen/Core>
joeverbout 0:ea44dc9ed014 59 # include "opencv2/core/eigen.hpp"
joeverbout 0:ea44dc9ed014 60 #endif
joeverbout 0:ea44dc9ed014 61
joeverbout 0:ea44dc9ed014 62 #ifdef HAVE_TBB
joeverbout 0:ea44dc9ed014 63 # include "tbb/tbb_stddef.h"
joeverbout 0:ea44dc9ed014 64 # if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
joeverbout 0:ea44dc9ed014 65 # include "tbb/tbb.h"
joeverbout 0:ea44dc9ed014 66 # include "tbb/task.h"
joeverbout 0:ea44dc9ed014 67 # undef min
joeverbout 0:ea44dc9ed014 68 # undef max
joeverbout 0:ea44dc9ed014 69 # else
joeverbout 0:ea44dc9ed014 70 # undef HAVE_TBB
joeverbout 0:ea44dc9ed014 71 # endif
joeverbout 0:ea44dc9ed014 72 #endif
joeverbout 0:ea44dc9ed014 73
joeverbout 0:ea44dc9ed014 74 //! @cond IGNORED
joeverbout 0:ea44dc9ed014 75
joeverbout 0:ea44dc9ed014 76 namespace cv
joeverbout 0:ea44dc9ed014 77 {
joeverbout 0:ea44dc9ed014 78 #ifdef HAVE_TBB
joeverbout 0:ea44dc9ed014 79
joeverbout 0:ea44dc9ed014 80 typedef tbb::blocked_range<int> BlockedRange;
joeverbout 0:ea44dc9ed014 81
joeverbout 0:ea44dc9ed014 82 template<typename Body> static inline
joeverbout 0:ea44dc9ed014 83 void parallel_for( const BlockedRange& range, const Body& body )
joeverbout 0:ea44dc9ed014 84 {
joeverbout 0:ea44dc9ed014 85 tbb::parallel_for(range, body);
joeverbout 0:ea44dc9ed014 86 }
joeverbout 0:ea44dc9ed014 87
joeverbout 0:ea44dc9ed014 88 typedef tbb::split Split;
joeverbout 0:ea44dc9ed014 89
joeverbout 0:ea44dc9ed014 90 template<typename Body> static inline
joeverbout 0:ea44dc9ed014 91 void parallel_reduce( const BlockedRange& range, Body& body )
joeverbout 0:ea44dc9ed014 92 {
joeverbout 0:ea44dc9ed014 93 tbb::parallel_reduce(range, body);
joeverbout 0:ea44dc9ed014 94 }
joeverbout 0:ea44dc9ed014 95
joeverbout 0:ea44dc9ed014 96 typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
joeverbout 0:ea44dc9ed014 97 #else
joeverbout 0:ea44dc9ed014 98 class BlockedRange
joeverbout 0:ea44dc9ed014 99 {
joeverbout 0:ea44dc9ed014 100 public:
joeverbout 0:ea44dc9ed014 101 BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
joeverbout 0:ea44dc9ed014 102 BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
joeverbout 0:ea44dc9ed014 103 int begin() const { return _begin; }
joeverbout 0:ea44dc9ed014 104 int end() const { return _end; }
joeverbout 0:ea44dc9ed014 105 int grainsize() const { return _grainsize; }
joeverbout 0:ea44dc9ed014 106
joeverbout 0:ea44dc9ed014 107 protected:
joeverbout 0:ea44dc9ed014 108 int _begin, _end, _grainsize;
joeverbout 0:ea44dc9ed014 109 };
joeverbout 0:ea44dc9ed014 110
joeverbout 0:ea44dc9ed014 111 template<typename Body> static inline
joeverbout 0:ea44dc9ed014 112 void parallel_for( const BlockedRange& range, const Body& body )
joeverbout 0:ea44dc9ed014 113 {
joeverbout 0:ea44dc9ed014 114 body(range);
joeverbout 0:ea44dc9ed014 115 }
joeverbout 0:ea44dc9ed014 116 typedef std::vector<Rect> ConcurrentRectVector;
joeverbout 0:ea44dc9ed014 117
joeverbout 0:ea44dc9ed014 118 class Split {};
joeverbout 0:ea44dc9ed014 119
joeverbout 0:ea44dc9ed014 120 template<typename Body> static inline
joeverbout 0:ea44dc9ed014 121 void parallel_reduce( const BlockedRange& range, Body& body )
joeverbout 0:ea44dc9ed014 122 {
joeverbout 0:ea44dc9ed014 123 body(range);
joeverbout 0:ea44dc9ed014 124 }
joeverbout 0:ea44dc9ed014 125 #endif
joeverbout 0:ea44dc9ed014 126
joeverbout 0:ea44dc9ed014 127 // Returns a static string if there is a parallel framework,
joeverbout 0:ea44dc9ed014 128 // NULL otherwise.
joeverbout 0:ea44dc9ed014 129 CV_EXPORTS const char* currentParallelFramework();
joeverbout 0:ea44dc9ed014 130 } //namespace cv
joeverbout 0:ea44dc9ed014 131
joeverbout 0:ea44dc9ed014 132 /****************************************************************************************\
joeverbout 0:ea44dc9ed014 133 * Common declarations *
joeverbout 0:ea44dc9ed014 134 \****************************************************************************************/
joeverbout 0:ea44dc9ed014 135
joeverbout 0:ea44dc9ed014 136 /* the alignment of all the allocated buffers */
joeverbout 0:ea44dc9ed014 137 #define CV_MALLOC_ALIGN 16
joeverbout 0:ea44dc9ed014 138
joeverbout 0:ea44dc9ed014 139 /* IEEE754 constants and macros */
joeverbout 0:ea44dc9ed014 140 #define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
joeverbout 0:ea44dc9ed014 141 #define CV_TOGGLE_DBL(x) ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
joeverbout 0:ea44dc9ed014 142
joeverbout 0:ea44dc9ed014 143 static inline void* cvAlignPtr( const void* ptr, int align = 32 )
joeverbout 0:ea44dc9ed014 144 {
joeverbout 0:ea44dc9ed014 145 CV_DbgAssert ( (align & (align-1)) == 0 );
joeverbout 0:ea44dc9ed014 146 return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
joeverbout 0:ea44dc9ed014 147 }
joeverbout 0:ea44dc9ed014 148
joeverbout 0:ea44dc9ed014 149 static inline int cvAlign( int size, int align )
joeverbout 0:ea44dc9ed014 150 {
joeverbout 0:ea44dc9ed014 151 CV_DbgAssert( (align & (align-1)) == 0 && size < INT_MAX );
joeverbout 0:ea44dc9ed014 152 return (size + align - 1) & -align;
joeverbout 0:ea44dc9ed014 153 }
joeverbout 0:ea44dc9ed014 154
joeverbout 0:ea44dc9ed014 155 #ifdef IPL_DEPTH_8U
joeverbout 0:ea44dc9ed014 156 static inline cv::Size cvGetMatSize( const CvMat* mat )
joeverbout 0:ea44dc9ed014 157 {
joeverbout 0:ea44dc9ed014 158 return cv::Size(mat->cols, mat->rows);
joeverbout 0:ea44dc9ed014 159 }
joeverbout 0:ea44dc9ed014 160 #endif
joeverbout 0:ea44dc9ed014 161
joeverbout 0:ea44dc9ed014 162 namespace cv
joeverbout 0:ea44dc9ed014 163 {
joeverbout 0:ea44dc9ed014 164 CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int unroll_to = 0);
joeverbout 0:ea44dc9ed014 165 }
joeverbout 0:ea44dc9ed014 166
joeverbout 0:ea44dc9ed014 167 // property implementation macros
joeverbout 0:ea44dc9ed014 168
joeverbout 0:ea44dc9ed014 169 #define CV_IMPL_PROPERTY_RO(type, name, member) \
joeverbout 0:ea44dc9ed014 170 inline type get##name() const { return member; }
joeverbout 0:ea44dc9ed014 171
joeverbout 0:ea44dc9ed014 172 #define CV_HELP_IMPL_PROPERTY(r_type, w_type, name, member) \
joeverbout 0:ea44dc9ed014 173 CV_IMPL_PROPERTY_RO(r_type, name, member) \
joeverbout 0:ea44dc9ed014 174 inline void set##name(w_type val) { member = val; }
joeverbout 0:ea44dc9ed014 175
joeverbout 0:ea44dc9ed014 176 #define CV_HELP_WRAP_PROPERTY(r_type, w_type, name, internal_name, internal_obj) \
joeverbout 0:ea44dc9ed014 177 r_type get##name() const { return internal_obj.get##internal_name(); } \
joeverbout 0:ea44dc9ed014 178 void set##name(w_type val) { internal_obj.set##internal_name(val); }
joeverbout 0:ea44dc9ed014 179
joeverbout 0:ea44dc9ed014 180 #define CV_IMPL_PROPERTY(type, name, member) CV_HELP_IMPL_PROPERTY(type, type, name, member)
joeverbout 0:ea44dc9ed014 181 #define CV_IMPL_PROPERTY_S(type, name, member) CV_HELP_IMPL_PROPERTY(type, const type &, name, member)
joeverbout 0:ea44dc9ed014 182
joeverbout 0:ea44dc9ed014 183 #define CV_WRAP_PROPERTY(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, type, name, internal_name, internal_obj)
joeverbout 0:ea44dc9ed014 184 #define CV_WRAP_PROPERTY_S(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, const type &, name, internal_name, internal_obj)
joeverbout 0:ea44dc9ed014 185
joeverbout 0:ea44dc9ed014 186 #define CV_WRAP_SAME_PROPERTY(type, name, internal_obj) CV_WRAP_PROPERTY(type, name, name, internal_obj)
joeverbout 0:ea44dc9ed014 187 #define CV_WRAP_SAME_PROPERTY_S(type, name, internal_obj) CV_WRAP_PROPERTY_S(type, name, name, internal_obj)
joeverbout 0:ea44dc9ed014 188
joeverbout 0:ea44dc9ed014 189 /****************************************************************************************\
joeverbout 0:ea44dc9ed014 190 * Structures and macros for integration with IPP *
joeverbout 0:ea44dc9ed014 191 \****************************************************************************************/
joeverbout 0:ea44dc9ed014 192
joeverbout 0:ea44dc9ed014 193 #ifdef HAVE_IPP
joeverbout 0:ea44dc9ed014 194 #include "ipp.h"
joeverbout 0:ea44dc9ed014 195
joeverbout 0:ea44dc9ed014 196 #ifndef IPP_VERSION_UPDATE // prior to 7.1
joeverbout 0:ea44dc9ed014 197 #define IPP_VERSION_UPDATE 0
joeverbout 0:ea44dc9ed014 198 #endif
joeverbout 0:ea44dc9ed014 199
joeverbout 0:ea44dc9ed014 200 #define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE)
joeverbout 0:ea44dc9ed014 201
joeverbout 0:ea44dc9ed014 202 // General define for ipp function disabling
joeverbout 0:ea44dc9ed014 203 #define IPP_DISABLE_BLOCK 0
joeverbout 0:ea44dc9ed014 204
joeverbout 0:ea44dc9ed014 205 #ifdef CV_MALLOC_ALIGN
joeverbout 0:ea44dc9ed014 206 #undef CV_MALLOC_ALIGN
joeverbout 0:ea44dc9ed014 207 #endif
joeverbout 0:ea44dc9ed014 208 #define CV_MALLOC_ALIGN 32 // required for AVX optimization
joeverbout 0:ea44dc9ed014 209
joeverbout 0:ea44dc9ed014 210 #define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__)
joeverbout 0:ea44dc9ed014 211
joeverbout 0:ea44dc9ed014 212 static inline IppiSize ippiSize(int width, int height)
joeverbout 0:ea44dc9ed014 213 {
joeverbout 0:ea44dc9ed014 214 IppiSize size = { width, height };
joeverbout 0:ea44dc9ed014 215 return size;
joeverbout 0:ea44dc9ed014 216 }
joeverbout 0:ea44dc9ed014 217
joeverbout 0:ea44dc9ed014 218 static inline IppiSize ippiSize(const cv::Size & _size)
joeverbout 0:ea44dc9ed014 219 {
joeverbout 0:ea44dc9ed014 220 IppiSize size = { _size.width, _size.height };
joeverbout 0:ea44dc9ed014 221 return size;
joeverbout 0:ea44dc9ed014 222 }
joeverbout 0:ea44dc9ed014 223
joeverbout 0:ea44dc9ed014 224 static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
joeverbout 0:ea44dc9ed014 225 {
joeverbout 0:ea44dc9ed014 226 return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
joeverbout 0:ea44dc9ed014 227 borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap :
joeverbout 0:ea44dc9ed014 228 borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
joeverbout 0:ea44dc9ed014 229 borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
joeverbout 0:ea44dc9ed014 230 borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1;
joeverbout 0:ea44dc9ed014 231 }
joeverbout 0:ea44dc9ed014 232
joeverbout 0:ea44dc9ed014 233 static inline IppDataType ippiGetDataType(int depth)
joeverbout 0:ea44dc9ed014 234 {
joeverbout 0:ea44dc9ed014 235 return depth == CV_8U ? ipp8u :
joeverbout 0:ea44dc9ed014 236 depth == CV_8S ? ipp8s :
joeverbout 0:ea44dc9ed014 237 depth == CV_16U ? ipp16u :
joeverbout 0:ea44dc9ed014 238 depth == CV_16S ? ipp16s :
joeverbout 0:ea44dc9ed014 239 depth == CV_32S ? ipp32s :
joeverbout 0:ea44dc9ed014 240 depth == CV_32F ? ipp32f :
joeverbout 0:ea44dc9ed014 241 depth == CV_64F ? ipp64f : (IppDataType)-1;
joeverbout 0:ea44dc9ed014 242 }
joeverbout 0:ea44dc9ed014 243
joeverbout 0:ea44dc9ed014 244 // IPP temporary buffer hepler
joeverbout 0:ea44dc9ed014 245 template<typename T>
joeverbout 0:ea44dc9ed014 246 class IppAutoBuffer
joeverbout 0:ea44dc9ed014 247 {
joeverbout 0:ea44dc9ed014 248 public:
joeverbout 0:ea44dc9ed014 249 IppAutoBuffer() { m_pBuffer = NULL; }
joeverbout 0:ea44dc9ed014 250 IppAutoBuffer(int size) { Alloc(size); }
joeverbout 0:ea44dc9ed014 251 ~IppAutoBuffer() { Release(); }
joeverbout 0:ea44dc9ed014 252 T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
joeverbout 0:ea44dc9ed014 253 void Release() { if(m_pBuffer) ippFree(m_pBuffer); }
joeverbout 0:ea44dc9ed014 254 inline operator T* () { return (T*)m_pBuffer;}
joeverbout 0:ea44dc9ed014 255 inline operator const T* () const { return (const T*)m_pBuffer;}
joeverbout 0:ea44dc9ed014 256 private:
joeverbout 0:ea44dc9ed014 257 // Disable copy operations
joeverbout 0:ea44dc9ed014 258 IppAutoBuffer(IppAutoBuffer &) {};
joeverbout 0:ea44dc9ed014 259 IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;};
joeverbout 0:ea44dc9ed014 260
joeverbout 0:ea44dc9ed014 261 T* m_pBuffer;
joeverbout 0:ea44dc9ed014 262 };
joeverbout 0:ea44dc9ed014 263
joeverbout 0:ea44dc9ed014 264 #else
joeverbout 0:ea44dc9ed014 265 #define IPP_VERSION_X100 0
joeverbout 0:ea44dc9ed014 266 #endif
joeverbout 0:ea44dc9ed014 267
joeverbout 0:ea44dc9ed014 268 // There shoud be no API difference in OpenCV between ICV and IPP since 9.0
joeverbout 0:ea44dc9ed014 269 #if (defined HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 900
joeverbout 0:ea44dc9ed014 270 #undef HAVE_IPP_ICV_ONLY
joeverbout 0:ea44dc9ed014 271 #endif
joeverbout 0:ea44dc9ed014 272
joeverbout 0:ea44dc9ed014 273 #ifdef HAVE_IPP_ICV_ONLY
joeverbout 0:ea44dc9ed014 274 #define HAVE_ICV 1
joeverbout 0:ea44dc9ed014 275 #else
joeverbout 0:ea44dc9ed014 276 #define HAVE_ICV 0
joeverbout 0:ea44dc9ed014 277 #endif
joeverbout 0:ea44dc9ed014 278
joeverbout 0:ea44dc9ed014 279 #if defined HAVE_IPP
joeverbout 0:ea44dc9ed014 280 #if IPP_VERSION_X100 >= 900
joeverbout 0:ea44dc9ed014 281 #define IPP_INITIALIZER(FEAT) \
joeverbout 0:ea44dc9ed014 282 { \
joeverbout 0:ea44dc9ed014 283 if(FEAT) \
joeverbout 0:ea44dc9ed014 284 ippSetCpuFeatures(FEAT); \
joeverbout 0:ea44dc9ed014 285 else \
joeverbout 0:ea44dc9ed014 286 ippInit(); \
joeverbout 0:ea44dc9ed014 287 }
joeverbout 0:ea44dc9ed014 288 #elif IPP_VERSION_X100 >= 800
joeverbout 0:ea44dc9ed014 289 #define IPP_INITIALIZER(FEAT) \
joeverbout 0:ea44dc9ed014 290 { \
joeverbout 0:ea44dc9ed014 291 ippInit(); \
joeverbout 0:ea44dc9ed014 292 }
joeverbout 0:ea44dc9ed014 293 #else
joeverbout 0:ea44dc9ed014 294 #define IPP_INITIALIZER(FEAT) \
joeverbout 0:ea44dc9ed014 295 { \
joeverbout 0:ea44dc9ed014 296 ippStaticInit(); \
joeverbout 0:ea44dc9ed014 297 }
joeverbout 0:ea44dc9ed014 298 #endif
joeverbout 0:ea44dc9ed014 299
joeverbout 0:ea44dc9ed014 300 #ifdef CVAPI_EXPORTS
joeverbout 0:ea44dc9ed014 301 #define IPP_INITIALIZER_AUTO \
joeverbout 0:ea44dc9ed014 302 struct __IppInitializer__ \
joeverbout 0:ea44dc9ed014 303 { \
joeverbout 0:ea44dc9ed014 304 __IppInitializer__() \
joeverbout 0:ea44dc9ed014 305 {IPP_INITIALIZER(cv::ipp::getIppFeatures())} \
joeverbout 0:ea44dc9ed014 306 }; \
joeverbout 0:ea44dc9ed014 307 static struct __IppInitializer__ __ipp_initializer__;
joeverbout 0:ea44dc9ed014 308 #else
joeverbout 0:ea44dc9ed014 309 #define IPP_INITIALIZER_AUTO
joeverbout 0:ea44dc9ed014 310 #endif
joeverbout 0:ea44dc9ed014 311 #else
joeverbout 0:ea44dc9ed014 312 #define IPP_INITIALIZER
joeverbout 0:ea44dc9ed014 313 #define IPP_INITIALIZER_AUTO
joeverbout 0:ea44dc9ed014 314 #endif
joeverbout 0:ea44dc9ed014 315
joeverbout 0:ea44dc9ed014 316 #define CV_IPP_CHECK_COND (cv::ipp::useIPP())
joeverbout 0:ea44dc9ed014 317 #define CV_IPP_CHECK() if(CV_IPP_CHECK_COND)
joeverbout 0:ea44dc9ed014 318
joeverbout 0:ea44dc9ed014 319 #ifdef HAVE_IPP
joeverbout 0:ea44dc9ed014 320
joeverbout 0:ea44dc9ed014 321 #ifdef CV_IPP_RUN_VERBOSE
joeverbout 0:ea44dc9ed014 322 #define CV_IPP_RUN_(condition, func, ...) \
joeverbout 0:ea44dc9ed014 323 { \
joeverbout 0:ea44dc9ed014 324 if (cv::ipp::useIPP() && (condition) && func) \
joeverbout 0:ea44dc9ed014 325 { \
joeverbout 0:ea44dc9ed014 326 printf("%s: IPP implementation is running\n", CV_Func); \
joeverbout 0:ea44dc9ed014 327 fflush(stdout); \
joeverbout 0:ea44dc9ed014 328 CV_IMPL_ADD(CV_IMPL_IPP); \
joeverbout 0:ea44dc9ed014 329 return __VA_ARGS__; \
joeverbout 0:ea44dc9ed014 330 } \
joeverbout 0:ea44dc9ed014 331 else \
joeverbout 0:ea44dc9ed014 332 { \
joeverbout 0:ea44dc9ed014 333 printf("%s: Plain implementation is running\n", CV_Func); \
joeverbout 0:ea44dc9ed014 334 fflush(stdout); \
joeverbout 0:ea44dc9ed014 335 } \
joeverbout 0:ea44dc9ed014 336 }
joeverbout 0:ea44dc9ed014 337 #elif defined CV_IPP_RUN_ASSERT
joeverbout 0:ea44dc9ed014 338 #define CV_IPP_RUN_(condition, func, ...) \
joeverbout 0:ea44dc9ed014 339 { \
joeverbout 0:ea44dc9ed014 340 if (cv::ipp::useIPP() && (condition)) \
joeverbout 0:ea44dc9ed014 341 { \
joeverbout 0:ea44dc9ed014 342 if(func) \
joeverbout 0:ea44dc9ed014 343 { \
joeverbout 0:ea44dc9ed014 344 CV_IMPL_ADD(CV_IMPL_IPP); \
joeverbout 0:ea44dc9ed014 345 } \
joeverbout 0:ea44dc9ed014 346 else \
joeverbout 0:ea44dc9ed014 347 { \
joeverbout 0:ea44dc9ed014 348 setIppErrorStatus(); \
joeverbout 0:ea44dc9ed014 349 CV_Error(cv::Error::StsAssert, #func); \
joeverbout 0:ea44dc9ed014 350 } \
joeverbout 0:ea44dc9ed014 351 return __VA_ARGS__; \
joeverbout 0:ea44dc9ed014 352 } \
joeverbout 0:ea44dc9ed014 353 }
joeverbout 0:ea44dc9ed014 354 #else
joeverbout 0:ea44dc9ed014 355 #define CV_IPP_RUN_(condition, func, ...) \
joeverbout 0:ea44dc9ed014 356 if (cv::ipp::useIPP() && (condition) && func) \
joeverbout 0:ea44dc9ed014 357 { \
joeverbout 0:ea44dc9ed014 358 CV_IMPL_ADD(CV_IMPL_IPP); \
joeverbout 0:ea44dc9ed014 359 return __VA_ARGS__; \
joeverbout 0:ea44dc9ed014 360 }
joeverbout 0:ea44dc9ed014 361 #endif
joeverbout 0:ea44dc9ed014 362
joeverbout 0:ea44dc9ed014 363 #else
joeverbout 0:ea44dc9ed014 364 #define CV_IPP_RUN_(condition, func, ...)
joeverbout 0:ea44dc9ed014 365 #endif
joeverbout 0:ea44dc9ed014 366
joeverbout 0:ea44dc9ed014 367 #define CV_IPP_RUN(condition, func, ...) CV_IPP_RUN_(condition, func, __VA_ARGS__)
joeverbout 0:ea44dc9ed014 368
joeverbout 0:ea44dc9ed014 369
joeverbout 0:ea44dc9ed014 370 #ifndef IPPI_CALL
joeverbout 0:ea44dc9ed014 371 # define IPPI_CALL(func) CV_Assert((func) >= 0)
joeverbout 0:ea44dc9ed014 372 #endif
joeverbout 0:ea44dc9ed014 373
joeverbout 0:ea44dc9ed014 374 /* IPP-compatible return codes */
joeverbout 0:ea44dc9ed014 375 typedef enum CvStatus
joeverbout 0:ea44dc9ed014 376 {
joeverbout 0:ea44dc9ed014 377 CV_BADMEMBLOCK_ERR = -113,
joeverbout 0:ea44dc9ed014 378 CV_INPLACE_NOT_SUPPORTED_ERR= -112,
joeverbout 0:ea44dc9ed014 379 CV_UNMATCHED_ROI_ERR = -111,
joeverbout 0:ea44dc9ed014 380 CV_NOTFOUND_ERR = -110,
joeverbout 0:ea44dc9ed014 381 CV_BADCONVERGENCE_ERR = -109,
joeverbout 0:ea44dc9ed014 382
joeverbout 0:ea44dc9ed014 383 CV_BADDEPTH_ERR = -107,
joeverbout 0:ea44dc9ed014 384 CV_BADROI_ERR = -106,
joeverbout 0:ea44dc9ed014 385 CV_BADHEADER_ERR = -105,
joeverbout 0:ea44dc9ed014 386 CV_UNMATCHED_FORMATS_ERR = -104,
joeverbout 0:ea44dc9ed014 387 CV_UNSUPPORTED_COI_ERR = -103,
joeverbout 0:ea44dc9ed014 388 CV_UNSUPPORTED_CHANNELS_ERR = -102,
joeverbout 0:ea44dc9ed014 389 CV_UNSUPPORTED_DEPTH_ERR = -101,
joeverbout 0:ea44dc9ed014 390 CV_UNSUPPORTED_FORMAT_ERR = -100,
joeverbout 0:ea44dc9ed014 391
joeverbout 0:ea44dc9ed014 392 CV_BADARG_ERR = -49, //ipp comp
joeverbout 0:ea44dc9ed014 393 CV_NOTDEFINED_ERR = -48, //ipp comp
joeverbout 0:ea44dc9ed014 394
joeverbout 0:ea44dc9ed014 395 CV_BADCHANNELS_ERR = -47, //ipp comp
joeverbout 0:ea44dc9ed014 396 CV_BADRANGE_ERR = -44, //ipp comp
joeverbout 0:ea44dc9ed014 397 CV_BADSTEP_ERR = -29, //ipp comp
joeverbout 0:ea44dc9ed014 398
joeverbout 0:ea44dc9ed014 399 CV_BADFLAG_ERR = -12,
joeverbout 0:ea44dc9ed014 400 CV_DIV_BY_ZERO_ERR = -11, //ipp comp
joeverbout 0:ea44dc9ed014 401 CV_BADCOEF_ERR = -10,
joeverbout 0:ea44dc9ed014 402
joeverbout 0:ea44dc9ed014 403 CV_BADFACTOR_ERR = -7,
joeverbout 0:ea44dc9ed014 404 CV_BADPOINT_ERR = -6,
joeverbout 0:ea44dc9ed014 405 CV_BADSCALE_ERR = -4,
joeverbout 0:ea44dc9ed014 406 CV_OUTOFMEM_ERR = -3,
joeverbout 0:ea44dc9ed014 407 CV_NULLPTR_ERR = -2,
joeverbout 0:ea44dc9ed014 408 CV_BADSIZE_ERR = -1,
joeverbout 0:ea44dc9ed014 409 CV_NO_ERR = 0,
joeverbout 0:ea44dc9ed014 410 CV_OK = CV_NO_ERR
joeverbout 0:ea44dc9ed014 411 }
joeverbout 0:ea44dc9ed014 412 CvStatus;
joeverbout 0:ea44dc9ed014 413
joeverbout 0:ea44dc9ed014 414 #ifdef HAVE_TEGRA_OPTIMIZATION
joeverbout 0:ea44dc9ed014 415 namespace tegra {
joeverbout 0:ea44dc9ed014 416
joeverbout 0:ea44dc9ed014 417 CV_EXPORTS bool useTegra();
joeverbout 0:ea44dc9ed014 418 CV_EXPORTS void setUseTegra(bool flag);
joeverbout 0:ea44dc9ed014 419
joeverbout 0:ea44dc9ed014 420 }
joeverbout 0:ea44dc9ed014 421 #endif
joeverbout 0:ea44dc9ed014 422
joeverbout 0:ea44dc9ed014 423 //! @endcond
joeverbout 0:ea44dc9ed014 424
joeverbout 0:ea44dc9ed014 425 #endif // __OPENCV_CORE_PRIVATE_HPP__
joeverbout 0:ea44dc9ed014 426