ocl: move program names into opencl_kernels.hpp

This commit is contained in:
Alexander Alekhin 2013-09-27 16:41:25 +04:00
parent e8d9ed8955
commit b00f79ac5f
35 changed files with 154 additions and 428 deletions

View File

@ -450,11 +450,11 @@ macro(ocv_glob_module_sources)
if(HAVE_OPENCL AND cl_kernels) if(HAVE_OPENCL AND cl_kernels)
ocv_include_directories(${OPENCL_INCLUDE_DIRS}) ocv_include_directories(${OPENCL_INCLUDE_DIRS})
add_custom_command( add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/kernels.cpp" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp"
COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake" COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake") DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake")
source_group("Src\\OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/kernels.cpp") source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/kernels.cpp") list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
endif() endif()
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs}) source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})

View File

@ -1,6 +1,20 @@
file(GLOB cl_list "${CL_DIR}/*.cl" ) file(GLOB cl_list "${CL_DIR}/*.cl" )
list(SORT cl_list)
file(WRITE ${OUTPUT} "// This file is auto-generated. Do not edit! string(REPLACE ".cpp" ".hpp" OUTPUT_HPP "${OUTPUT}")
get_filename_component(OUTPUT_HPP_NAME "${OUTPUT_HPP}" NAME)
set(STR_CPP "// This file is auto-generated. Do not edit!
#include \"${OUTPUT_HPP_NAME}\"
namespace cv
{
namespace ocl
{
")
set(STR_HPP "// This file is auto-generated. Do not edit!
namespace cv namespace cv
{ {
@ -29,7 +43,12 @@ foreach(cl ${cl_list})
string(REGEX REPLACE "\"$" "" lines "${lines}") # unneeded " at the eof string(REGEX REPLACE "\"$" "" lines "${lines}") # unneeded " at the eof
file(APPEND ${OUTPUT} "const char* ${cl_filename}=\"${lines};\n") set(STR_CPP "${STR_CPP}const char* ${cl_filename}=\"${lines};\n")
set(STR_HPP "${STR_HPP}extern const char* ${cl_filename};\n")
endforeach() endforeach()
file(APPEND ${OUTPUT} "}\n}\n") set(STR_CPP "${STR_CPP}}\n}\n")
set(STR_HPP "${STR_HPP}}\n}\n")
file(WRITE ${OUTPUT} "${STR_CPP}")
file(WRITE ${OUTPUT_HPP} "${STR_HPP}")

View File

@ -43,27 +43,24 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <cstdio>
#ifdef HAVE_OPENCV_OCL #ifdef HAVE_OPENCV_OCL
#include <cstdio>
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *surf;
const char noImage2dOption [] = "-D DISABLE_IMAGE2D"; const char noImage2dOption [] = "-D DISABLE_IMAGE2D";
static bool use_image2d = false; static bool use_image2d = false;
static void openCLExecuteKernelSURF(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3], static void openCLExecuteKernelSURF(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) size_t localThreads[3], std::vector< std::pair<size_t, const void *> > &args, int channels, int depth)
{ {
char optBuf [100] = {0}; char optBuf [100] = {0};
char * optBufPtr = optBuf; char * optBufPtr = optBuf;
@ -486,26 +483,26 @@ void SURF_OCL_Invoker::icvCalcLayerDetAndTrace_gpu(oclMat &det, oclMat &trace, i
Context *clCxt = det.clCxt; Context *clCxt = det.clCxt;
string kernelName = "icvCalcLayerDetAndTrace"; string kernelName = "icvCalcLayerDetAndTrace";
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
if(sumTex) if(sumTex)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&sumTex)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&sumTex));
} }
else else
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&surf_.sum.data)); // if image2d is not supported args.push_back( std::make_pair( sizeof(cl_mem), (void *)&surf_.sum.data)); // if image2d is not supported
} }
args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&trace.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trace.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&trace.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&trace.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&nOctaveLayers)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&nOctaveLayers));
args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave));
args.push_back( make_pair( sizeof(cl_int), (void *)&c_layer_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&c_layer_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&surf_.sum.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&surf_.sum.step));
size_t localThreads[3] = {16, 16, 1}; size_t localThreads[3] = {16, 16, 1};
size_t globalThreads[3] = size_t globalThreads[3] =
@ -524,35 +521,35 @@ void SURF_OCL_Invoker::icvFindMaximaInLayer_gpu(const oclMat &det, const oclMat
Context *clCxt = det.clCxt; Context *clCxt = det.clCxt;
string kernelName = useMask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer"; string kernelName = useMask ? "icvFindMaximaInLayer_withmask" : "icvFindMaximaInLayer";
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&trace.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trace.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&maxCounter.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxCounter.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&counterOffset)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&counterOffset));
args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&trace.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&trace.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&nLayers)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&nLayers));
args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave));
args.push_back( make_pair( sizeof(cl_int), (void *)&layer_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&layer_cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&maxCandidates)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&maxCandidates));
args.push_back( make_pair( sizeof(cl_float), (void *)&surf_.hessianThreshold)); args.push_back( std::make_pair( sizeof(cl_float), (void *)&surf_.hessianThreshold));
if(useMask) if(useMask)
{ {
if(maskSumTex) if(maskSumTex)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&maskSumTex)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maskSumTex));
} }
else else
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&surf_.maskSum.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&surf_.maskSum.data));
} }
args.push_back( make_pair( sizeof(cl_mem), (void *)&surf_.maskSum.step)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&surf_.maskSum.step));
} }
size_t localThreads[3] = {16, 16, 1}; size_t localThreads[3] = {16, 16, 1};
size_t globalThreads[3] = {divUp(layer_cols - 2 * min_margin, localThreads[0] - 2) *localThreads[0], size_t globalThreads[3] = {divUp(layer_cols - 2 * min_margin, localThreads[0] - 2) *localThreads[0],
@ -568,19 +565,19 @@ void SURF_OCL_Invoker::icvInterpolateKeypoint_gpu(const oclMat &det, const oclMa
{ {
Context *clCxt = det.clCxt; Context *clCxt = det.clCxt;
string kernelName = "icvInterpolateKeypoint"; string kernelName = "icvInterpolateKeypoint";
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
args.push_back( make_pair( sizeof(cl_mem), (void *)&det.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&det.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&maxPosBuffer.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&counters_.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&counters_.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&det.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&det.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&octave)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&octave));
args.push_back( make_pair( sizeof(cl_int), (void *)&layer_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&layer_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&max_features)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&max_features));
size_t localThreads[3] = {3, 3, 3}; size_t localThreads[3] = {3, 3, 3};
size_t globalThreads[3] = {maxCounter *localThreads[0], localThreads[1], 1}; size_t globalThreads[3] = {maxCounter *localThreads[0], localThreads[1], 1};
@ -593,21 +590,21 @@ void SURF_OCL_Invoker::icvCalcOrientation_gpu(const oclMat &keypoints, int nFeat
Context *clCxt = counters.clCxt; Context *clCxt = counters.clCxt;
string kernelName = "icvCalcOrientation"; string kernelName = "icvCalcOrientation";
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
if(sumTex) if(sumTex)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&sumTex)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&sumTex));
} }
else else
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&surf_.sum.data)); // if image2d is not supported args.push_back( std::make_pair( sizeof(cl_mem), (void *)&surf_.sum.data)); // if image2d is not supported
} }
args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&img_cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&img_cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&surf_.sum.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&surf_.sum.step));
size_t localThreads[3] = {32, 4, 1}; size_t localThreads[3] = {32, 4, 1};
size_t globalThreads[3] = {nFeatures *localThreads[0], localThreads[1], 1}; size_t globalThreads[3] = {nFeatures *localThreads[0], localThreads[1], 1};
@ -620,11 +617,11 @@ void SURF_OCL_Invoker::icvSetUpright_gpu(const oclMat &keypoints, int nFeatures)
Context *clCxt = counters.clCxt; Context *clCxt = counters.clCxt;
string kernelName = "icvSetUpright"; string kernelName = "icvSetUpright";
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&nFeatures)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&nFeatures));
size_t localThreads[3] = {256, 1, 1}; size_t localThreads[3] = {256, 1, 1};
size_t globalThreads[3] = {saturate_cast<size_t>(nFeatures), 1, 1}; size_t globalThreads[3] = {saturate_cast<size_t>(nFeatures), 1, 1};
@ -638,7 +635,7 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
// compute unnormalized descriptors, then normalize them - odd indexing since grid must be 2D // compute unnormalized descriptors, then normalize them - odd indexing since grid must be 2D
Context *clCxt = descriptors.clCxt; Context *clCxt = descriptors.clCxt;
string kernelName; string kernelName;
vector< pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
size_t localThreads[3] = {1, 1, 1}; size_t localThreads[3] = {1, 1, 1};
size_t globalThreads[3] = {1, 1, 1}; size_t globalThreads[3] = {1, 1, 1};
@ -655,19 +652,19 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args.clear(); args.clear();
if(imgTex) if(imgTex)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&imgTex)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&imgTex));
} }
else else
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&_img.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&_img.data));
} }
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.step));
openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1); openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
@ -680,8 +677,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
globalThreads[1] = localThreads[1]; globalThreads[1] = localThreads[1];
args.clear(); args.clear();
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step));
openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1); openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
} }
@ -698,19 +695,19 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
args.clear(); args.clear();
if(imgTex) if(imgTex)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&imgTex)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&imgTex));
} }
else else
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&_img.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&_img.data));
} }
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_mem), (void *)&keypoints.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&keypoints.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&keypoints.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&keypoints.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.rows)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.cols)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&_img.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&_img.step));
openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1); openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
@ -723,8 +720,8 @@ void SURF_OCL_Invoker::compute_descriptors_gpu(const oclMat &descriptors, const
globalThreads[1] = localThreads[1]; globalThreads[1] = localThreads[1];
args.clear(); args.clear();
args.push_back( make_pair( sizeof(cl_mem), (void *)&descriptors.data)); args.push_back( std::make_pair( sizeof(cl_mem), (void *)&descriptors.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&descriptors.step)); args.push_back( std::make_pair( sizeof(cl_int), (void *)&descriptors.step));
openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1); openCLExecuteKernelSURF(clCxt, &surf, kernelName, globalThreads, localThreads, args, -1, -1);
} }

View File

@ -44,14 +44,15 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char* bgfg_mog;
typedef struct _contant_struct typedef struct _contant_struct
{ {
cl_float c_Tb; cl_float c_Tb;

View File

@ -44,20 +44,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <iomanip> #include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
////////////////////////////////////OpenCL kernel strings//////////////////////////
extern const char *blend_linear;
}
}
void cv::ocl::blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2, void cv::ocl::blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2,
oclMat &result) oclMat &result)

View File

@ -45,22 +45,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
#include <functional>
#include <iterator>
#include <vector>
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
////////////////////////////////////OpenCL kernel strings//////////////////////////
extern const char *brute_force_match;
}
}
static const int OPT_SIZE = 100; static const int OPT_SIZE = 100;

View File

@ -44,19 +44,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *build_warps;
}
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// buildWarpPlaneMaps // buildWarpPlaneMaps

View File

@ -44,19 +44,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *imgproc_canny;
}
}
cv::ocl::CannyBuf::CannyBuf(const oclMat &dx_, const oclMat &dy_) : dx(dx_), dy(dy_), counter(NULL) cv::ocl::CannyBuf::CannyBuf(const oclMat &dx_, const oclMat &dy_) : dx(dx_), dy(dy_), counter(NULL)
{ {

View File

@ -45,6 +45,7 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
@ -57,14 +58,6 @@ using namespace cv::ocl;
#define FLT_EPSILON 1.192092896e-07F #define FLT_EPSILON 1.192092896e-07F
#endif #endif
namespace cv
{
namespace ocl
{
extern const char *cvt_color;
}
}
namespace namespace
{ {
void RGB2Gray_caller(const oclMat &src, oclMat &dst, int bidx) void RGB2Gray_caller(const oclMat &src, oclMat &dst, int bidx)

View File

@ -43,20 +43,11 @@
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
extern const char *imgproc_columnsum;
}
}
void cv::ocl::columnSum(const oclMat &src, oclMat &dst) void cv::ocl::columnSum(const oclMat &src, oclMat &dst)
{ {

View File

@ -42,12 +42,10 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
#if !defined HAVE_CLAMDFFT #if !defined HAVE_CLAMDFFT
void cv::ocl::dft(const oclMat&, oclMat&, Size, int) void cv::ocl::dft(const oclMat&, oclMat&, Size, int)

View File

@ -48,26 +48,11 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace std;
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
//helper routines
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *filtering_boxFilter;
extern const char *filter_sep_row;
extern const char *filter_sep_col;
extern const char *filtering_laplacian;
extern const char *filtering_morph;
extern const char *filtering_adaptive_bilateral;
}
}
namespace namespace
{ {
inline void normalizeAnchor(int &anchor, int ksize) inline void normalizeAnchor(int &anchor, int ksize)

View File

@ -43,7 +43,6 @@
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
namespace cv { namespace ocl { namespace cv { namespace ocl {

View File

@ -42,23 +42,14 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
static bool use_cpu_sorter = true; static bool use_cpu_sorter = true;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *imgproc_gftt;
}
}
namespace namespace
{ {
enum SortMethod enum SortMethod

View File

@ -49,24 +49,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <stdio.h> #include "opencl_kernels.hpp"
#include <string>
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *haarobjectdetect;
extern const char *haarobjectdetectbackup;
extern const char *haarobjectdetect_scaled2;
}
}
/* these settings affect the quality of detection: change with care */ /* these settings affect the quality of detection: change with care */
#define CV_ADJUST_FEATURES 1 #define CV_ADJUST_FEATURES 1

View File

@ -44,9 +44,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
#define CELL_WIDTH 8 #define CELL_WIDTH 8
#define CELL_HEIGHT 8 #define CELL_HEIGHT 8
@ -57,15 +58,6 @@ using namespace std;
static oclMat gauss_w_lut; static oclMat gauss_w_lut;
static bool hog_device_cpu; static bool hog_device_cpu;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *objdetect_hog;
}
}
namespace cv namespace cv
{ {
namespace ocl namespace ocl

View File

@ -54,34 +54,15 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <iomanip> #include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
////////////////////////////////////OpenCL kernel strings//////////////////////////
extern const char *meanShift;
extern const char *imgproc_copymakeboder;
extern const char *imgproc_median;
extern const char *imgproc_threshold;
extern const char *imgproc_resize;
extern const char *imgproc_remap;
extern const char *imgproc_warpAffine;
extern const char *imgproc_warpPerspective;
extern const char *imgproc_integral_sum;
extern const char *imgproc_integral;
extern const char *imgproc_histogram;
extern const char *imgproc_bilateral;
extern const char *imgproc_calcHarris;
extern const char *imgproc_calcMinEigenVal;
extern const char *imgproc_convolve;
extern const char *imgproc_clahe;
////////////////////////////////////OpenCL call wrappers//////////////////////////// ////////////////////////////////////OpenCL call wrappers////////////////////////////
template <typename T> struct index_and_sizeof; template <typename T> struct index_and_sizeof;

View File

@ -44,8 +44,8 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace std;
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
@ -53,9 +53,6 @@ namespace cv
{ {
namespace ocl namespace ocl
{ {
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *interpolate_frames;
namespace interpolate namespace interpolate
{ {
//The following are ported from NPP_staging.cu //The following are ported from NPP_staging.cu

View File

@ -44,7 +44,6 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std;
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
@ -132,4 +131,4 @@ CV_EXPORTS const oclMat& KalmanFilter::correct(const oclMat& measurement)
gemm(gain, temp5, 1, statePre, 1, statePost); gemm(gain, temp5, 1, statePre, 1, statePost);
gemm(gain, temp2, -1, errorCovPre, 1, errorCovPost); gemm(gain, temp2, -1, errorCovPre, 1, errorCovPost);
return statePost; return statePost;
} }

View File

@ -43,20 +43,11 @@
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace ocl; using namespace cv::ocl;
namespace cv
{
namespace ocl
{
////////////////////////////////////OpenCL kernel strings//////////////////////////
extern const char *kmeans_kernel;
}
}
static void generateRandomCenter(const vector<Vec2f>& box, float* center, RNG& rng) static void generateRandomCenter(const vector<Vec2f>& box, float* center, RNG& rng)
{ {

View File

@ -44,22 +44,11 @@
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
//helper routines
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *match_template;
}
}
namespace cv namespace cv
{ {

View File

@ -46,30 +46,19 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
#define ALIGN 32
#define GPU_MATRIX_MALLOC_STEP(step) (((step) + ALIGN - 1) / ALIGN) * ALIGN
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
//////////////////////////////////////////////////////////////////////// #define ALIGN 32
//////////////////////////////// oclMat //////////////////////////////// #define GPU_MATRIX_MALLOC_STEP(step) (((step) + ALIGN - 1) / ALIGN) * ALIGN
////////////////////////////////////////////////////////////////////////
// helper routines // helper routines
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
/////////////////////////// OpenCL kernel strings ///////////////////////////
extern const char *operator_copyToM;
extern const char *operator_convertTo;
extern const char *operator_setTo;
extern const char *operator_setToM;
extern const char *convertC3C4;
extern DevMemType gDeviceMemType; extern DevMemType gDeviceMemType;
extern DevMemRW gDeviceMemRW; extern DevMemRW gDeviceMemRW;
} }

View File

@ -44,13 +44,12 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <iostream> #include "opencl_kernels.hpp"
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char *moments;
// The function calculates center of gravity and the central second order moments // The function calculates center of gravity and the central second order moments
static void icvCompleteMomentState( CvMoments* moments ) static void icvCompleteMomentState( CvMoments* moments )
{ {

View File

@ -43,8 +43,10 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace std; using namespace cv;
using namespace cv::ocl;
// Auxiliray stuff // Auxiliray stuff
namespace namespace

View File

@ -45,23 +45,14 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
#include "opencv2/video/tracking.hpp" #include "opencv2/video/tracking.hpp"
using namespace std;
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
#define MIN_SIZE 32 #define MIN_SIZE 32
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *optical_flow_farneback;
}
}
namespace cv { namespace cv {
namespace ocl { namespace ocl {
namespace optflow_farneback namespace optflow_farneback

View File

@ -45,23 +45,10 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
using std::cout;
using std::endl;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *pyr_down;
}
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/////////////////////// add subtract multiply divide ///////////////////////// /////////////////////// add subtract multiply divide /////////////////////////

View File

@ -45,21 +45,12 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace std;
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
namespace cv
{
namespace ocl
{
extern const char *pyrlk;
extern const char *pyrlk_no_image;
}
}
struct dim3 struct dim3
{ {
unsigned int x, y, z; unsigned int x, y, z;

View File

@ -45,21 +45,19 @@
// //
//M*/ //M*/
/* Haar features calculation */
//#define EMU
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
/* Haar features calculation */
//#define EMU
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char *pyr_up;
void pyrUp(const cv::ocl::oclMat &src, cv::ocl::oclMat &dst) void pyrUp(const cv::ocl::oclMat &src, cv::ocl::oclMat &dst)
{ {
int depth = src.depth(), channels = src.channels(), oclChannels = src.oclchannels(); int depth = src.depth(), channels = src.channels(), oclChannels = src.oclchannels();

View File

@ -43,18 +43,16 @@
// //
//M*/ //M*/
#include <iomanip>
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv;
using namespace cv::ocl;
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char * kernel_sort_by_key;
extern const char * kernel_stablesort_by_key;
extern const char * kernel_radix_sort_by_key;
void sortByKey(oclMat& keys, oclMat& vals, size_t vecSize, int method, bool isGreaterThan); void sortByKey(oclMat& keys, oclMat& vals, size_t vecSize, int method, bool isGreaterThan);
//TODO(pengx17): change this value depending on device other than a constant //TODO(pengx17): change this value depending on device other than a constant

View File

@ -44,29 +44,11 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <vector> #include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
using std::cout;
using std::endl;
////////////////////////////////////////////////////////////////////////
///////////////// oclMat merge and split ///////////////////////////////
////////////////////////////////////////////////////////////////////////
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *merge_mat;
extern const char *split_mat;
}
}
namespace cv namespace cv
{ {
namespace ocl namespace ocl

View File

@ -45,51 +45,11 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
#if !defined (HAVE_OPENCL)
namespace cv
{
namespace ocl
{
void cv::ocl::StereoConstantSpaceBP::estimateRecommendedParams(int, int, int &, int &, int &, int &)
{
throw_nogpu();
}
cv::ocl::StereoConstantSpaceBP::StereoConstantSpaceBP(int, int, int, int, int)
{
throw_nogpu();
}
cv::ocl::StereoConstantSpaceBP::StereoConstantSpaceBP(int, int, int, int, float, float,
float, float, int, int)
{
throw_nogpu();
}
void cv::ocl::StereoConstantSpaceBP::operator()(const oclMat &, const oclMat &, oclMat &)
{
throw_nogpu();
}
}
}
#else /* !defined (HAVE_OPENCL) */
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *stereocsbp;
}
}
namespace cv namespace cv
{ {
namespace ocl namespace ocl
@ -755,5 +715,3 @@ void cv::ocl::StereoConstantSpaceBP::operator()(const oclMat &left, const oclMat
operators[msg_type](*this, u, d, l, r, disp_selected_pyr, data_cost, data_cost_selected, temp, out, operators[msg_type](*this, u, d, l, r, disp_selected_pyr, data_cost, data_cost_selected, temp, out,
left, right, disp); left, right, disp);
} }
#endif /* !defined (HAVE_OPENCL) */

View File

@ -46,23 +46,11 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <vector> #include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *stereobm;
}
}
namespace cv namespace cv
{ {
namespace ocl namespace ocl

View File

@ -45,27 +45,11 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <vector> #include "opencl_kernels.hpp"
#include <cstdio>
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
using namespace std;
////////////////////////////////////////////////////////////////////////
///////////////// stereoBP /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *stereobp;
}
}
namespace cv namespace cv
{ {
namespace ocl namespace ocl

View File

@ -42,21 +42,12 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; #include "opencl_kernels.hpp"
using namespace cv; using namespace cv;
using namespace cv::ocl; using namespace cv::ocl;
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char* tvl1flow;
}
}
cv::ocl::OpticalFlowDual_TVL1_OCL::OpticalFlowDual_TVL1_OCL() cv::ocl::OpticalFlowDual_TVL1_OCL::OpticalFlowDual_TVL1_OCL()
{ {
tau = 0.25; tau = 0.25;

View File

@ -56,6 +56,7 @@ cv::Ptr<cv::superres::SuperResolution> cv::superres::createSuperResolution_BTVL1
} }
#else #else
#include "opencl_kernels.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
@ -67,8 +68,6 @@ namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char* superres_btvl1;
float* btvWeights_ = NULL; float* btvWeights_ = NULL;
size_t btvWeights_size = 0; size_t btvWeights_size = 0;
} }