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 // Copyright (C) 2015, Itseez Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 17 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 18 //
joeverbout 0:ea44dc9ed014 19 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 20 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 21 //
joeverbout 0:ea44dc9ed014 22 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 23 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 24 //
joeverbout 0:ea44dc9ed014 25 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 26 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 27 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 28 //
joeverbout 0:ea44dc9ed014 29 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 30 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 31 //
joeverbout 0:ea44dc9ed014 32 // This software is provided by the copyright holders and contributors "as is" and
joeverbout 0:ea44dc9ed014 33 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 35 // In no event shall the Intel Corporation or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 36 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 37 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 38 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 39 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 40 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 41 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 42 //
joeverbout 0:ea44dc9ed014 43 //M*/
joeverbout 0:ea44dc9ed014 44
joeverbout 0:ea44dc9ed014 45 #ifndef __OPENCV_HAL_INTRIN_HPP__
joeverbout 0:ea44dc9ed014 46 #define __OPENCV_HAL_INTRIN_HPP__
joeverbout 0:ea44dc9ed014 47
joeverbout 0:ea44dc9ed014 48 #include <cmath>
joeverbout 0:ea44dc9ed014 49 #include <float.h>
joeverbout 0:ea44dc9ed014 50 #include <stdlib.h>
joeverbout 0:ea44dc9ed014 51 #include "opencv2/core/cvdef.h"
joeverbout 0:ea44dc9ed014 52
joeverbout 0:ea44dc9ed014 53 #define OPENCV_HAL_ADD(a, b) ((a) + (b))
joeverbout 0:ea44dc9ed014 54 #define OPENCV_HAL_AND(a, b) ((a) & (b))
joeverbout 0:ea44dc9ed014 55 #define OPENCV_HAL_NOP(a) (a)
joeverbout 0:ea44dc9ed014 56 #define OPENCV_HAL_1ST(a, b) (a)
joeverbout 0:ea44dc9ed014 57
joeverbout 0:ea44dc9ed014 58 // unlike HAL API, which is in cv::hal,
joeverbout 0:ea44dc9ed014 59 // we put intrinsics into cv namespace to make its
joeverbout 0:ea44dc9ed014 60 // access from within opencv code more accessible
joeverbout 0:ea44dc9ed014 61 namespace cv {
joeverbout 0:ea44dc9ed014 62
joeverbout 0:ea44dc9ed014 63 //! @addtogroup core_hal_intrin
joeverbout 0:ea44dc9ed014 64 //! @{
joeverbout 0:ea44dc9ed014 65
joeverbout 0:ea44dc9ed014 66 //! @cond IGNORED
joeverbout 0:ea44dc9ed014 67 template<typename _Tp> struct V_TypeTraits
joeverbout 0:ea44dc9ed014 68 {
joeverbout 0:ea44dc9ed014 69 typedef _Tp int_type;
joeverbout 0:ea44dc9ed014 70 typedef _Tp uint_type;
joeverbout 0:ea44dc9ed014 71 typedef _Tp abs_type;
joeverbout 0:ea44dc9ed014 72 typedef _Tp sum_type;
joeverbout 0:ea44dc9ed014 73
joeverbout 0:ea44dc9ed014 74 enum { delta = 0, shift = 0 };
joeverbout 0:ea44dc9ed014 75
joeverbout 0:ea44dc9ed014 76 static int_type reinterpret_int(_Tp x) { return x; }
joeverbout 0:ea44dc9ed014 77 static uint_type reinterpet_uint(_Tp x) { return x; }
joeverbout 0:ea44dc9ed014 78 static _Tp reinterpret_from_int(int_type x) { return (_Tp)x; }
joeverbout 0:ea44dc9ed014 79 };
joeverbout 0:ea44dc9ed014 80
joeverbout 0:ea44dc9ed014 81 template<> struct V_TypeTraits<uchar>
joeverbout 0:ea44dc9ed014 82 {
joeverbout 0:ea44dc9ed014 83 typedef uchar value_type;
joeverbout 0:ea44dc9ed014 84 typedef schar int_type;
joeverbout 0:ea44dc9ed014 85 typedef uchar uint_type;
joeverbout 0:ea44dc9ed014 86 typedef uchar abs_type;
joeverbout 0:ea44dc9ed014 87 typedef int sum_type;
joeverbout 0:ea44dc9ed014 88
joeverbout 0:ea44dc9ed014 89 typedef ushort w_type;
joeverbout 0:ea44dc9ed014 90 typedef unsigned q_type;
joeverbout 0:ea44dc9ed014 91
joeverbout 0:ea44dc9ed014 92 enum { delta = 128, shift = 8 };
joeverbout 0:ea44dc9ed014 93
joeverbout 0:ea44dc9ed014 94 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 95 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 96 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 97 };
joeverbout 0:ea44dc9ed014 98
joeverbout 0:ea44dc9ed014 99 template<> struct V_TypeTraits<schar>
joeverbout 0:ea44dc9ed014 100 {
joeverbout 0:ea44dc9ed014 101 typedef schar value_type;
joeverbout 0:ea44dc9ed014 102 typedef schar int_type;
joeverbout 0:ea44dc9ed014 103 typedef uchar uint_type;
joeverbout 0:ea44dc9ed014 104 typedef uchar abs_type;
joeverbout 0:ea44dc9ed014 105 typedef int sum_type;
joeverbout 0:ea44dc9ed014 106
joeverbout 0:ea44dc9ed014 107 typedef short w_type;
joeverbout 0:ea44dc9ed014 108 typedef int q_type;
joeverbout 0:ea44dc9ed014 109
joeverbout 0:ea44dc9ed014 110 enum { delta = 128, shift = 8 };
joeverbout 0:ea44dc9ed014 111
joeverbout 0:ea44dc9ed014 112 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 113 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 114 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 115 };
joeverbout 0:ea44dc9ed014 116
joeverbout 0:ea44dc9ed014 117 template<> struct V_TypeTraits<ushort>
joeverbout 0:ea44dc9ed014 118 {
joeverbout 0:ea44dc9ed014 119 typedef ushort value_type;
joeverbout 0:ea44dc9ed014 120 typedef short int_type;
joeverbout 0:ea44dc9ed014 121 typedef ushort uint_type;
joeverbout 0:ea44dc9ed014 122 typedef ushort abs_type;
joeverbout 0:ea44dc9ed014 123 typedef int sum_type;
joeverbout 0:ea44dc9ed014 124
joeverbout 0:ea44dc9ed014 125 typedef unsigned w_type;
joeverbout 0:ea44dc9ed014 126 typedef uchar nu_type;
joeverbout 0:ea44dc9ed014 127
joeverbout 0:ea44dc9ed014 128 enum { delta = 32768, shift = 16 };
joeverbout 0:ea44dc9ed014 129
joeverbout 0:ea44dc9ed014 130 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 131 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 132 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 133 };
joeverbout 0:ea44dc9ed014 134
joeverbout 0:ea44dc9ed014 135 template<> struct V_TypeTraits<short>
joeverbout 0:ea44dc9ed014 136 {
joeverbout 0:ea44dc9ed014 137 typedef short value_type;
joeverbout 0:ea44dc9ed014 138 typedef short int_type;
joeverbout 0:ea44dc9ed014 139 typedef ushort uint_type;
joeverbout 0:ea44dc9ed014 140 typedef ushort abs_type;
joeverbout 0:ea44dc9ed014 141 typedef int sum_type;
joeverbout 0:ea44dc9ed014 142
joeverbout 0:ea44dc9ed014 143 typedef int w_type;
joeverbout 0:ea44dc9ed014 144 typedef uchar nu_type;
joeverbout 0:ea44dc9ed014 145 typedef schar n_type;
joeverbout 0:ea44dc9ed014 146
joeverbout 0:ea44dc9ed014 147 enum { delta = 128, shift = 8 };
joeverbout 0:ea44dc9ed014 148
joeverbout 0:ea44dc9ed014 149 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 150 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 151 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 152 };
joeverbout 0:ea44dc9ed014 153
joeverbout 0:ea44dc9ed014 154 template<> struct V_TypeTraits<unsigned>
joeverbout 0:ea44dc9ed014 155 {
joeverbout 0:ea44dc9ed014 156 typedef unsigned value_type;
joeverbout 0:ea44dc9ed014 157 typedef int int_type;
joeverbout 0:ea44dc9ed014 158 typedef unsigned uint_type;
joeverbout 0:ea44dc9ed014 159 typedef unsigned abs_type;
joeverbout 0:ea44dc9ed014 160 typedef unsigned sum_type;
joeverbout 0:ea44dc9ed014 161
joeverbout 0:ea44dc9ed014 162 typedef uint64 w_type;
joeverbout 0:ea44dc9ed014 163 typedef ushort nu_type;
joeverbout 0:ea44dc9ed014 164
joeverbout 0:ea44dc9ed014 165 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 166 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 167 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 168 };
joeverbout 0:ea44dc9ed014 169
joeverbout 0:ea44dc9ed014 170 template<> struct V_TypeTraits<int>
joeverbout 0:ea44dc9ed014 171 {
joeverbout 0:ea44dc9ed014 172 typedef int value_type;
joeverbout 0:ea44dc9ed014 173 typedef int int_type;
joeverbout 0:ea44dc9ed014 174 typedef unsigned uint_type;
joeverbout 0:ea44dc9ed014 175 typedef unsigned abs_type;
joeverbout 0:ea44dc9ed014 176 typedef int sum_type;
joeverbout 0:ea44dc9ed014 177
joeverbout 0:ea44dc9ed014 178 typedef int64 w_type;
joeverbout 0:ea44dc9ed014 179 typedef short n_type;
joeverbout 0:ea44dc9ed014 180 typedef ushort nu_type;
joeverbout 0:ea44dc9ed014 181
joeverbout 0:ea44dc9ed014 182 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 183 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 184 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 185 };
joeverbout 0:ea44dc9ed014 186
joeverbout 0:ea44dc9ed014 187 template<> struct V_TypeTraits<uint64>
joeverbout 0:ea44dc9ed014 188 {
joeverbout 0:ea44dc9ed014 189 typedef uint64 value_type;
joeverbout 0:ea44dc9ed014 190 typedef int64 int_type;
joeverbout 0:ea44dc9ed014 191 typedef uint64 uint_type;
joeverbout 0:ea44dc9ed014 192 typedef uint64 abs_type;
joeverbout 0:ea44dc9ed014 193 typedef uint64 sum_type;
joeverbout 0:ea44dc9ed014 194
joeverbout 0:ea44dc9ed014 195 typedef unsigned nu_type;
joeverbout 0:ea44dc9ed014 196
joeverbout 0:ea44dc9ed014 197 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 198 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 199 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 200 };
joeverbout 0:ea44dc9ed014 201
joeverbout 0:ea44dc9ed014 202 template<> struct V_TypeTraits<int64>
joeverbout 0:ea44dc9ed014 203 {
joeverbout 0:ea44dc9ed014 204 typedef int64 value_type;
joeverbout 0:ea44dc9ed014 205 typedef int64 int_type;
joeverbout 0:ea44dc9ed014 206 typedef uint64 uint_type;
joeverbout 0:ea44dc9ed014 207 typedef uint64 abs_type;
joeverbout 0:ea44dc9ed014 208 typedef int64 sum_type;
joeverbout 0:ea44dc9ed014 209
joeverbout 0:ea44dc9ed014 210 typedef int nu_type;
joeverbout 0:ea44dc9ed014 211
joeverbout 0:ea44dc9ed014 212 static int_type reinterpret_int(value_type x) { return (int_type)x; }
joeverbout 0:ea44dc9ed014 213 static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
joeverbout 0:ea44dc9ed014 214 static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
joeverbout 0:ea44dc9ed014 215 };
joeverbout 0:ea44dc9ed014 216
joeverbout 0:ea44dc9ed014 217
joeverbout 0:ea44dc9ed014 218 template<> struct V_TypeTraits<float>
joeverbout 0:ea44dc9ed014 219 {
joeverbout 0:ea44dc9ed014 220 typedef float value_type;
joeverbout 0:ea44dc9ed014 221 typedef int int_type;
joeverbout 0:ea44dc9ed014 222 typedef unsigned uint_type;
joeverbout 0:ea44dc9ed014 223 typedef float abs_type;
joeverbout 0:ea44dc9ed014 224 typedef float sum_type;
joeverbout 0:ea44dc9ed014 225
joeverbout 0:ea44dc9ed014 226 typedef double w_type;
joeverbout 0:ea44dc9ed014 227
joeverbout 0:ea44dc9ed014 228 static int_type reinterpret_int(value_type x)
joeverbout 0:ea44dc9ed014 229 {
joeverbout 0:ea44dc9ed014 230 Cv32suf u;
joeverbout 0:ea44dc9ed014 231 u.f = x;
joeverbout 0:ea44dc9ed014 232 return u.i;
joeverbout 0:ea44dc9ed014 233 }
joeverbout 0:ea44dc9ed014 234 static uint_type reinterpet_uint(value_type x)
joeverbout 0:ea44dc9ed014 235 {
joeverbout 0:ea44dc9ed014 236 Cv32suf u;
joeverbout 0:ea44dc9ed014 237 u.f = x;
joeverbout 0:ea44dc9ed014 238 return u.u;
joeverbout 0:ea44dc9ed014 239 }
joeverbout 0:ea44dc9ed014 240 static value_type reinterpret_from_int(int_type x)
joeverbout 0:ea44dc9ed014 241 {
joeverbout 0:ea44dc9ed014 242 Cv32suf u;
joeverbout 0:ea44dc9ed014 243 u.i = x;
joeverbout 0:ea44dc9ed014 244 return u.f;
joeverbout 0:ea44dc9ed014 245 }
joeverbout 0:ea44dc9ed014 246 };
joeverbout 0:ea44dc9ed014 247
joeverbout 0:ea44dc9ed014 248 template<> struct V_TypeTraits<double>
joeverbout 0:ea44dc9ed014 249 {
joeverbout 0:ea44dc9ed014 250 typedef double value_type;
joeverbout 0:ea44dc9ed014 251 typedef int64 int_type;
joeverbout 0:ea44dc9ed014 252 typedef uint64 uint_type;
joeverbout 0:ea44dc9ed014 253 typedef double abs_type;
joeverbout 0:ea44dc9ed014 254 typedef double sum_type;
joeverbout 0:ea44dc9ed014 255 static int_type reinterpret_int(value_type x)
joeverbout 0:ea44dc9ed014 256 {
joeverbout 0:ea44dc9ed014 257 Cv64suf u;
joeverbout 0:ea44dc9ed014 258 u.f = x;
joeverbout 0:ea44dc9ed014 259 return u.i;
joeverbout 0:ea44dc9ed014 260 }
joeverbout 0:ea44dc9ed014 261 static uint_type reinterpet_uint(value_type x)
joeverbout 0:ea44dc9ed014 262 {
joeverbout 0:ea44dc9ed014 263 Cv64suf u;
joeverbout 0:ea44dc9ed014 264 u.f = x;
joeverbout 0:ea44dc9ed014 265 return u.u;
joeverbout 0:ea44dc9ed014 266 }
joeverbout 0:ea44dc9ed014 267 static value_type reinterpret_from_int(int_type x)
joeverbout 0:ea44dc9ed014 268 {
joeverbout 0:ea44dc9ed014 269 Cv64suf u;
joeverbout 0:ea44dc9ed014 270 u.i = x;
joeverbout 0:ea44dc9ed014 271 return u.f;
joeverbout 0:ea44dc9ed014 272 }
joeverbout 0:ea44dc9ed014 273 };
joeverbout 0:ea44dc9ed014 274
joeverbout 0:ea44dc9ed014 275 template <typename T> struct V_SIMD128Traits
joeverbout 0:ea44dc9ed014 276 {
joeverbout 0:ea44dc9ed014 277 enum { nlanes = 16 / sizeof(T) };
joeverbout 0:ea44dc9ed014 278 };
joeverbout 0:ea44dc9ed014 279
joeverbout 0:ea44dc9ed014 280 //! @endcond
joeverbout 0:ea44dc9ed014 281
joeverbout 0:ea44dc9ed014 282 //! @}
joeverbout 0:ea44dc9ed014 283
joeverbout 0:ea44dc9ed014 284 }
joeverbout 0:ea44dc9ed014 285
joeverbout 0:ea44dc9ed014 286 #ifdef CV_DOXYGEN
joeverbout 0:ea44dc9ed014 287 # undef CV_SSE2
joeverbout 0:ea44dc9ed014 288 # undef CV_NEON
joeverbout 0:ea44dc9ed014 289 #endif
joeverbout 0:ea44dc9ed014 290
joeverbout 0:ea44dc9ed014 291 #if CV_SSE2
joeverbout 0:ea44dc9ed014 292
joeverbout 0:ea44dc9ed014 293 #include "opencv2/core/hal/intrin_sse.hpp"
joeverbout 0:ea44dc9ed014 294
joeverbout 0:ea44dc9ed014 295 #elif CV_NEON
joeverbout 0:ea44dc9ed014 296
joeverbout 0:ea44dc9ed014 297 #include "opencv2/core/hal/intrin_neon.hpp"
joeverbout 0:ea44dc9ed014 298
joeverbout 0:ea44dc9ed014 299 #else
joeverbout 0:ea44dc9ed014 300
joeverbout 0:ea44dc9ed014 301 #include "opencv2/core/hal/intrin_cpp.hpp"
joeverbout 0:ea44dc9ed014 302
joeverbout 0:ea44dc9ed014 303 #endif
joeverbout 0:ea44dc9ed014 304
joeverbout 0:ea44dc9ed014 305 //! @addtogroup core_hal_intrin
joeverbout 0:ea44dc9ed014 306 //! @{
joeverbout 0:ea44dc9ed014 307
joeverbout 0:ea44dc9ed014 308 #ifndef CV_SIMD128
joeverbout 0:ea44dc9ed014 309 //! Set to 1 if current compiler supports vector extensions (NEON or SSE is enabled)
joeverbout 0:ea44dc9ed014 310 #define CV_SIMD128 0
joeverbout 0:ea44dc9ed014 311 #endif
joeverbout 0:ea44dc9ed014 312
joeverbout 0:ea44dc9ed014 313 #ifndef CV_SIMD128_64F
joeverbout 0:ea44dc9ed014 314 //! Set to 1 if current intrinsics implementation supports 64-bit float vectors
joeverbout 0:ea44dc9ed014 315 #define CV_SIMD128_64F 0
joeverbout 0:ea44dc9ed014 316 #endif
joeverbout 0:ea44dc9ed014 317
joeverbout 0:ea44dc9ed014 318 //! @}
joeverbout 0:ea44dc9ed014 319
joeverbout 0:ea44dc9ed014 320 #endif
joeverbout 0:ea44dc9ed014 321