endif()
set(the_description "Functionality with possible limitations on the use")
-ocv_add_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu)
+ocv_add_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu opencv_ocl)
ocv_module_include_directories()
if(HAVE_CUDA AND HAVE_opencv_gpu)
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_NONFREE_OCL_HPP__
+#define __OPENCV_NONFREE_OCL_HPP__
+
+#include "opencv2/ocl/ocl.hpp"
+
+namespace cv
+{
+ namespace ocl
+ {
+ //! Speeded up robust features, port from GPU module.
+ ////////////////////////////////// SURF //////////////////////////////////////////
+
+ class CV_EXPORTS SURF_OCL
+ {
+ public:
+ enum KeypointLayout
+ {
+ X_ROW = 0,
+ Y_ROW,
+ LAPLACIAN_ROW,
+ OCTAVE_ROW,
+ SIZE_ROW,
+ ANGLE_ROW,
+ HESSIAN_ROW,
+ ROWS_COUNT
+ };
+
+ //! the default constructor
+ SURF_OCL();
+ //! the full constructor taking all the necessary parameters
+ explicit SURF_OCL(double _hessianThreshold, int _nOctaves = 4,
+ int _nOctaveLayers = 2, bool _extended = false, float _keypointsRatio = 0.01f, bool _upright = false);
+
+ //! returns the descriptor size in float's (64 or 128)
+ int descriptorSize() const;
+ //! upload host keypoints to device memory
+ void uploadKeypoints(const vector<cv::KeyPoint> &keypoints, oclMat &keypointsocl);
+ //! download keypoints from device to host memory
+ void downloadKeypoints(const oclMat &keypointsocl, vector<KeyPoint> &keypoints);
+ //! download descriptors from device to host memory
+ void downloadDescriptors(const oclMat &descriptorsocl, vector<float> &descriptors);
+ //! finds the keypoints using fast hessian detector used in SURF
+ //! supports CV_8UC1 images
+ //! keypoints will have nFeature cols and 6 rows
+ //! keypoints.ptr<float>(X_ROW)[i] will contain x coordinate of i'th feature
+ //! keypoints.ptr<float>(Y_ROW)[i] will contain y coordinate of i'th feature
+ //! keypoints.ptr<float>(LAPLACIAN_ROW)[i] will contain laplacian sign of i'th feature
+ //! keypoints.ptr<float>(OCTAVE_ROW)[i] will contain octave of i'th feature
+ //! keypoints.ptr<float>(SIZE_ROW)[i] will contain size of i'th feature
+ //! keypoints.ptr<float>(ANGLE_ROW)[i] will contain orientation of i'th feature
+ //! keypoints.ptr<float>(HESSIAN_ROW)[i] will contain response of i'th feature
+ void operator()(const oclMat &img, const oclMat &mask, oclMat &keypoints);
+ //! finds the keypoints and computes their descriptors.
+ //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
+ void operator()(const oclMat &img, const oclMat &mask, oclMat &keypoints, oclMat &descriptors,
+ bool useProvidedKeypoints = false);
+ void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints);
+ void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints, oclMat &descriptors,
+ bool useProvidedKeypoints = false);
+ void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints, std::vector<float> &descriptors,
+ bool useProvidedKeypoints = false);
+
+ void releaseMemory();
+
+ // SURF parameters
+ float hessianThreshold;
+ int nOctaves;
+ int nOctaveLayers;
+ bool extended;
+ bool upright;
+ //! max keypoints = min(keypointsRatio * img.size().area(), 65535)
+ float keypointsRatio;
+ oclMat sum, mask1, maskSum, intBuffer;
+ oclMat det, trace;
+ oclMat maxPosBuffer;
+
+ };
+ }
+}
+
+#endif __OPENCV_NONFREE_OCL_HPP__
\ No newline at end of file
#endif
#endif
+#ifdef HAVE_OPENCV_OCL
+# include "opencv2/nonfree/ocl.hpp"
+# include "opencv2/ocl/private/util.hpp"
+#endif
+
#endif
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
-#include <iomanip>
#include "precomp.hpp"
-#include "mcwutil.hpp"
-//#include "opencv2/highgui/highgui.hpp"
+
+#ifdef HAVE_OPENCV_OCL
using namespace cv;
using namespace cv::ocl;
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
- extern const char *nonfree_surf;
+ extern const char *surf;
const char* noImage2dOption = "-D DISABLE_IMAGE2D";
int maxFeatures;
oclMat counters;
-
+
// texture buffers
cl_mem imgTex;
cl_mem sumTex;
divUp(max_samples_i, localThreads[1]) *localThreads[1] *(nOctaveLayers + 2),
1
};
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat &trace, oclMat &maxPosBuffer, oclMat &maxCounter, int counterOffset,
1
};
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMat &maxPosBuffer, int maxCounter,
size_t localThreads[3] = {3, 3, 3};
size_t globalThreads[3] = {maxCounter *localThreads[0], localThreads[1], 1};
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeatures)
size_t localThreads[3] = {32, 4, 1};
size_t globalThreads[3] = {nFeatures *localThreads[0], localThreads[1], 1};
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
void SURF_OCL_Invoker::icvSetUpright_gpu(const oclMat &keypoints, int nFeatures)
size_t localThreads[3] = {256, 1, 1};
size_t globalThreads[3] = {saturate_cast<size_t>(nFeatures), 1, 1};
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.step));
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
kernelName = "normalize_descriptors64";
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step));
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
else
{
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.step));
-
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
kernelName = "normalize_descriptors128";
args.clear();
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step));
-
- openCLExecuteKernelSURF(clCxt, &nonfree_surf, kernelName, globalThreads, localThreads, args, -1, -1);
+
+ openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
}
}
+
+#endif //HAVE_OPENCV_OCL
endif()
set(the_description "OpenCL-accelerated Computer Vision")
-ocv_define_module(ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video opencv_nonfree)
+ocv_define_module(ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
enum DevMemRW
{
- DEVICE_MEM_R_W = 0,
- DEVICE_MEM_R_ONLY,
+ DEVICE_MEM_R_W = 0,
+ DEVICE_MEM_R_ONLY,
DEVICE_MEM_W_ONLY
};
-
+
enum DevMemType
- {
- DEVICE_MEM_DEFAULT = 0,
+ {
+ DEVICE_MEM_DEFAULT = 0,
DEVICE_MEM_AHP, //alloc host pointer
DEVICE_MEM_UHP, //use host pointer
DEVICE_MEM_CHP, //copy host pointer
DEVICE_MEM_PM //persistent memory
};
- //Get the global device memory and read/write type
+ //Get the global device memory and read/write type
//return 1 if unified memory system supported, otherwise return 0
CV_EXPORTS int getDevMemType(DevMemRW& rw_type, DevMemType& mem_type);
- //Set the global device memory and read/write type,
+ //Set the global device memory and read/write type,
//the newly generated oclMat will all use this type
//return -1 if the target type is unsupported, otherwise return 0
- CV_EXPORTS int setDevMemType(DevMemRW rw_type = DEVICE_MEM_R_W, DevMemType mem_type = DEVICE_MEM_DEFAULT);
+ CV_EXPORTS int setDevMemType(DevMemRW rw_type = DEVICE_MEM_R_W, DevMemType mem_type = DEVICE_MEM_DEFAULT);
//this class contains ocl runtime information
class CV_EXPORTS Info
//////////////////////////////// OpenCL context ////////////////////////
//This is a global singleton class used to represent a OpenCL context.
- class Context
+ class CV_EXPORTS Context
{
protected:
Context();
};
-
- //! Speeded up robust features, port from GPU module.
- ////////////////////////////////// SURF //////////////////////////////////////////
-
- class CV_EXPORTS SURF_OCL
-
- {
-
- public:
-
- enum KeypointLayout
-
- {
-
- X_ROW = 0,
-
- Y_ROW,
-
- LAPLACIAN_ROW,
-
- OCTAVE_ROW,
-
- SIZE_ROW,
-
- ANGLE_ROW,
-
- HESSIAN_ROW,
-
- ROWS_COUNT
-
- };
-
-
-
- //! the default constructor
-
- SURF_OCL();
-
- //! the full constructor taking all the necessary parameters
-
- explicit SURF_OCL(double _hessianThreshold, int _nOctaves = 4,
-
- int _nOctaveLayers = 2, bool _extended = false, float _keypointsRatio = 0.01f, bool _upright = false);
-
-
-
- //! returns the descriptor size in float's (64 or 128)
-
- int descriptorSize() const;
-
-
-
- //! upload host keypoints to device memory
-
- void uploadKeypoints(const vector<cv::KeyPoint> &keypoints, oclMat &keypointsocl);
-
- //! download keypoints from device to host memory
-
- void downloadKeypoints(const oclMat &keypointsocl, vector<KeyPoint> &keypoints);
-
-
-
- //! download descriptors from device to host memory
-
- void downloadDescriptors(const oclMat &descriptorsocl, vector<float> &descriptors);
-
-
-
- //! finds the keypoints using fast hessian detector used in SURF
-
- //! supports CV_8UC1 images
-
- //! keypoints will have nFeature cols and 6 rows
-
- //! keypoints.ptr<float>(X_ROW)[i] will contain x coordinate of i'th feature
-
- //! keypoints.ptr<float>(Y_ROW)[i] will contain y coordinate of i'th feature
-
- //! keypoints.ptr<float>(LAPLACIAN_ROW)[i] will contain laplacian sign of i'th feature
-
- //! keypoints.ptr<float>(OCTAVE_ROW)[i] will contain octave of i'th feature
-
- //! keypoints.ptr<float>(SIZE_ROW)[i] will contain size of i'th feature
-
- //! keypoints.ptr<float>(ANGLE_ROW)[i] will contain orientation of i'th feature
-
- //! keypoints.ptr<float>(HESSIAN_ROW)[i] will contain response of i'th feature
-
- void operator()(const oclMat &img, const oclMat &mask, oclMat &keypoints);
-
- //! finds the keypoints and computes their descriptors.
-
- //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
-
- void operator()(const oclMat &img, const oclMat &mask, oclMat &keypoints, oclMat &descriptors,
-
- bool useProvidedKeypoints = false);
-
-
-
- void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints);
-
- void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints, oclMat &descriptors,
-
- bool useProvidedKeypoints = false);
-
-
-
- void operator()(const oclMat &img, const oclMat &mask, std::vector<KeyPoint> &keypoints, std::vector<float> &descriptors,
-
- bool useProvidedKeypoints = false);
-
-
-
- void releaseMemory();
-
-
-
- // SURF parameters
-
- float hessianThreshold;
-
- int nOctaves;
-
- int nOctaveLayers;
-
- bool extended;
-
- bool upright;
-
-
-
- //! max keypoints = min(keypointsRatio * img.size().area(), 65535)
-
- float keypointsRatio;
-
-
-
- oclMat sum, mask1, maskSum, intBuffer;
-
-
-
- oclMat det, trace;
-
-
-
- oclMat maxPosBuffer;
-
- };
-
////////////////////////feature2d_ocl/////////////////
/****************************************************************************************\
* Distance *
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
+// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// @Authors
+// Peng Xiao, pengxiao@multicorewareinc.com
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other oclMaterials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors as is and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_OCL_PRIVATE_UTIL__
+#define __OPENCV_OCL_PRIVATE_UTIL__
+
+#include "opencv2/ocl/ocl.hpp"
+
+#if defined __APPLE__
+#include <OpenCL/OpenCL.h>
+#else
+#include <CL/opencl.h>
+#endif
+
+namespace cv
+{
+ namespace ocl
+ {
+ ///////////////////////////OpenCL call wrappers////////////////////////////
+ void CV_EXPORTS openCLMallocPitch(Context *clCxt, void **dev_ptr, size_t *pitch,
+ size_t widthInBytes, size_t height);
+ void CV_EXPORTS openCLMallocPitchEx(Context *clCxt, void **dev_ptr, size_t *pitch,
+ size_t widthInBytes, size_t height, DevMemRW rw_type, DevMemType mem_type);
+ void CV_EXPORTS openCLMemcpy2D(Context *clCxt, void *dst, size_t dpitch,
+ const void *src, size_t spitch,
+ size_t width, size_t height, enum openCLMemcpyKind kind, int channels = -1);
+ void CV_EXPORTS openCLCopyBuffer2D(Context *clCxt, void *dst, size_t dpitch, int dst_offset,
+ const void *src, size_t spitch,
+ size_t width, size_t height, int src_offset);
+ void CV_EXPORTS openCLFree(void *devPtr);
+ cl_mem CV_EXPORTS openCLCreateBuffer(Context *clCxt, size_t flag, size_t size);
+ void CV_EXPORTS openCLReadBuffer(Context *clCxt, cl_mem dst_buffer, void *host_buffer, size_t size);
+ cl_kernel CV_EXPORTS openCLGetKernelFromSource(const Context *clCxt,
+ const char **source, std::string kernelName);
+ cl_kernel CV_EXPORTS openCLGetKernelFromSource(const Context *clCxt,
+ const char **source, std::string kernelName, const char *build_options);
+ void CV_EXPORTS openCLVerifyKernel(const Context *clCxt, cl_kernel kernel, size_t *localThreads);
+ void CV_EXPORTS openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, std::vector< std::pair<size_t, const void *> > &args,
+ int globalcols , int globalrows, size_t blockSize = 16, int kernel_expand_depth = -1, int kernel_expand_channel = -1);
+ void CV_EXPORTS openCLExecuteKernel_(Context *clCxt , const char **source, std::string kernelName,
+ size_t globalThreads[3], size_t localThreads[3],
+ std::vector< std::pair<size_t, const void *> > &args, int channels, int depth, const char *build_options);
+ void CV_EXPORTS openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3],
+ size_t localThreads[3], std::vector< std::pair<size_t, const void *> > &args, int channels, int depth);
+ void CV_EXPORTS openCLExecuteKernel(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3],
+ size_t localThreads[3], std::vector< std::pair<size_t, const void *> > &args, int channels,
+ int depth, const char *build_options);
+
+ cl_mem CV_EXPORTS load_constant(cl_context context, cl_command_queue command_queue, const void *value,
+ const size_t size);
+
+ cl_mem CV_EXPORTS openCLMalloc(cl_context clCxt, size_t size, cl_mem_flags flags, void *host_ptr);
+
+ int CV_EXPORTS savetofile(const Context *clcxt, cl_program &program, const char *fileName);
+
+ enum FLUSH_MODE
+ {
+ CLFINISH = 0,
+ CLFLUSH,
+ DISABLE
+ };
+
+ void CV_EXPORTS openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3],
+ size_t localThreads[3], std::vector< std::pair<size_t, const void *> > &args, int channels, int depth, FLUSH_MODE finish_mode = DISABLE);
+ void CV_EXPORTS openCLExecuteKernel2(Context *clCxt , const char **source, std::string kernelName, size_t globalThreads[3],
+ size_t localThreads[3], std::vector< std::pair<size_t, const void *> > &args, int channels,
+ int depth, char *build_options, FLUSH_MODE finish_mode = DISABLE);
+ // bind oclMat to OpenCL image textures
+ // note:
+ // 1. there is no memory management. User need to explicitly release the resource
+ // 2. for faster clamping, there is no buffer padding for the constructed texture
+ cl_mem CV_EXPORTS bindTexture(const oclMat &mat);
+ void CV_EXPORTS releaseTexture(cl_mem& texture);
+
+ // returns whether the current context supports image2d_t format or not
+ bool CV_EXPORTS support_image2d(Context *clCxt = Context::getContext());
+
+ }//namespace ocl
+
+}//namespace cv
+
+#endif //__OPENCV_OCL_PRIVATE_UTIL__
//
//M*/
-#include <iomanip>
#include "precomp.hpp"
-#include "mcwutil.hpp"
using namespace cv;
using namespace cv::ocl;
//M*/
#include "precomp.hpp"
-#include "mcwutil.hpp"
-#include <iostream>
+
using namespace std;
using namespace cv;
using namespace cv::ocl;
//M*/
#include "precomp.hpp"
-#include "mcwutil.hpp"
+
using namespace cv;
using namespace cv::ocl;
using namespace std;
//
//M*/
-#include <iomanip>
#include "precomp.hpp"
-#include "mcwutil.hpp"
using namespace std;
using namespace cv;
//
//M*/
-#include "mcwutil.hpp"
+#include "opencv2/ocl/private/util.hpp"
#if defined (HAVE_OPENCL)
#ifndef CL_VERSION_1_2
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
-// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// @Authors
-// Peng Xiao, pengxiao@multicorewareinc.com
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other oclMaterials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors as is and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef _OPENCV_MCWUTIL_
-#define _OPENCV_MCWUTIL_
-
-#include "precomp.hpp"
-using namespace std;
-
-namespace cv
-{
- namespace ocl
- {
- enum FLUSH_MODE
- {
- CLFINISH = 0,
- CLFLUSH,
- DISABLE
- };
- void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3],
- size_t localThreads[3], vector< pair<size_t, const void *> > &args, int channels, int depth, FLUSH_MODE finish_mode = DISABLE);
- void openCLExecuteKernel2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3],
- size_t localThreads[3], vector< pair<size_t, const void *> > &args, int channels,
- int depth, char *build_options, FLUSH_MODE finish_mode = DISABLE);
- // bind oclMat to OpenCL image textures
- // note:
- // 1. there is no memory management. User need to explicitly release the resource
- // 2. for faster clamping, there is no buffer padding for the constructed texture
- cl_mem bindTexture(const oclMat &mat);
- void releaseTexture(cl_mem& texture);
-
- // returns whether the current context supports image2d_t format or not
- bool support_image2d(Context *clCxt = Context::getContext());
-
- }//namespace ocl
-
-}//namespace cv
-
-#endif //_OPENCV_MCWUTIL_
#if defined (HAVE_OPENCL)
-#if defined __APPLE__
-#include <OpenCL/OpenCL.h>
-#else
-#include <CL/opencl.h>
-#endif
-
+#include "opencv2/ocl/private/util.hpp"
#include "safe_call.hpp"
using namespace std;
{
namespace ocl
{
- ///////////////////////////OpenCL call wrappers////////////////////////////
- void openCLMallocPitch(Context *clCxt, void **dev_ptr, size_t *pitch,
- size_t widthInBytes, size_t height);
- void openCLMallocPitchEx(Context *clCxt, void **dev_ptr, size_t *pitch,
- size_t widthInBytes, size_t height, DevMemRW rw_type, DevMemType mem_type);
- void openCLMemcpy2D(Context *clCxt, void *dst, size_t dpitch,
- const void *src, size_t spitch,
- size_t width, size_t height, enum openCLMemcpyKind kind, int channels = -1);
- void openCLCopyBuffer2D(Context *clCxt, void *dst, size_t dpitch, int dst_offset,
- const void *src, size_t spitch,
- size_t width, size_t height, int src_offset);
- void openCLFree(void *devPtr);
- cl_mem openCLCreateBuffer(Context *clCxt, size_t flag, size_t size);
- void openCLReadBuffer(Context *clCxt, cl_mem dst_buffer, void *host_buffer, size_t size);
- cl_kernel openCLGetKernelFromSource(const Context *clCxt,
- const char **source, string kernelName);
- cl_kernel openCLGetKernelFromSource(const Context *clCxt,
- const char **source, string kernelName, const char *build_options);
- void openCLVerifyKernel(const Context *clCxt, cl_kernel kernel, size_t *localThreads);
- void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, vector< std::pair<size_t, const void *> > &args,
- int globalcols , int globalrows, size_t blockSize = 16, int kernel_expand_depth = -1, int kernel_expand_channel = -1);
- void openCLExecuteKernel_(Context *clCxt , const char **source, string kernelName,
- size_t globalThreads[3], size_t localThreads[3],
- vector< pair<size_t, const void *> > &args, int channels, int depth, const char *build_options);
- void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3],
- size_t localThreads[3], vector< pair<size_t, const void *> > &args, int channels, int depth);
- void openCLExecuteKernel(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3],
- size_t localThreads[3], vector< pair<size_t, const void *> > &args, int channels,
- int depth, const char *build_options);
-
- cl_mem load_constant(cl_context context, cl_command_queue command_queue, const void *value,
- const size_t size);
-
- cl_mem openCLMalloc(cl_context clCxt, size_t size, cl_mem_flags flags, void *host_ptr);
-
- //void openCLMemcpy2DWithNoPadding(cl_command_queue command_queue, cl_mem buffer, size_t size, size_t offset, void *ptr,
- // enum openCLMemcpyKind kind, cl_bool blocking_write);
- int savetofile(const Context *clcxt, cl_program &program, const char *fileName);
struct Context::Impl
{
//Information of the OpenCL context
#include "precomp.hpp"
-#include "mcwutil.hpp"
using namespace std;
using namespace cv;
using namespace cv::ocl;