Cinder

  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

include/OpenCV/cvinternal.h

Go to the documentation of this file.
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 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 /* The header is for internal use and it is likely to change.
00044    It contains some macro definitions that are used in cxcore, cv, cvaux
00045    and, probably, other libraries. If you need some of this functionality,
00046    the safe way is to copy it into your code and rename the macros.
00047 */
00048 #ifndef __OPENCV_INTERNAL_H__
00049 #define __OPENCV_INTERNAL_H__
00050 
00051 #include <vector>
00052 
00053 #ifdef HAVE_CONFIG_H
00054     #include <cvconfig.h>
00055 #endif
00056 
00057 #if defined WIN32 || defined _WIN32
00058 #  ifndef WIN32
00059 #    define WIN32
00060 #  endif
00061 #  ifndef _WIN32
00062 #    define _WIN32
00063 #  endif
00064 #endif
00065 
00066 #if defined WIN32 || defined WINCE
00067 #ifndef _WIN32_WINNT         // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
00068 #define _WIN32_WINNT 0x0400  // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
00069 #endif
00070 #include <windows.h>
00071 #undef small
00072 #undef min
00073 #undef max
00074 #else
00075 #include <pthread.h>
00076 #include <sys/mman.h>
00077 #endif
00078 
00079 #ifdef __BORLANDC__
00080 #ifndef WIN32
00081     #define     WIN32
00082 #endif
00083 #ifndef _WIN32
00084     #define     _WIN32
00085 #endif
00086     #define     CV_DLL
00087     #undef      _CV_ALWAYS_PROFILE_
00088     #define     _CV_ALWAYS_NO_PROFILE_
00089 #endif
00090 
00091 #ifndef FALSE
00092 #define FALSE 0
00093 #endif
00094 #ifndef TRUE
00095 #define TRUE 1
00096 #endif
00097 
00098 #define __BEGIN__ __CV_BEGIN__
00099 #define __END__ __CV_END__
00100 #define EXIT __CV_EXIT__
00101 
00102 #ifdef HAVE_IPP
00103 #include "ipp.h"
00104 
00105 CV_INLINE IppiSize ippiSize(int width, int height)
00106 {
00107     IppiSize size = { width, height };
00108     return size;
00109 }
00110 #endif
00111 
00112 #if defined __SSE2__ || _MSC_VER >= 1300
00113 #include "emmintrin.h"
00114 #define CV_SSE 1
00115 #define CV_SSE2 1
00116 #if defined __SSE3__ || _MSC_VER >= 1400
00117 #include "pmmintrin.h"
00118 #define CV_SSE3 1
00119 #endif
00120 #else
00121 #define CV_SSE 0
00122 #define CV_SSE2 0
00123 #define CV_SSE3 0
00124 #endif
00125 
00126 #ifndef IPPI_CALL
00127 #define IPPI_CALL(func) CV_Assert((func) >= 0)
00128 #endif
00129 
00130 #ifdef HAVE_TBB
00131     #include "tbb/tbb_stddef.h"
00132     #if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
00133         #include "tbb/tbb.h"
00134         #undef min
00135         #undef max
00136     #else
00137         #undef HAVE_TBB
00138     #endif
00139 #endif
00140 
00141 #ifdef HAVE_TBB
00142     namespace cv
00143     {
00144         typedef tbb::blocked_range<int> BlockedRange;
00145         
00146         template<typename Body> static inline
00147         void parallel_for( const BlockedRange& range, const Body& body )
00148         {
00149             tbb::parallel_for(range, body);
00150         }
00151         
00152         template<typename Iterator, typename Body> static inline
00153         void parallel_do( Iterator first, Iterator last, const Body& body )
00154         {
00155             tbb::parallel_do(first, last, body);
00156         }
00157         
00158         typedef tbb::split Split;
00159         
00160         template<typename Body> static inline
00161         void parallel_reduce( const BlockedRange& range, Body& body )
00162         {
00163             tbb::parallel_reduce(range, body);
00164         }
00165         
00166         typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
00167     }
00168 #else
00169     namespace cv
00170     {
00171         class BlockedRange
00172         {
00173         public:
00174             BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
00175             BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
00176             int begin() const { return _begin; }
00177             int end() const { return _end; }
00178             int grainsize() const { return _grainsize; }
00179             
00180         protected:
00181             int _begin, _end, _grainsize;
00182         };
00183 
00184         template<typename Body> static inline
00185         void parallel_for( const BlockedRange& range, const Body& body )
00186         {
00187             body(range);
00188         }
00189         
00190         template<typename Iterator, typename Body> static inline
00191         void parallel_do( Iterator first, Iterator last, const Body& body )
00192         {
00193             for( ; first != last; ++first )
00194                 body(*first);
00195         }
00196         
00197         class Split {};
00198         
00199         template<typename Body> static inline
00200         void parallel_reduce( const BlockedRange& range, Body& body )
00201         {
00202             body(range);
00203         }
00204         
00205         typedef std::vector<Rect> ConcurrentRectVector;
00206     }
00207 #endif
00208 
00209 #endif