openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

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