Joe Verbout
/
main
opencv on mbed
opencv2/core/ocl.hpp@0:ea44dc9ed014, 2016-03-31 (annotated)
- Committer:
- joeverbout
- Date:
- Thu Mar 31 21:16:38 2016 +0000
- Revision:
- 0:ea44dc9ed014
OpenCV on mbed attempt
Who changed what in which revision?
User | Revision | Line number | New 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) 2013, OpenCV Foundation, all rights reserved. |
joeverbout | 0:ea44dc9ed014 | 14 | // Third party copyrights are property of their respective owners. |
joeverbout | 0:ea44dc9ed014 | 15 | // |
joeverbout | 0:ea44dc9ed014 | 16 | // Redistribution and use in source and binary forms, with or without modification, |
joeverbout | 0:ea44dc9ed014 | 17 | // are permitted provided that the following conditions are met: |
joeverbout | 0:ea44dc9ed014 | 18 | // |
joeverbout | 0:ea44dc9ed014 | 19 | // * Redistribution's of source code must retain the above copyright notice, |
joeverbout | 0:ea44dc9ed014 | 20 | // this list of conditions and the following disclaimer. |
joeverbout | 0:ea44dc9ed014 | 21 | // |
joeverbout | 0:ea44dc9ed014 | 22 | // * Redistribution's in binary form must reproduce the above copyright notice, |
joeverbout | 0:ea44dc9ed014 | 23 | // this list of conditions and the following disclaimer in the documentation |
joeverbout | 0:ea44dc9ed014 | 24 | // and/or other materials provided with the distribution. |
joeverbout | 0:ea44dc9ed014 | 25 | // |
joeverbout | 0:ea44dc9ed014 | 26 | // * The name of the copyright holders may not be used to endorse or promote products |
joeverbout | 0:ea44dc9ed014 | 27 | // derived from this software without specific prior written permission. |
joeverbout | 0:ea44dc9ed014 | 28 | // |
joeverbout | 0:ea44dc9ed014 | 29 | // This software is provided by the copyright holders and contributors "as is" and |
joeverbout | 0:ea44dc9ed014 | 30 | // any express or implied warranties, including, but not limited to, the implied |
joeverbout | 0:ea44dc9ed014 | 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
joeverbout | 0:ea44dc9ed014 | 32 | // In no event shall the OpenCV Foundation or contributors be liable for any direct, |
joeverbout | 0:ea44dc9ed014 | 33 | // indirect, incidental, special, exemplary, or consequential damages |
joeverbout | 0:ea44dc9ed014 | 34 | // (including, but not limited to, procurement of substitute goods or services; |
joeverbout | 0:ea44dc9ed014 | 35 | // loss of use, data, or profits; or business interruption) however caused |
joeverbout | 0:ea44dc9ed014 | 36 | // and on any theory of liability, whether in contract, strict liability, |
joeverbout | 0:ea44dc9ed014 | 37 | // or tort (including negligence or otherwise) arising in any way out of |
joeverbout | 0:ea44dc9ed014 | 38 | // the use of this software, even if advised of the possibility of such damage. |
joeverbout | 0:ea44dc9ed014 | 39 | // |
joeverbout | 0:ea44dc9ed014 | 40 | //M*/ |
joeverbout | 0:ea44dc9ed014 | 41 | |
joeverbout | 0:ea44dc9ed014 | 42 | #ifndef __OPENCV_OPENCL_HPP__ |
joeverbout | 0:ea44dc9ed014 | 43 | #define __OPENCV_OPENCL_HPP__ |
joeverbout | 0:ea44dc9ed014 | 44 | |
joeverbout | 0:ea44dc9ed014 | 45 | #include "opencv2/core.hpp" |
joeverbout | 0:ea44dc9ed014 | 46 | |
joeverbout | 0:ea44dc9ed014 | 47 | namespace cv { namespace ocl { |
joeverbout | 0:ea44dc9ed014 | 48 | |
joeverbout | 0:ea44dc9ed014 | 49 | //! @addtogroup core_opencl |
joeverbout | 0:ea44dc9ed014 | 50 | //! @{ |
joeverbout | 0:ea44dc9ed014 | 51 | |
joeverbout | 0:ea44dc9ed014 | 52 | CV_EXPORTS_W bool haveOpenCL(); |
joeverbout | 0:ea44dc9ed014 | 53 | CV_EXPORTS_W bool useOpenCL(); |
joeverbout | 0:ea44dc9ed014 | 54 | CV_EXPORTS_W bool haveAmdBlas(); |
joeverbout | 0:ea44dc9ed014 | 55 | CV_EXPORTS_W bool haveAmdFft(); |
joeverbout | 0:ea44dc9ed014 | 56 | CV_EXPORTS_W void setUseOpenCL(bool flag); |
joeverbout | 0:ea44dc9ed014 | 57 | CV_EXPORTS_W void finish(); |
joeverbout | 0:ea44dc9ed014 | 58 | |
joeverbout | 0:ea44dc9ed014 | 59 | CV_EXPORTS bool haveSVM(); |
joeverbout | 0:ea44dc9ed014 | 60 | |
joeverbout | 0:ea44dc9ed014 | 61 | class CV_EXPORTS Context; |
joeverbout | 0:ea44dc9ed014 | 62 | class CV_EXPORTS Device; |
joeverbout | 0:ea44dc9ed014 | 63 | class CV_EXPORTS Kernel; |
joeverbout | 0:ea44dc9ed014 | 64 | class CV_EXPORTS Program; |
joeverbout | 0:ea44dc9ed014 | 65 | class CV_EXPORTS ProgramSource; |
joeverbout | 0:ea44dc9ed014 | 66 | class CV_EXPORTS Queue; |
joeverbout | 0:ea44dc9ed014 | 67 | class CV_EXPORTS PlatformInfo; |
joeverbout | 0:ea44dc9ed014 | 68 | class CV_EXPORTS Image2D; |
joeverbout | 0:ea44dc9ed014 | 69 | |
joeverbout | 0:ea44dc9ed014 | 70 | class CV_EXPORTS Device |
joeverbout | 0:ea44dc9ed014 | 71 | { |
joeverbout | 0:ea44dc9ed014 | 72 | public: |
joeverbout | 0:ea44dc9ed014 | 73 | Device(); |
joeverbout | 0:ea44dc9ed014 | 74 | explicit Device(void* d); |
joeverbout | 0:ea44dc9ed014 | 75 | Device(const Device& d); |
joeverbout | 0:ea44dc9ed014 | 76 | Device& operator = (const Device& d); |
joeverbout | 0:ea44dc9ed014 | 77 | ~Device(); |
joeverbout | 0:ea44dc9ed014 | 78 | |
joeverbout | 0:ea44dc9ed014 | 79 | void set(void* d); |
joeverbout | 0:ea44dc9ed014 | 80 | |
joeverbout | 0:ea44dc9ed014 | 81 | enum |
joeverbout | 0:ea44dc9ed014 | 82 | { |
joeverbout | 0:ea44dc9ed014 | 83 | TYPE_DEFAULT = (1 << 0), |
joeverbout | 0:ea44dc9ed014 | 84 | TYPE_CPU = (1 << 1), |
joeverbout | 0:ea44dc9ed014 | 85 | TYPE_GPU = (1 << 2), |
joeverbout | 0:ea44dc9ed014 | 86 | TYPE_ACCELERATOR = (1 << 3), |
joeverbout | 0:ea44dc9ed014 | 87 | TYPE_DGPU = TYPE_GPU + (1 << 16), |
joeverbout | 0:ea44dc9ed014 | 88 | TYPE_IGPU = TYPE_GPU + (1 << 17), |
joeverbout | 0:ea44dc9ed014 | 89 | TYPE_ALL = 0xFFFFFFFF |
joeverbout | 0:ea44dc9ed014 | 90 | }; |
joeverbout | 0:ea44dc9ed014 | 91 | |
joeverbout | 0:ea44dc9ed014 | 92 | String name() const; |
joeverbout | 0:ea44dc9ed014 | 93 | String extensions() const; |
joeverbout | 0:ea44dc9ed014 | 94 | String version() const; |
joeverbout | 0:ea44dc9ed014 | 95 | String vendorName() const; |
joeverbout | 0:ea44dc9ed014 | 96 | String OpenCL_C_Version() const; |
joeverbout | 0:ea44dc9ed014 | 97 | String OpenCLVersion() const; |
joeverbout | 0:ea44dc9ed014 | 98 | int deviceVersionMajor() const; |
joeverbout | 0:ea44dc9ed014 | 99 | int deviceVersionMinor() const; |
joeverbout | 0:ea44dc9ed014 | 100 | String driverVersion() const; |
joeverbout | 0:ea44dc9ed014 | 101 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 102 | |
joeverbout | 0:ea44dc9ed014 | 103 | int type() const; |
joeverbout | 0:ea44dc9ed014 | 104 | |
joeverbout | 0:ea44dc9ed014 | 105 | int addressBits() const; |
joeverbout | 0:ea44dc9ed014 | 106 | bool available() const; |
joeverbout | 0:ea44dc9ed014 | 107 | bool compilerAvailable() const; |
joeverbout | 0:ea44dc9ed014 | 108 | bool linkerAvailable() const; |
joeverbout | 0:ea44dc9ed014 | 109 | |
joeverbout | 0:ea44dc9ed014 | 110 | enum |
joeverbout | 0:ea44dc9ed014 | 111 | { |
joeverbout | 0:ea44dc9ed014 | 112 | FP_DENORM=(1 << 0), |
joeverbout | 0:ea44dc9ed014 | 113 | FP_INF_NAN=(1 << 1), |
joeverbout | 0:ea44dc9ed014 | 114 | FP_ROUND_TO_NEAREST=(1 << 2), |
joeverbout | 0:ea44dc9ed014 | 115 | FP_ROUND_TO_ZERO=(1 << 3), |
joeverbout | 0:ea44dc9ed014 | 116 | FP_ROUND_TO_INF=(1 << 4), |
joeverbout | 0:ea44dc9ed014 | 117 | FP_FMA=(1 << 5), |
joeverbout | 0:ea44dc9ed014 | 118 | FP_SOFT_FLOAT=(1 << 6), |
joeverbout | 0:ea44dc9ed014 | 119 | FP_CORRECTLY_ROUNDED_DIVIDE_SQRT=(1 << 7) |
joeverbout | 0:ea44dc9ed014 | 120 | }; |
joeverbout | 0:ea44dc9ed014 | 121 | int doubleFPConfig() const; |
joeverbout | 0:ea44dc9ed014 | 122 | int singleFPConfig() const; |
joeverbout | 0:ea44dc9ed014 | 123 | int halfFPConfig() const; |
joeverbout | 0:ea44dc9ed014 | 124 | |
joeverbout | 0:ea44dc9ed014 | 125 | bool endianLittle() const; |
joeverbout | 0:ea44dc9ed014 | 126 | bool errorCorrectionSupport() const; |
joeverbout | 0:ea44dc9ed014 | 127 | |
joeverbout | 0:ea44dc9ed014 | 128 | enum |
joeverbout | 0:ea44dc9ed014 | 129 | { |
joeverbout | 0:ea44dc9ed014 | 130 | EXEC_KERNEL=(1 << 0), |
joeverbout | 0:ea44dc9ed014 | 131 | EXEC_NATIVE_KERNEL=(1 << 1) |
joeverbout | 0:ea44dc9ed014 | 132 | }; |
joeverbout | 0:ea44dc9ed014 | 133 | int executionCapabilities() const; |
joeverbout | 0:ea44dc9ed014 | 134 | |
joeverbout | 0:ea44dc9ed014 | 135 | size_t globalMemCacheSize() const; |
joeverbout | 0:ea44dc9ed014 | 136 | |
joeverbout | 0:ea44dc9ed014 | 137 | enum |
joeverbout | 0:ea44dc9ed014 | 138 | { |
joeverbout | 0:ea44dc9ed014 | 139 | NO_CACHE=0, |
joeverbout | 0:ea44dc9ed014 | 140 | READ_ONLY_CACHE=1, |
joeverbout | 0:ea44dc9ed014 | 141 | READ_WRITE_CACHE=2 |
joeverbout | 0:ea44dc9ed014 | 142 | }; |
joeverbout | 0:ea44dc9ed014 | 143 | int globalMemCacheType() const; |
joeverbout | 0:ea44dc9ed014 | 144 | int globalMemCacheLineSize() const; |
joeverbout | 0:ea44dc9ed014 | 145 | size_t globalMemSize() const; |
joeverbout | 0:ea44dc9ed014 | 146 | |
joeverbout | 0:ea44dc9ed014 | 147 | size_t localMemSize() const; |
joeverbout | 0:ea44dc9ed014 | 148 | enum |
joeverbout | 0:ea44dc9ed014 | 149 | { |
joeverbout | 0:ea44dc9ed014 | 150 | NO_LOCAL_MEM=0, |
joeverbout | 0:ea44dc9ed014 | 151 | LOCAL_IS_LOCAL=1, |
joeverbout | 0:ea44dc9ed014 | 152 | LOCAL_IS_GLOBAL=2 |
joeverbout | 0:ea44dc9ed014 | 153 | }; |
joeverbout | 0:ea44dc9ed014 | 154 | int localMemType() const; |
joeverbout | 0:ea44dc9ed014 | 155 | bool hostUnifiedMemory() const; |
joeverbout | 0:ea44dc9ed014 | 156 | |
joeverbout | 0:ea44dc9ed014 | 157 | bool imageSupport() const; |
joeverbout | 0:ea44dc9ed014 | 158 | |
joeverbout | 0:ea44dc9ed014 | 159 | bool imageFromBufferSupport() const; |
joeverbout | 0:ea44dc9ed014 | 160 | uint imagePitchAlignment() const; |
joeverbout | 0:ea44dc9ed014 | 161 | uint imageBaseAddressAlignment() const; |
joeverbout | 0:ea44dc9ed014 | 162 | |
joeverbout | 0:ea44dc9ed014 | 163 | size_t image2DMaxWidth() const; |
joeverbout | 0:ea44dc9ed014 | 164 | size_t image2DMaxHeight() const; |
joeverbout | 0:ea44dc9ed014 | 165 | |
joeverbout | 0:ea44dc9ed014 | 166 | size_t image3DMaxWidth() const; |
joeverbout | 0:ea44dc9ed014 | 167 | size_t image3DMaxHeight() const; |
joeverbout | 0:ea44dc9ed014 | 168 | size_t image3DMaxDepth() const; |
joeverbout | 0:ea44dc9ed014 | 169 | |
joeverbout | 0:ea44dc9ed014 | 170 | size_t imageMaxBufferSize() const; |
joeverbout | 0:ea44dc9ed014 | 171 | size_t imageMaxArraySize() const; |
joeverbout | 0:ea44dc9ed014 | 172 | |
joeverbout | 0:ea44dc9ed014 | 173 | enum |
joeverbout | 0:ea44dc9ed014 | 174 | { |
joeverbout | 0:ea44dc9ed014 | 175 | UNKNOWN_VENDOR=0, |
joeverbout | 0:ea44dc9ed014 | 176 | VENDOR_AMD=1, |
joeverbout | 0:ea44dc9ed014 | 177 | VENDOR_INTEL=2, |
joeverbout | 0:ea44dc9ed014 | 178 | VENDOR_NVIDIA=3 |
joeverbout | 0:ea44dc9ed014 | 179 | }; |
joeverbout | 0:ea44dc9ed014 | 180 | int vendorID() const; |
joeverbout | 0:ea44dc9ed014 | 181 | // FIXIT |
joeverbout | 0:ea44dc9ed014 | 182 | // dev.isAMD() doesn't work for OpenCL CPU devices from AMD OpenCL platform. |
joeverbout | 0:ea44dc9ed014 | 183 | // This method should use platform name instead of vendor name. |
joeverbout | 0:ea44dc9ed014 | 184 | // After fix restore code in arithm.cpp: ocl_compare() |
joeverbout | 0:ea44dc9ed014 | 185 | inline bool isAMD() const { return vendorID() == VENDOR_AMD; } |
joeverbout | 0:ea44dc9ed014 | 186 | inline bool isIntel() const { return vendorID() == VENDOR_INTEL; } |
joeverbout | 0:ea44dc9ed014 | 187 | inline bool isNVidia() const { return vendorID() == VENDOR_NVIDIA; } |
joeverbout | 0:ea44dc9ed014 | 188 | |
joeverbout | 0:ea44dc9ed014 | 189 | int maxClockFrequency() const; |
joeverbout | 0:ea44dc9ed014 | 190 | int maxComputeUnits() const; |
joeverbout | 0:ea44dc9ed014 | 191 | int maxConstantArgs() const; |
joeverbout | 0:ea44dc9ed014 | 192 | size_t maxConstantBufferSize() const; |
joeverbout | 0:ea44dc9ed014 | 193 | |
joeverbout | 0:ea44dc9ed014 | 194 | size_t maxMemAllocSize() const; |
joeverbout | 0:ea44dc9ed014 | 195 | size_t maxParameterSize() const; |
joeverbout | 0:ea44dc9ed014 | 196 | |
joeverbout | 0:ea44dc9ed014 | 197 | int maxReadImageArgs() const; |
joeverbout | 0:ea44dc9ed014 | 198 | int maxWriteImageArgs() const; |
joeverbout | 0:ea44dc9ed014 | 199 | int maxSamplers() const; |
joeverbout | 0:ea44dc9ed014 | 200 | |
joeverbout | 0:ea44dc9ed014 | 201 | size_t maxWorkGroupSize() const; |
joeverbout | 0:ea44dc9ed014 | 202 | int maxWorkItemDims() const; |
joeverbout | 0:ea44dc9ed014 | 203 | void maxWorkItemSizes(size_t*) const; |
joeverbout | 0:ea44dc9ed014 | 204 | |
joeverbout | 0:ea44dc9ed014 | 205 | int memBaseAddrAlign() const; |
joeverbout | 0:ea44dc9ed014 | 206 | |
joeverbout | 0:ea44dc9ed014 | 207 | int nativeVectorWidthChar() const; |
joeverbout | 0:ea44dc9ed014 | 208 | int nativeVectorWidthShort() const; |
joeverbout | 0:ea44dc9ed014 | 209 | int nativeVectorWidthInt() const; |
joeverbout | 0:ea44dc9ed014 | 210 | int nativeVectorWidthLong() const; |
joeverbout | 0:ea44dc9ed014 | 211 | int nativeVectorWidthFloat() const; |
joeverbout | 0:ea44dc9ed014 | 212 | int nativeVectorWidthDouble() const; |
joeverbout | 0:ea44dc9ed014 | 213 | int nativeVectorWidthHalf() const; |
joeverbout | 0:ea44dc9ed014 | 214 | |
joeverbout | 0:ea44dc9ed014 | 215 | int preferredVectorWidthChar() const; |
joeverbout | 0:ea44dc9ed014 | 216 | int preferredVectorWidthShort() const; |
joeverbout | 0:ea44dc9ed014 | 217 | int preferredVectorWidthInt() const; |
joeverbout | 0:ea44dc9ed014 | 218 | int preferredVectorWidthLong() const; |
joeverbout | 0:ea44dc9ed014 | 219 | int preferredVectorWidthFloat() const; |
joeverbout | 0:ea44dc9ed014 | 220 | int preferredVectorWidthDouble() const; |
joeverbout | 0:ea44dc9ed014 | 221 | int preferredVectorWidthHalf() const; |
joeverbout | 0:ea44dc9ed014 | 222 | |
joeverbout | 0:ea44dc9ed014 | 223 | size_t printfBufferSize() const; |
joeverbout | 0:ea44dc9ed014 | 224 | size_t profilingTimerResolution() const; |
joeverbout | 0:ea44dc9ed014 | 225 | |
joeverbout | 0:ea44dc9ed014 | 226 | static const Device& getDefault(); |
joeverbout | 0:ea44dc9ed014 | 227 | |
joeverbout | 0:ea44dc9ed014 | 228 | protected: |
joeverbout | 0:ea44dc9ed014 | 229 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 230 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 231 | }; |
joeverbout | 0:ea44dc9ed014 | 232 | |
joeverbout | 0:ea44dc9ed014 | 233 | |
joeverbout | 0:ea44dc9ed014 | 234 | class CV_EXPORTS Context |
joeverbout | 0:ea44dc9ed014 | 235 | { |
joeverbout | 0:ea44dc9ed014 | 236 | public: |
joeverbout | 0:ea44dc9ed014 | 237 | Context(); |
joeverbout | 0:ea44dc9ed014 | 238 | explicit Context(int dtype); |
joeverbout | 0:ea44dc9ed014 | 239 | ~Context(); |
joeverbout | 0:ea44dc9ed014 | 240 | Context(const Context& c); |
joeverbout | 0:ea44dc9ed014 | 241 | Context& operator = (const Context& c); |
joeverbout | 0:ea44dc9ed014 | 242 | |
joeverbout | 0:ea44dc9ed014 | 243 | bool create(); |
joeverbout | 0:ea44dc9ed014 | 244 | bool create(int dtype); |
joeverbout | 0:ea44dc9ed014 | 245 | size_t ndevices() const; |
joeverbout | 0:ea44dc9ed014 | 246 | const Device& device(size_t idx) const; |
joeverbout | 0:ea44dc9ed014 | 247 | Program getProg(const ProgramSource& prog, |
joeverbout | 0:ea44dc9ed014 | 248 | const String& buildopt, String& errmsg); |
joeverbout | 0:ea44dc9ed014 | 249 | |
joeverbout | 0:ea44dc9ed014 | 250 | static Context& getDefault(bool initialize = true); |
joeverbout | 0:ea44dc9ed014 | 251 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 252 | |
joeverbout | 0:ea44dc9ed014 | 253 | friend void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); |
joeverbout | 0:ea44dc9ed014 | 254 | |
joeverbout | 0:ea44dc9ed014 | 255 | bool useSVM() const; |
joeverbout | 0:ea44dc9ed014 | 256 | void setUseSVM(bool enabled); |
joeverbout | 0:ea44dc9ed014 | 257 | |
joeverbout | 0:ea44dc9ed014 | 258 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 259 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 260 | }; |
joeverbout | 0:ea44dc9ed014 | 261 | |
joeverbout | 0:ea44dc9ed014 | 262 | class CV_EXPORTS Platform |
joeverbout | 0:ea44dc9ed014 | 263 | { |
joeverbout | 0:ea44dc9ed014 | 264 | public: |
joeverbout | 0:ea44dc9ed014 | 265 | Platform(); |
joeverbout | 0:ea44dc9ed014 | 266 | ~Platform(); |
joeverbout | 0:ea44dc9ed014 | 267 | Platform(const Platform& p); |
joeverbout | 0:ea44dc9ed014 | 268 | Platform& operator = (const Platform& p); |
joeverbout | 0:ea44dc9ed014 | 269 | |
joeverbout | 0:ea44dc9ed014 | 270 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 271 | static Platform& getDefault(); |
joeverbout | 0:ea44dc9ed014 | 272 | |
joeverbout | 0:ea44dc9ed014 | 273 | friend void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); |
joeverbout | 0:ea44dc9ed014 | 274 | protected: |
joeverbout | 0:ea44dc9ed014 | 275 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 276 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 277 | }; |
joeverbout | 0:ea44dc9ed014 | 278 | |
joeverbout | 0:ea44dc9ed014 | 279 | /* |
joeverbout | 0:ea44dc9ed014 | 280 | //! @brief Attaches OpenCL context to OpenCV |
joeverbout | 0:ea44dc9ed014 | 281 | // |
joeverbout | 0:ea44dc9ed014 | 282 | //! @note Note: |
joeverbout | 0:ea44dc9ed014 | 283 | // OpenCV will check if available OpenCL platform has platformName name, |
joeverbout | 0:ea44dc9ed014 | 284 | // then assign context to OpenCV and call clRetainContext function. |
joeverbout | 0:ea44dc9ed014 | 285 | // The deviceID device will be used as target device and new command queue |
joeverbout | 0:ea44dc9ed014 | 286 | // will be created. |
joeverbout | 0:ea44dc9ed014 | 287 | // |
joeverbout | 0:ea44dc9ed014 | 288 | // Params: |
joeverbout | 0:ea44dc9ed014 | 289 | //! @param platformName - name of OpenCL platform to attach, |
joeverbout | 0:ea44dc9ed014 | 290 | //! this string is used to check if platform is available |
joeverbout | 0:ea44dc9ed014 | 291 | //! to OpenCV at runtime |
joeverbout | 0:ea44dc9ed014 | 292 | //! @param platfromID - ID of platform attached context was created for |
joeverbout | 0:ea44dc9ed014 | 293 | //! @param context - OpenCL context to be attached to OpenCV |
joeverbout | 0:ea44dc9ed014 | 294 | //! @param deviceID - ID of device, must be created from attached context |
joeverbout | 0:ea44dc9ed014 | 295 | */ |
joeverbout | 0:ea44dc9ed014 | 296 | CV_EXPORTS void attachContext(const String& platformName, void* platformID, void* context, void* deviceID); |
joeverbout | 0:ea44dc9ed014 | 297 | |
joeverbout | 0:ea44dc9ed014 | 298 | /* |
joeverbout | 0:ea44dc9ed014 | 299 | //! @brief Convert OpenCL buffer to UMat |
joeverbout | 0:ea44dc9ed014 | 300 | // |
joeverbout | 0:ea44dc9ed014 | 301 | //! @note Note: |
joeverbout | 0:ea44dc9ed014 | 302 | // OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV. |
joeverbout | 0:ea44dc9ed014 | 303 | // Memory content is not copied from clBuffer to UMat. Instead, buffer handle assigned |
joeverbout | 0:ea44dc9ed014 | 304 | // to UMat and clRetainMemObject is called. |
joeverbout | 0:ea44dc9ed014 | 305 | // |
joeverbout | 0:ea44dc9ed014 | 306 | // Params: |
joeverbout | 0:ea44dc9ed014 | 307 | //! @param cl_mem_buffer - source clBuffer handle |
joeverbout | 0:ea44dc9ed014 | 308 | //! @param step - num of bytes in single row |
joeverbout | 0:ea44dc9ed014 | 309 | //! @param rows - number of rows |
joeverbout | 0:ea44dc9ed014 | 310 | //! @param cols - number of cols |
joeverbout | 0:ea44dc9ed014 | 311 | //! @param type - OpenCV type of image |
joeverbout | 0:ea44dc9ed014 | 312 | //! @param dst - destination UMat |
joeverbout | 0:ea44dc9ed014 | 313 | */ |
joeverbout | 0:ea44dc9ed014 | 314 | CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst); |
joeverbout | 0:ea44dc9ed014 | 315 | |
joeverbout | 0:ea44dc9ed014 | 316 | /* |
joeverbout | 0:ea44dc9ed014 | 317 | //! @brief Convert OpenCL image2d_t to UMat |
joeverbout | 0:ea44dc9ed014 | 318 | // |
joeverbout | 0:ea44dc9ed014 | 319 | //! @note Note: |
joeverbout | 0:ea44dc9ed014 | 320 | // OpenCL image2d_t (cl_mem_image), should be compatible with OpenCV |
joeverbout | 0:ea44dc9ed014 | 321 | // UMat formats. |
joeverbout | 0:ea44dc9ed014 | 322 | // Memory content is copied from image to UMat with |
joeverbout | 0:ea44dc9ed014 | 323 | // clEnqueueCopyImageToBuffer function. |
joeverbout | 0:ea44dc9ed014 | 324 | // |
joeverbout | 0:ea44dc9ed014 | 325 | // Params: |
joeverbout | 0:ea44dc9ed014 | 326 | //! @param cl_mem_image - source image2d_t handle |
joeverbout | 0:ea44dc9ed014 | 327 | //! @param dst - destination UMat |
joeverbout | 0:ea44dc9ed014 | 328 | */ |
joeverbout | 0:ea44dc9ed014 | 329 | CV_EXPORTS void convertFromImage(void* cl_mem_image, UMat& dst); |
joeverbout | 0:ea44dc9ed014 | 330 | |
joeverbout | 0:ea44dc9ed014 | 331 | // TODO Move to internal header |
joeverbout | 0:ea44dc9ed014 | 332 | void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); |
joeverbout | 0:ea44dc9ed014 | 333 | |
joeverbout | 0:ea44dc9ed014 | 334 | class CV_EXPORTS Queue |
joeverbout | 0:ea44dc9ed014 | 335 | { |
joeverbout | 0:ea44dc9ed014 | 336 | public: |
joeverbout | 0:ea44dc9ed014 | 337 | Queue(); |
joeverbout | 0:ea44dc9ed014 | 338 | explicit Queue(const Context& c, const Device& d=Device()); |
joeverbout | 0:ea44dc9ed014 | 339 | ~Queue(); |
joeverbout | 0:ea44dc9ed014 | 340 | Queue(const Queue& q); |
joeverbout | 0:ea44dc9ed014 | 341 | Queue& operator = (const Queue& q); |
joeverbout | 0:ea44dc9ed014 | 342 | |
joeverbout | 0:ea44dc9ed014 | 343 | bool create(const Context& c=Context(), const Device& d=Device()); |
joeverbout | 0:ea44dc9ed014 | 344 | void finish(); |
joeverbout | 0:ea44dc9ed014 | 345 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 346 | static Queue& getDefault(); |
joeverbout | 0:ea44dc9ed014 | 347 | |
joeverbout | 0:ea44dc9ed014 | 348 | protected: |
joeverbout | 0:ea44dc9ed014 | 349 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 350 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 351 | }; |
joeverbout | 0:ea44dc9ed014 | 352 | |
joeverbout | 0:ea44dc9ed014 | 353 | |
joeverbout | 0:ea44dc9ed014 | 354 | class CV_EXPORTS KernelArg |
joeverbout | 0:ea44dc9ed014 | 355 | { |
joeverbout | 0:ea44dc9ed014 | 356 | public: |
joeverbout | 0:ea44dc9ed014 | 357 | enum { LOCAL=1, READ_ONLY=2, WRITE_ONLY=4, READ_WRITE=6, CONSTANT=8, PTR_ONLY = 16, NO_SIZE=256 }; |
joeverbout | 0:ea44dc9ed014 | 358 | KernelArg(int _flags, UMat* _m, int wscale=1, int iwscale=1, const void* _obj=0, size_t _sz=0); |
joeverbout | 0:ea44dc9ed014 | 359 | KernelArg(); |
joeverbout | 0:ea44dc9ed014 | 360 | |
joeverbout | 0:ea44dc9ed014 | 361 | static KernelArg Local() { return KernelArg(LOCAL, 0); } |
joeverbout | 0:ea44dc9ed014 | 362 | static KernelArg PtrWriteOnly(const UMat& m) |
joeverbout | 0:ea44dc9ed014 | 363 | { return KernelArg(PTR_ONLY+WRITE_ONLY, (UMat*)&m); } |
joeverbout | 0:ea44dc9ed014 | 364 | static KernelArg PtrReadOnly(const UMat& m) |
joeverbout | 0:ea44dc9ed014 | 365 | { return KernelArg(PTR_ONLY+READ_ONLY, (UMat*)&m); } |
joeverbout | 0:ea44dc9ed014 | 366 | static KernelArg PtrReadWrite(const UMat& m) |
joeverbout | 0:ea44dc9ed014 | 367 | { return KernelArg(PTR_ONLY+READ_WRITE, (UMat*)&m); } |
joeverbout | 0:ea44dc9ed014 | 368 | static KernelArg ReadWrite(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 369 | { return KernelArg(READ_WRITE, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 370 | static KernelArg ReadWriteNoSize(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 371 | { return KernelArg(READ_WRITE+NO_SIZE, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 372 | static KernelArg ReadOnly(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 373 | { return KernelArg(READ_ONLY, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 374 | static KernelArg WriteOnly(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 375 | { return KernelArg(WRITE_ONLY, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 376 | static KernelArg ReadOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 377 | { return KernelArg(READ_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 378 | static KernelArg WriteOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) |
joeverbout | 0:ea44dc9ed014 | 379 | { return KernelArg(WRITE_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } |
joeverbout | 0:ea44dc9ed014 | 380 | static KernelArg Constant(const Mat& m); |
joeverbout | 0:ea44dc9ed014 | 381 | template<typename _Tp> static KernelArg Constant(const _Tp* arr, size_t n) |
joeverbout | 0:ea44dc9ed014 | 382 | { return KernelArg(CONSTANT, 0, 1, 1, (void*)arr, n); } |
joeverbout | 0:ea44dc9ed014 | 383 | |
joeverbout | 0:ea44dc9ed014 | 384 | int flags; |
joeverbout | 0:ea44dc9ed014 | 385 | UMat* m; |
joeverbout | 0:ea44dc9ed014 | 386 | const void* obj; |
joeverbout | 0:ea44dc9ed014 | 387 | size_t sz; |
joeverbout | 0:ea44dc9ed014 | 388 | int wscale, iwscale; |
joeverbout | 0:ea44dc9ed014 | 389 | }; |
joeverbout | 0:ea44dc9ed014 | 390 | |
joeverbout | 0:ea44dc9ed014 | 391 | |
joeverbout | 0:ea44dc9ed014 | 392 | class CV_EXPORTS Kernel |
joeverbout | 0:ea44dc9ed014 | 393 | { |
joeverbout | 0:ea44dc9ed014 | 394 | public: |
joeverbout | 0:ea44dc9ed014 | 395 | Kernel(); |
joeverbout | 0:ea44dc9ed014 | 396 | Kernel(const char* kname, const Program& prog); |
joeverbout | 0:ea44dc9ed014 | 397 | Kernel(const char* kname, const ProgramSource& prog, |
joeverbout | 0:ea44dc9ed014 | 398 | const String& buildopts = String(), String* errmsg=0); |
joeverbout | 0:ea44dc9ed014 | 399 | ~Kernel(); |
joeverbout | 0:ea44dc9ed014 | 400 | Kernel(const Kernel& k); |
joeverbout | 0:ea44dc9ed014 | 401 | Kernel& operator = (const Kernel& k); |
joeverbout | 0:ea44dc9ed014 | 402 | |
joeverbout | 0:ea44dc9ed014 | 403 | bool empty() const; |
joeverbout | 0:ea44dc9ed014 | 404 | bool create(const char* kname, const Program& prog); |
joeverbout | 0:ea44dc9ed014 | 405 | bool create(const char* kname, const ProgramSource& prog, |
joeverbout | 0:ea44dc9ed014 | 406 | const String& buildopts, String* errmsg=0); |
joeverbout | 0:ea44dc9ed014 | 407 | |
joeverbout | 0:ea44dc9ed014 | 408 | int set(int i, const void* value, size_t sz); |
joeverbout | 0:ea44dc9ed014 | 409 | int set(int i, const Image2D& image2D); |
joeverbout | 0:ea44dc9ed014 | 410 | int set(int i, const UMat& m); |
joeverbout | 0:ea44dc9ed014 | 411 | int set(int i, const KernelArg& arg); |
joeverbout | 0:ea44dc9ed014 | 412 | template<typename _Tp> int set(int i, const _Tp& value) |
joeverbout | 0:ea44dc9ed014 | 413 | { return set(i, &value, sizeof(value)); } |
joeverbout | 0:ea44dc9ed014 | 414 | |
joeverbout | 0:ea44dc9ed014 | 415 | template<typename _Tp0> |
joeverbout | 0:ea44dc9ed014 | 416 | Kernel& args(const _Tp0& a0) |
joeverbout | 0:ea44dc9ed014 | 417 | { |
joeverbout | 0:ea44dc9ed014 | 418 | set(0, a0); return *this; |
joeverbout | 0:ea44dc9ed014 | 419 | } |
joeverbout | 0:ea44dc9ed014 | 420 | |
joeverbout | 0:ea44dc9ed014 | 421 | template<typename _Tp0, typename _Tp1> |
joeverbout | 0:ea44dc9ed014 | 422 | Kernel& args(const _Tp0& a0, const _Tp1& a1) |
joeverbout | 0:ea44dc9ed014 | 423 | { |
joeverbout | 0:ea44dc9ed014 | 424 | int i = set(0, a0); set(i, a1); return *this; |
joeverbout | 0:ea44dc9ed014 | 425 | } |
joeverbout | 0:ea44dc9ed014 | 426 | |
joeverbout | 0:ea44dc9ed014 | 427 | template<typename _Tp0, typename _Tp1, typename _Tp2> |
joeverbout | 0:ea44dc9ed014 | 428 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2) |
joeverbout | 0:ea44dc9ed014 | 429 | { |
joeverbout | 0:ea44dc9ed014 | 430 | int i = set(0, a0); i = set(i, a1); set(i, a2); return *this; |
joeverbout | 0:ea44dc9ed014 | 431 | } |
joeverbout | 0:ea44dc9ed014 | 432 | |
joeverbout | 0:ea44dc9ed014 | 433 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3> |
joeverbout | 0:ea44dc9ed014 | 434 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3) |
joeverbout | 0:ea44dc9ed014 | 435 | { |
joeverbout | 0:ea44dc9ed014 | 436 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); return *this; |
joeverbout | 0:ea44dc9ed014 | 437 | } |
joeverbout | 0:ea44dc9ed014 | 438 | |
joeverbout | 0:ea44dc9ed014 | 439 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> |
joeverbout | 0:ea44dc9ed014 | 440 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, |
joeverbout | 0:ea44dc9ed014 | 441 | const _Tp3& a3, const _Tp4& a4) |
joeverbout | 0:ea44dc9ed014 | 442 | { |
joeverbout | 0:ea44dc9ed014 | 443 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); |
joeverbout | 0:ea44dc9ed014 | 444 | i = set(i, a3); set(i, a4); return *this; |
joeverbout | 0:ea44dc9ed014 | 445 | } |
joeverbout | 0:ea44dc9ed014 | 446 | |
joeverbout | 0:ea44dc9ed014 | 447 | template<typename _Tp0, typename _Tp1, typename _Tp2, |
joeverbout | 0:ea44dc9ed014 | 448 | typename _Tp3, typename _Tp4, typename _Tp5> |
joeverbout | 0:ea44dc9ed014 | 449 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, |
joeverbout | 0:ea44dc9ed014 | 450 | const _Tp3& a3, const _Tp4& a4, const _Tp5& a5) |
joeverbout | 0:ea44dc9ed014 | 451 | { |
joeverbout | 0:ea44dc9ed014 | 452 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); |
joeverbout | 0:ea44dc9ed014 | 453 | i = set(i, a3); i = set(i, a4); set(i, a5); return *this; |
joeverbout | 0:ea44dc9ed014 | 454 | } |
joeverbout | 0:ea44dc9ed014 | 455 | |
joeverbout | 0:ea44dc9ed014 | 456 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 457 | typename _Tp4, typename _Tp5, typename _Tp6> |
joeverbout | 0:ea44dc9ed014 | 458 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 459 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6) |
joeverbout | 0:ea44dc9ed014 | 460 | { |
joeverbout | 0:ea44dc9ed014 | 461 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); |
joeverbout | 0:ea44dc9ed014 | 462 | i = set(i, a4); i = set(i, a5); set(i, a6); return *this; |
joeverbout | 0:ea44dc9ed014 | 463 | } |
joeverbout | 0:ea44dc9ed014 | 464 | |
joeverbout | 0:ea44dc9ed014 | 465 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 466 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7> |
joeverbout | 0:ea44dc9ed014 | 467 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 468 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7) |
joeverbout | 0:ea44dc9ed014 | 469 | { |
joeverbout | 0:ea44dc9ed014 | 470 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); |
joeverbout | 0:ea44dc9ed014 | 471 | i = set(i, a4); i = set(i, a5); i = set(i, a6); set(i, a7); return *this; |
joeverbout | 0:ea44dc9ed014 | 472 | } |
joeverbout | 0:ea44dc9ed014 | 473 | |
joeverbout | 0:ea44dc9ed014 | 474 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, |
joeverbout | 0:ea44dc9ed014 | 475 | typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8> |
joeverbout | 0:ea44dc9ed014 | 476 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 477 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 478 | const _Tp8& a8) |
joeverbout | 0:ea44dc9ed014 | 479 | { |
joeverbout | 0:ea44dc9ed014 | 480 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); |
joeverbout | 0:ea44dc9ed014 | 481 | i = set(i, a5); i = set(i, a6); i = set(i, a7); set(i, a8); return *this; |
joeverbout | 0:ea44dc9ed014 | 482 | } |
joeverbout | 0:ea44dc9ed014 | 483 | |
joeverbout | 0:ea44dc9ed014 | 484 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4, |
joeverbout | 0:ea44dc9ed014 | 485 | typename _Tp5, typename _Tp6, typename _Tp7, typename _Tp8, typename _Tp9> |
joeverbout | 0:ea44dc9ed014 | 486 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 487 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 488 | const _Tp8& a8, const _Tp9& a9) |
joeverbout | 0:ea44dc9ed014 | 489 | { |
joeverbout | 0:ea44dc9ed014 | 490 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 491 | i = set(i, a6); i = set(i, a7); i = set(i, a8); set(i, a9); return *this; |
joeverbout | 0:ea44dc9ed014 | 492 | } |
joeverbout | 0:ea44dc9ed014 | 493 | |
joeverbout | 0:ea44dc9ed014 | 494 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 495 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 496 | typename _Tp8, typename _Tp9, typename _Tp10> |
joeverbout | 0:ea44dc9ed014 | 497 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 498 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 499 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10) |
joeverbout | 0:ea44dc9ed014 | 500 | { |
joeverbout | 0:ea44dc9ed014 | 501 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 502 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); set(i, a10); return *this; |
joeverbout | 0:ea44dc9ed014 | 503 | } |
joeverbout | 0:ea44dc9ed014 | 504 | |
joeverbout | 0:ea44dc9ed014 | 505 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 506 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 507 | typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11> |
joeverbout | 0:ea44dc9ed014 | 508 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 509 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 510 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10, const _Tp11& a11) |
joeverbout | 0:ea44dc9ed014 | 511 | { |
joeverbout | 0:ea44dc9ed014 | 512 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 513 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); set(i, a11); return *this; |
joeverbout | 0:ea44dc9ed014 | 514 | } |
joeverbout | 0:ea44dc9ed014 | 515 | |
joeverbout | 0:ea44dc9ed014 | 516 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 517 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 518 | typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12> |
joeverbout | 0:ea44dc9ed014 | 519 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 520 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 521 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10, const _Tp11& a11, |
joeverbout | 0:ea44dc9ed014 | 522 | const _Tp12& a12) |
joeverbout | 0:ea44dc9ed014 | 523 | { |
joeverbout | 0:ea44dc9ed014 | 524 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 525 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); |
joeverbout | 0:ea44dc9ed014 | 526 | set(i, a12); return *this; |
joeverbout | 0:ea44dc9ed014 | 527 | } |
joeverbout | 0:ea44dc9ed014 | 528 | |
joeverbout | 0:ea44dc9ed014 | 529 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 530 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 531 | typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, |
joeverbout | 0:ea44dc9ed014 | 532 | typename _Tp13> |
joeverbout | 0:ea44dc9ed014 | 533 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 534 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 535 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10, const _Tp11& a11, |
joeverbout | 0:ea44dc9ed014 | 536 | const _Tp12& a12, const _Tp13& a13) |
joeverbout | 0:ea44dc9ed014 | 537 | { |
joeverbout | 0:ea44dc9ed014 | 538 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 539 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); |
joeverbout | 0:ea44dc9ed014 | 540 | i = set(i, a12); set(i, a13); return *this; |
joeverbout | 0:ea44dc9ed014 | 541 | } |
joeverbout | 0:ea44dc9ed014 | 542 | |
joeverbout | 0:ea44dc9ed014 | 543 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 544 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 545 | typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, |
joeverbout | 0:ea44dc9ed014 | 546 | typename _Tp13, typename _Tp14> |
joeverbout | 0:ea44dc9ed014 | 547 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 548 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 549 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10, const _Tp11& a11, |
joeverbout | 0:ea44dc9ed014 | 550 | const _Tp12& a12, const _Tp13& a13, const _Tp14& a14) |
joeverbout | 0:ea44dc9ed014 | 551 | { |
joeverbout | 0:ea44dc9ed014 | 552 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 553 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); |
joeverbout | 0:ea44dc9ed014 | 554 | i = set(i, a12); i = set(i, a13); set(i, a14); return *this; |
joeverbout | 0:ea44dc9ed014 | 555 | } |
joeverbout | 0:ea44dc9ed014 | 556 | |
joeverbout | 0:ea44dc9ed014 | 557 | template<typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3, |
joeverbout | 0:ea44dc9ed014 | 558 | typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7, |
joeverbout | 0:ea44dc9ed014 | 559 | typename _Tp8, typename _Tp9, typename _Tp10, typename _Tp11, typename _Tp12, |
joeverbout | 0:ea44dc9ed014 | 560 | typename _Tp13, typename _Tp14, typename _Tp15> |
joeverbout | 0:ea44dc9ed014 | 561 | Kernel& args(const _Tp0& a0, const _Tp1& a1, const _Tp2& a2, const _Tp3& a3, |
joeverbout | 0:ea44dc9ed014 | 562 | const _Tp4& a4, const _Tp5& a5, const _Tp6& a6, const _Tp7& a7, |
joeverbout | 0:ea44dc9ed014 | 563 | const _Tp8& a8, const _Tp9& a9, const _Tp10& a10, const _Tp11& a11, |
joeverbout | 0:ea44dc9ed014 | 564 | const _Tp12& a12, const _Tp13& a13, const _Tp14& a14, const _Tp15& a15) |
joeverbout | 0:ea44dc9ed014 | 565 | { |
joeverbout | 0:ea44dc9ed014 | 566 | int i = set(0, a0); i = set(i, a1); i = set(i, a2); i = set(i, a3); i = set(i, a4); i = set(i, a5); |
joeverbout | 0:ea44dc9ed014 | 567 | i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11); |
joeverbout | 0:ea44dc9ed014 | 568 | i = set(i, a12); i = set(i, a13); i = set(i, a14); set(i, a15); return *this; |
joeverbout | 0:ea44dc9ed014 | 569 | } |
joeverbout | 0:ea44dc9ed014 | 570 | |
joeverbout | 0:ea44dc9ed014 | 571 | bool run(int dims, size_t globalsize[], |
joeverbout | 0:ea44dc9ed014 | 572 | size_t localsize[], bool sync, const Queue& q=Queue()); |
joeverbout | 0:ea44dc9ed014 | 573 | bool runTask(bool sync, const Queue& q=Queue()); |
joeverbout | 0:ea44dc9ed014 | 574 | |
joeverbout | 0:ea44dc9ed014 | 575 | size_t workGroupSize() const; |
joeverbout | 0:ea44dc9ed014 | 576 | size_t preferedWorkGroupSizeMultiple() const; |
joeverbout | 0:ea44dc9ed014 | 577 | bool compileWorkGroupSize(size_t wsz[]) const; |
joeverbout | 0:ea44dc9ed014 | 578 | size_t localMemSize() const; |
joeverbout | 0:ea44dc9ed014 | 579 | |
joeverbout | 0:ea44dc9ed014 | 580 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 581 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 582 | |
joeverbout | 0:ea44dc9ed014 | 583 | protected: |
joeverbout | 0:ea44dc9ed014 | 584 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 585 | }; |
joeverbout | 0:ea44dc9ed014 | 586 | |
joeverbout | 0:ea44dc9ed014 | 587 | class CV_EXPORTS Program |
joeverbout | 0:ea44dc9ed014 | 588 | { |
joeverbout | 0:ea44dc9ed014 | 589 | public: |
joeverbout | 0:ea44dc9ed014 | 590 | Program(); |
joeverbout | 0:ea44dc9ed014 | 591 | Program(const ProgramSource& src, |
joeverbout | 0:ea44dc9ed014 | 592 | const String& buildflags, String& errmsg); |
joeverbout | 0:ea44dc9ed014 | 593 | explicit Program(const String& buf); |
joeverbout | 0:ea44dc9ed014 | 594 | Program(const Program& prog); |
joeverbout | 0:ea44dc9ed014 | 595 | |
joeverbout | 0:ea44dc9ed014 | 596 | Program& operator = (const Program& prog); |
joeverbout | 0:ea44dc9ed014 | 597 | ~Program(); |
joeverbout | 0:ea44dc9ed014 | 598 | |
joeverbout | 0:ea44dc9ed014 | 599 | bool create(const ProgramSource& src, |
joeverbout | 0:ea44dc9ed014 | 600 | const String& buildflags, String& errmsg); |
joeverbout | 0:ea44dc9ed014 | 601 | bool read(const String& buf, const String& buildflags); |
joeverbout | 0:ea44dc9ed014 | 602 | bool write(String& buf) const; |
joeverbout | 0:ea44dc9ed014 | 603 | |
joeverbout | 0:ea44dc9ed014 | 604 | const ProgramSource& source() const; |
joeverbout | 0:ea44dc9ed014 | 605 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 606 | |
joeverbout | 0:ea44dc9ed014 | 607 | String getPrefix() const; |
joeverbout | 0:ea44dc9ed014 | 608 | static String getPrefix(const String& buildflags); |
joeverbout | 0:ea44dc9ed014 | 609 | |
joeverbout | 0:ea44dc9ed014 | 610 | protected: |
joeverbout | 0:ea44dc9ed014 | 611 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 612 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 613 | }; |
joeverbout | 0:ea44dc9ed014 | 614 | |
joeverbout | 0:ea44dc9ed014 | 615 | |
joeverbout | 0:ea44dc9ed014 | 616 | class CV_EXPORTS ProgramSource |
joeverbout | 0:ea44dc9ed014 | 617 | { |
joeverbout | 0:ea44dc9ed014 | 618 | public: |
joeverbout | 0:ea44dc9ed014 | 619 | typedef uint64 hash_t; |
joeverbout | 0:ea44dc9ed014 | 620 | |
joeverbout | 0:ea44dc9ed014 | 621 | ProgramSource(); |
joeverbout | 0:ea44dc9ed014 | 622 | explicit ProgramSource(const String& prog); |
joeverbout | 0:ea44dc9ed014 | 623 | explicit ProgramSource(const char* prog); |
joeverbout | 0:ea44dc9ed014 | 624 | ~ProgramSource(); |
joeverbout | 0:ea44dc9ed014 | 625 | ProgramSource(const ProgramSource& prog); |
joeverbout | 0:ea44dc9ed014 | 626 | ProgramSource& operator = (const ProgramSource& prog); |
joeverbout | 0:ea44dc9ed014 | 627 | |
joeverbout | 0:ea44dc9ed014 | 628 | const String& source() const; |
joeverbout | 0:ea44dc9ed014 | 629 | hash_t hash() const; |
joeverbout | 0:ea44dc9ed014 | 630 | |
joeverbout | 0:ea44dc9ed014 | 631 | protected: |
joeverbout | 0:ea44dc9ed014 | 632 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 633 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 634 | }; |
joeverbout | 0:ea44dc9ed014 | 635 | |
joeverbout | 0:ea44dc9ed014 | 636 | class CV_EXPORTS PlatformInfo |
joeverbout | 0:ea44dc9ed014 | 637 | { |
joeverbout | 0:ea44dc9ed014 | 638 | public: |
joeverbout | 0:ea44dc9ed014 | 639 | PlatformInfo(); |
joeverbout | 0:ea44dc9ed014 | 640 | explicit PlatformInfo(void* id); |
joeverbout | 0:ea44dc9ed014 | 641 | ~PlatformInfo(); |
joeverbout | 0:ea44dc9ed014 | 642 | |
joeverbout | 0:ea44dc9ed014 | 643 | PlatformInfo(const PlatformInfo& i); |
joeverbout | 0:ea44dc9ed014 | 644 | PlatformInfo& operator =(const PlatformInfo& i); |
joeverbout | 0:ea44dc9ed014 | 645 | |
joeverbout | 0:ea44dc9ed014 | 646 | String name() const; |
joeverbout | 0:ea44dc9ed014 | 647 | String vendor() const; |
joeverbout | 0:ea44dc9ed014 | 648 | String version() const; |
joeverbout | 0:ea44dc9ed014 | 649 | int deviceNumber() const; |
joeverbout | 0:ea44dc9ed014 | 650 | void getDevice(Device& device, int d) const; |
joeverbout | 0:ea44dc9ed014 | 651 | |
joeverbout | 0:ea44dc9ed014 | 652 | protected: |
joeverbout | 0:ea44dc9ed014 | 653 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 654 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 655 | }; |
joeverbout | 0:ea44dc9ed014 | 656 | |
joeverbout | 0:ea44dc9ed014 | 657 | CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf); |
joeverbout | 0:ea44dc9ed014 | 658 | CV_EXPORTS const char* typeToStr(int t); |
joeverbout | 0:ea44dc9ed014 | 659 | CV_EXPORTS const char* memopTypeToStr(int t); |
joeverbout | 0:ea44dc9ed014 | 660 | CV_EXPORTS const char* vecopTypeToStr(int t); |
joeverbout | 0:ea44dc9ed014 | 661 | CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL); |
joeverbout | 0:ea44dc9ed014 | 662 | CV_EXPORTS void getPlatfomsInfo(std::vector<PlatformInfo>& platform_info); |
joeverbout | 0:ea44dc9ed014 | 663 | |
joeverbout | 0:ea44dc9ed014 | 664 | |
joeverbout | 0:ea44dc9ed014 | 665 | enum OclVectorStrategy |
joeverbout | 0:ea44dc9ed014 | 666 | { |
joeverbout | 0:ea44dc9ed014 | 667 | // all matrices have its own vector width |
joeverbout | 0:ea44dc9ed014 | 668 | OCL_VECTOR_OWN = 0, |
joeverbout | 0:ea44dc9ed014 | 669 | // all matrices have maximal vector width among all matrices |
joeverbout | 0:ea44dc9ed014 | 670 | // (useful for cases when matrices have different data types) |
joeverbout | 0:ea44dc9ed014 | 671 | OCL_VECTOR_MAX = 1, |
joeverbout | 0:ea44dc9ed014 | 672 | |
joeverbout | 0:ea44dc9ed014 | 673 | // default strategy |
joeverbout | 0:ea44dc9ed014 | 674 | OCL_VECTOR_DEFAULT = OCL_VECTOR_OWN |
joeverbout | 0:ea44dc9ed014 | 675 | }; |
joeverbout | 0:ea44dc9ed014 | 676 | |
joeverbout | 0:ea44dc9ed014 | 677 | CV_EXPORTS int predictOptimalVectorWidth(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 678 | InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 679 | InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 680 | OclVectorStrategy strat = OCL_VECTOR_DEFAULT); |
joeverbout | 0:ea44dc9ed014 | 681 | |
joeverbout | 0:ea44dc9ed014 | 682 | CV_EXPORTS int checkOptimalVectorWidth(const int *vectorWidths, |
joeverbout | 0:ea44dc9ed014 | 683 | InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 684 | InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 685 | InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 686 | OclVectorStrategy strat = OCL_VECTOR_DEFAULT); |
joeverbout | 0:ea44dc9ed014 | 687 | |
joeverbout | 0:ea44dc9ed014 | 688 | // with OCL_VECTOR_MAX strategy |
joeverbout | 0:ea44dc9ed014 | 689 | CV_EXPORTS int predictOptimalVectorWidthMax(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 690 | InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), |
joeverbout | 0:ea44dc9ed014 | 691 | InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray()); |
joeverbout | 0:ea44dc9ed014 | 692 | |
joeverbout | 0:ea44dc9ed014 | 693 | CV_EXPORTS void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, InputArray _m); |
joeverbout | 0:ea44dc9ed014 | 694 | |
joeverbout | 0:ea44dc9ed014 | 695 | class CV_EXPORTS Image2D |
joeverbout | 0:ea44dc9ed014 | 696 | { |
joeverbout | 0:ea44dc9ed014 | 697 | public: |
joeverbout | 0:ea44dc9ed014 | 698 | Image2D(); |
joeverbout | 0:ea44dc9ed014 | 699 | |
joeverbout | 0:ea44dc9ed014 | 700 | // src: The UMat from which to get image properties and data |
joeverbout | 0:ea44dc9ed014 | 701 | // norm: Flag to enable the use of normalized channel data types |
joeverbout | 0:ea44dc9ed014 | 702 | // alias: Flag indicating that the image should alias the src UMat. |
joeverbout | 0:ea44dc9ed014 | 703 | // If true, changes to the image or src will be reflected in |
joeverbout | 0:ea44dc9ed014 | 704 | // both objects. |
joeverbout | 0:ea44dc9ed014 | 705 | explicit Image2D(const UMat &src, bool norm = false, bool alias = false); |
joeverbout | 0:ea44dc9ed014 | 706 | Image2D(const Image2D & i); |
joeverbout | 0:ea44dc9ed014 | 707 | ~Image2D(); |
joeverbout | 0:ea44dc9ed014 | 708 | |
joeverbout | 0:ea44dc9ed014 | 709 | Image2D & operator = (const Image2D & i); |
joeverbout | 0:ea44dc9ed014 | 710 | |
joeverbout | 0:ea44dc9ed014 | 711 | // Indicates if creating an aliased image should succeed. Depends on the |
joeverbout | 0:ea44dc9ed014 | 712 | // underlying platform and the dimensions of the UMat. |
joeverbout | 0:ea44dc9ed014 | 713 | static bool canCreateAlias(const UMat &u); |
joeverbout | 0:ea44dc9ed014 | 714 | |
joeverbout | 0:ea44dc9ed014 | 715 | // Indicates if the image format is supported. |
joeverbout | 0:ea44dc9ed014 | 716 | static bool isFormatSupported(int depth, int cn, bool norm); |
joeverbout | 0:ea44dc9ed014 | 717 | |
joeverbout | 0:ea44dc9ed014 | 718 | void* ptr() const; |
joeverbout | 0:ea44dc9ed014 | 719 | protected: |
joeverbout | 0:ea44dc9ed014 | 720 | struct Impl; |
joeverbout | 0:ea44dc9ed014 | 721 | Impl* p; |
joeverbout | 0:ea44dc9ed014 | 722 | }; |
joeverbout | 0:ea44dc9ed014 | 723 | |
joeverbout | 0:ea44dc9ed014 | 724 | |
joeverbout | 0:ea44dc9ed014 | 725 | CV_EXPORTS MatAllocator* getOpenCLAllocator(); |
joeverbout | 0:ea44dc9ed014 | 726 | |
joeverbout | 0:ea44dc9ed014 | 727 | |
joeverbout | 0:ea44dc9ed014 | 728 | #ifdef __OPENCV_BUILD |
joeverbout | 0:ea44dc9ed014 | 729 | namespace internal { |
joeverbout | 0:ea44dc9ed014 | 730 | |
joeverbout | 0:ea44dc9ed014 | 731 | CV_EXPORTS bool isPerformanceCheckBypassed(); |
joeverbout | 0:ea44dc9ed014 | 732 | #define OCL_PERFORMANCE_CHECK(condition) (cv::ocl::internal::isPerformanceCheckBypassed() || (condition)) |
joeverbout | 0:ea44dc9ed014 | 733 | |
joeverbout | 0:ea44dc9ed014 | 734 | CV_EXPORTS bool isCLBuffer(UMat& u); |
joeverbout | 0:ea44dc9ed014 | 735 | |
joeverbout | 0:ea44dc9ed014 | 736 | } // namespace internal |
joeverbout | 0:ea44dc9ed014 | 737 | #endif |
joeverbout | 0:ea44dc9ed014 | 738 | |
joeverbout | 0:ea44dc9ed014 | 739 | //! @} |
joeverbout | 0:ea44dc9ed014 | 740 | |
joeverbout | 0:ea44dc9ed014 | 741 | }} |
joeverbout | 0:ea44dc9ed014 | 742 | |
joeverbout | 0:ea44dc9ed014 | 743 | #endif |
joeverbout | 0:ea44dc9ed014 | 744 |