endif()
endif()
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
+
ocv_set_module_sources(HEADERS ${lib_hdrs} SOURCES ${lib_int_hdrs} ${lib_srcs} ${kernels_cpp})
ocv_create_module(${ocl_link_libs})
}
}
-#if _MSC_VER >= 1200
-#pragma warning( push)
-#pragma warning( disable: 4267)
+#if defined _MSC_VER && _MSC_VER >= 1200
+# pragma warning( push)
+# pragma warning( disable: 4267)
#endif
#include "opencv2/ocl/matrix_operations.hpp"
-#if _MSC_VER >= 1200
-#pragma warning( pop)
+#if defined _MSC_VER && _MSC_VER >= 1200
+# pragma warning( pop)
#endif
+
#endif /* __OPENCV_GPU_HPP__ */
print_info();
- int flag = CVCL_DEVICE_TYPE_GPU;
+ // int flag = CVCL_DEVICE_TYPE_GPU;
- if(type == "cpu")
+ // if(type == "cpu")
- {
+ // {
- flag = CVCL_DEVICE_TYPE_CPU;
+ // flag = CVCL_DEVICE_TYPE_CPU;
- }
+ // }
std::vector<cv::ocl::Info> oclinfo;
int devnums = getDevice(oclinfo);
if(devnums <= device || device < 0)
Has_roi(k);
t0 = (double)cvGetTickCount();//cpu start
- Scalar cpures = cv::sum(mat1_roi);
+ cv::sum(mat1_roi);
t0 = (double)cvGetTickCount() - t0;//cpu end
t1 = (double)cvGetTickCount();//gpu start1
gmat1 = mat1_roi;
t2 = (double)cvGetTickCount(); //kernel
- Scalar gpures = cv::ocl::sum(gmat1);
+ cv::ocl::sum(gmat1);
t2 = (double)cvGetTickCount() - t2;//kernel
t1 = (double)cvGetTickCount() - t1;//gpu end1
if(j == 0)
double t = 0;
vector<Rect> faces, oclfaces;
- const static Scalar colors[] = { CV_RGB(0, 0, 255),
- CV_RGB(0, 128, 255),
- CV_RGB(0, 255, 255),
- CV_RGB(0, 255, 0),
- CV_RGB(255, 128, 0),
- CV_RGB(255, 255, 0),
- CV_RGB(255, 0, 0),
- CV_RGB(255, 0, 255)
- } ;
+ // const static Scalar colors[] = { CV_RGB(0, 0, 255),
+ // CV_RGB(0, 128, 255),
+ // CV_RGB(0, 255, 255),
+ // CV_RGB(0, 255, 0),
+ // CV_RGB(255, 128, 0),
+ // CV_RGB(255, 255, 0),
+ // CV_RGB(255, 0, 0),
+ // CV_RGB(255, 0, 255)
+ // } ;
Mat gray, smallImg(cvRound (img.rows / scale), cvRound(img.cols / scale), CV_8UC1 );
MemStorage storage(cvCreateMemStorage(0));
}
else
{
- for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
+ for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
{
cout << borderstr[i] << endl;
#ifndef PRINT_KERNEL_RUN_TIME
for(int j = 0; j < LOOP_TIMES + 1; j ++)
{
Has_roi(k);
- if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE)) && (mat1_roi.cols <= radius) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
+ if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE) && (mat1_roi.cols <= radius)) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
{
continue;
}
}
else
{
- for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
+ for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
{
#ifndef PRINT_KERNEL_RUN_TIME
double totalcputick = 0;
cv::RNG &rng = TS::ptr()->get_rng();
cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT);
- cv::Size dstSize = cv::Size(MWIDTH, MHEIGHT);
cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT);
double min = 5, max = 16;
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
+
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wmissing-declarations"
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic ignored "-Wmissing-prototypes"
+# pragma GCC diagnostic ignored "-Wextra"
+# endif
+#endif
+
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
}
-//#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
-//{ \
-// ASSERT_EQ(mat1.type(), mat2.type()); \
-// ASSERT_EQ(mat1.size(), mat2.size()); \
-// EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
-//}
+/*#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
+{ \
+ ASSERT_EQ(mat1.type(), mat2.type()); \
+ ASSERT_EQ(mat1.size(), mat2.size()); \
+ EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
+}*/
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
{ \
openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth);
}
-void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
+static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
{
arithmetic_run<char>(src1, src2, dst, kernelName, kernelString, (void *)NULL);
}
-void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
+static void arithmetic_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
{
//CV_Assert(src1.depth() != CV_8S);
if(mask.data)
+ {
CV_Assert(mask.type() == CV_8U && src1.rows == mask.rows && src1.cols == mask.cols);
+ }
Context *clCxt = src1.clCxt;
int channels = dst.oclchannels();
openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, channels, depth);
}
-void arithmetic_scalar_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString, double scalar)
+static void arithmetic_scalar_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString, double scalar)
{
if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F)
{
typedef void (*ArithmeticFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar);
-void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar)
+static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar)
{
static ArithmeticFuncS tab[8] =
{
cv::ocl::error("Unsupported arithmetic operation", __FILE__, __LINE__);
func(src1, src2, dst, mask, kernelName, kernelString, isMatSubScalar);
}
-void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
+static void arithmetic_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
{
arithmetic_scalar(src1, src2, dst, mask, kernelName, kernelString, 0);
}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////// compare ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
+static void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
{
dst.create(src1.size(), CV_8UC1);
CV_Assert(src1.oclchannels() == 1);
//////////////////////////////////////////////////////////////////////////////
//type = 0 sum,type = 1 absSum,type = 2 sqrSum
-void arithmetic_sum_buffer_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, int type = 0)
+static void arithmetic_sum_buffer_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, int type = 0)
{
vector<pair<size_t , const void *> > args;
int all_cols = src.step / (vlen * src.elemSize1());
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// minMax /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen , int groupnum, string kernelName)
+static void arithmetic_minMax_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen , int groupnum, string kernelName)
{
vector<pair<size_t , const void *> > args;
int all_cols = src.step / (vlen * src.elemSize1());
}
-void arithmetic_minMax_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum, string kernelName)
+static void arithmetic_minMax_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum, string kernelName)
{
vector<pair<size_t , const void *> > args;
size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1};
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// flip //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kernelName)
+static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kernelName)
{
if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F)
{
openCLExecuteKernel(clCxt, &arithm_flip, kernelName, globalThreads, localThreads, args, -1, depth);
}
-void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kernelName, bool isVertical)
+static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kernelName, bool isVertical)
{
if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F)
{
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// LUT //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName)
+static void arithmetic_lut_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName)
{
Context *clCxt = src1.clCxt;
int channels = src1.oclchannels();
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// exp log /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString)
+static void arithmetic_exp_log_run(const oclMat &src, oclMat &dst, string kernelName, const char **kernelString)
{
dst.create(src.size(), src.type());
CV_Assert(src.cols == dst.cols &&
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// magnitude phase ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName)
+static void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
{
arithmetic_magnitude_phase_run(src1, src2, dst, "arithm_magnitude");
}
-void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
+static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
{
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// cartToPolar ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, oclMat &dst_mag, oclMat &dst_cart,
+static void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, oclMat &dst_mag, oclMat &dst_cart,
string kernelName, bool angleInDegrees)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////// polarToCart ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_ptc_run(const oclMat &src1, const oclMat &src2, oclMat &dst1, oclMat &dst2, bool angleInDegrees,
+static void arithmetic_ptc_run(const oclMat &src1, const oclMat &src2, oclMat &dst1, oclMat &dst2, bool angleInDegrees,
string kernelName)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// minMaxLoc ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum)
+static void arithmetic_minMaxLoc_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum)
{
vector<pair<size_t , const void *> > args;
int all_cols = src.step / (vlen * src.elemSize1());
openCLExecuteKernel(src.clCxt, &arithm_minMaxLoc, "arithm_op_minMaxLoc", gt, lt, args, -1, -1, build_options);
}
-void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum)
+static void arithmetic_minMaxLoc_mask_run(const oclMat &src, const oclMat &mask, cl_mem &dst, int vlen, int groupnum)
{
vector<pair<size_t , const void *> > args;
size_t gt[3] = {groupnum * 256, 1, 1}, lt[3] = {256, 1, 1};
//////////////////////////////////////////////////////////////////////////////
///////////////////////////// countNonZero ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void arithmetic_countNonZero_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, string kernelName)
+static void arithmetic_countNonZero_run(const oclMat &src, cl_mem &dst, int vlen , int groupnum, string kernelName)
{
vector<pair<size_t , const void *> > args;
int all_cols = src.step / (vlen * src.elemSize1());
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////bitwise_op////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void bitwise_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString)
+static void bitwise_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString)
{
dst.create(src1.size(), src1.type());
openCLExecuteKernel(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, depth);
}
-void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
+static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const char **kernelString)
{
bitwise_run<char>(src1, src2, dst, kernelName, kernelString, (void *)NULL);
}
-void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
+static void bitwise_run(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
{
dst.create(src1.size(), src1.type());
CV_Assert(src1.cols == src2.cols && src2.cols == dst.cols &&
if(mask.data)
+ {
CV_Assert(mask.type() == CV_8U && src1.rows == mask.rows && src1.cols == mask.cols);
+ }
Context *clCxt = src1.clCxt;
int channels = dst.oclchannels();
typedef void (*BitwiseFuncS)(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar);
-void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar)
+static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString, int isMatSubScalar)
{
static BitwiseFuncS tab[8] =
{
cv::ocl::error("Unsupported arithmetic operation", __FILE__, __LINE__);
func(src1, src2, dst, mask, kernelName, kernelString, isMatSubScalar);
}
-void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
+static void bitwise_scalar(const oclMat &src1, const Scalar &src2, oclMat &dst, const oclMat &mask, string kernelName, const char **kernelString)
{
bitwise_scalar(src1, src2, dst, mask, kernelName, kernelString, 0);
}
//////////////////////////////////////////////////////////////////////////////
#define TILE_DIM (32)
#define BLOCK_ROWS (256/TILE_DIM)
-void transpose_run(const oclMat &src, oclMat &dst, string kernelName)
+static void transpose_run(const oclMat &src, oclMat &dst, string kernelName)
{
if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F)
{
openCLExecuteKernel(clCxt, &arithm_magnitudeSqr, "magnitudeSqr", globalThreads, localThreads, args, 2, depth);
}
-void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string kernelName, const char **kernelString)
+static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string kernelName, const char **kernelString)
{
CV_Assert(src1.cols == dst.cols && src1.rows == dst.rows);
CV_Assert(src1.type() == dst.type());
return;
}
- CV_Assert(x.type() == y.type() && x.size() == y.size() && x.depth() == CV_32F || x.depth() == CV_64F);
+ CV_Assert((x.type() == y.type() && x.size() == y.size() && x.depth() == CV_32F) || x.depth() == CV_64F);
y.create(x.size(), x.type());
string kernelName = "arithm_pow";
}
}
-void findKnnMatchDispatcher(int k, const oclMat &trainIdx, const oclMat &distance, const oclMat &allDist, int distType)
+static void findKnnMatchDispatcher(int k, const oclMat &trainIdx, const oclMat &distance, const oclMat &allDist, int distType)
{
findKnnMatch<256>(k, trainIdx, distance, allDist, distType);
}
**Extend this if necessary later.
**Note that the kernel need to be further refined.
*/
-void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
+static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
{
//Normalize the result by default
//float alpha = ksize.height * ksize.width;
}
char compile_option[128];
- sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s", anchor.x, anchor.y, localThreads[0], localThreads[1], s);
+ sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s", anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], s);
vector< pair<size_t, const void *> > args;
args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data));
//! data type supported: CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4
-void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
+static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
{
//Normalize the result by default
//float alpha = ksize.height * ksize.width;
}
char compile_option[128];
- sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s", anchor.x, anchor.y, localThreads[0], localThreads[1], s);
+ sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s", anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], s);
vector< pair<size_t, const void *> > args;
args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data));
};
}
-void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel,
+static void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel,
Size &ksize, const Point anchor, const int borderType)
{
CV_Assert(src.clCxt == dst.clCxt);
**support four border types: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_REFLECT_101
*/
-void GPUFilterBox_8u_C1R(const oclMat &src, oclMat &dst,
+static void GPUFilterBox_8u_C1R(const oclMat &src, oclMat &dst,
Size &ksize, const Point anchor, const int borderType)
{
//Normalize the result by default
openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options);
}
-void GPUFilterBox_8u_C4R(const oclMat &src, oclMat &dst,
+static void GPUFilterBox_8u_C4R(const oclMat &src, oclMat &dst,
Size &ksize, const Point anchor, const int borderType)
{
//Normalize the result by default
openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options);
}
-void GPUFilterBox_32F_C1R(const oclMat &src, oclMat &dst,
+static void GPUFilterBox_32F_C1R(const oclMat &src, oclMat &dst,
Size &ksize, const Point anchor, const int borderType)
{
//Normalize the result by default
openCLExecuteKernel(clCxt, &filtering_boxFilter, kernelName, globalThreads, localThreads, args, -1, -1, build_options);
}
-void GPUFilterBox_32F_C4R(const oclMat &src, oclMat &dst,
+static void GPUFilterBox_32F_C4R(const oclMat &src, oclMat &dst,
Size &ksize, const Point anchor, const int borderType)
{
//Normalize the result by default
}
char compile_option[128];
- sprintf(compile_option, "-D RADIUSX=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s", anchor, localThreads[0], localThreads[1], channels, btype);
+ sprintf(compile_option, "-D RADIUSX=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s", anchor, (int)localThreads[0], (int)localThreads[1], channels, btype);
size_t globalThreads[3];
globalThreads[1] = (dst.rows + localThreads[1] - 1) / localThreads[1] * localThreads[1];
CV_Assert(src.oclchannels() == dst.oclchannels());
CV_Assert(ksize == (anchor << 1) + 1);
int src_pix_per_row, dst_pix_per_row;
- int src_offset_x, src_offset_y, dst_offset_in_pixel;
+ int src_offset_x, src_offset_y;//, dst_offset_in_pixel;
src_pix_per_row = src.step / src.elemSize();
src_offset_x = (src.offset % src.step) / src.elemSize();
src_offset_y = src.offset / src.step;
dst_pix_per_row = dst.step / dst.elemSize();
- dst_offset_in_pixel = dst.offset / dst.elemSize();
+ //dst_offset_in_pixel = dst.offset / dst.elemSize();
int ridusy = (dst.rows - src.rows) >> 1;
vector<pair<size_t , const void *> > args;
args.push_back(make_pair(sizeof(cl_mem), &src.data));
case 1:
globalThreads[0] = (dst.cols + localThreads[0] - 1) / localThreads[0] * localThreads[0];
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float", "uchar", "convert_uchar_sat");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float", "uchar", "convert_uchar_sat");
break;
case 2:
globalThreads[0] = ((dst.cols + 1) / 2 + localThreads[0] - 1) / localThreads[0] * localThreads[0];
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float2", "uchar2", "convert_uchar2_sat");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float2", "uchar2", "convert_uchar2_sat");
break;
case 3:
case 4:
globalThreads[0] = (dst.cols + localThreads[0] - 1) / localThreads[0] * localThreads[0];
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float4", "uchar4", "convert_uchar4_sat");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float4", "uchar4", "convert_uchar4_sat");
break;
}
}
{
case CV_32SC1:
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float", "int", "convert_int_sat");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float", "int", "convert_int_sat");
break;
case CV_32SC3:
case CV_32SC4:
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float4", "int4", "convert_int4_sat");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float4", "int4", "convert_int4_sat");
break;
case CV_32FC1:
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float", "float", "");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float", "float", "");
break;
case CV_32FC3:
case CV_32FC4:
sprintf(compile_option, "-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D GENTYPE_SRC=%s -D GENTYPE_DST=%s -D convert_to_DST=%s",
- anchor, localThreads[0], localThreads[1], channels, btype, "float4", "float4", "");
+ anchor, (int)localThreads[0], (int)localThreads[1], channels, btype, "float4", "float4", "");
break;
}
}
CV_Assert(src.oclchannels() == dst.oclchannels());
CV_Assert(ksize == (anchor << 1) + 1);
int src_pix_per_row, dst_pix_per_row;
- int src_offset_x, src_offset_y, dst_offset_in_pixel;
+ //int src_offset_x, src_offset_y;
+ int dst_offset_in_pixel;
src_pix_per_row = src.step / src.elemSize();
- src_offset_x = (src.offset % src.step) / src.elemSize();
- src_offset_y = src.offset / src.step;
+ //src_offset_x = (src.offset % src.step) / src.elemSize();
+ //src_offset_y = src.offset / src.step;
dst_pix_per_row = dst.step / dst.elemSize();
dst_offset_in_pixel = dst.offset / dst.elemSize();
int imgoff;
float factor;
} detect_piramid_info;
-#if WIN32
+#ifdef WIN32
#define _ALIGNED_ON(_ALIGNMENT) __declspec(align(_ALIGNMENT))
typedef _ALIGNED_ON(128) struct GpuHidHaarFeature
{
double globaltime = 0;
-CvHaarClassifierCascade *
-gpuCreateHaarClassifierCascade( int stage_count )
-{
- CvHaarClassifierCascade *cascade = 0;
+// static CvHaarClassifierCascade * gpuCreateHaarClassifierCascade( int stage_count )
+// {
+// CvHaarClassifierCascade *cascade = 0;
- int block_size = sizeof(*cascade) + stage_count * sizeof(*cascade->stage_classifier);
+// int block_size = sizeof(*cascade) + stage_count * sizeof(*cascade->stage_classifier);
- if( stage_count <= 0 )
- CV_Error( CV_StsOutOfRange, "Number of stages should be positive" );
+// if( stage_count <= 0 )
+// CV_Error( CV_StsOutOfRange, "Number of stages should be positive" );
- cascade = (CvHaarClassifierCascade *)cvAlloc( block_size );
- memset( cascade, 0, block_size );
+// cascade = (CvHaarClassifierCascade *)cvAlloc( block_size );
+// memset( cascade, 0, block_size );
- cascade->stage_classifier = (CvHaarStageClassifier *)(cascade + 1);
- cascade->flags = CV_HAAR_MAGIC_VAL;
- cascade->count = stage_count;
+// cascade->stage_classifier = (CvHaarStageClassifier *)(cascade + 1);
+// cascade->flags = CV_HAAR_MAGIC_VAL;
+// cascade->count = stage_count;
- return cascade;
-}
+// return cascade;
+// }
//static int globalcounter = 0;
-void
-gpuReleaseHidHaarClassifierCascade( GpuHidHaarClassifierCascade **_cascade )
-{
- if( _cascade && *_cascade )
- {
- cvFree( _cascade );
- }
-}
+// static void gpuReleaseHidHaarClassifierCascade( GpuHidHaarClassifierCascade **_cascade )
+// {
+// if( _cascade && *_cascade )
+// {
+// cvFree( _cascade );
+// }
+// }
/* create more efficient internal representation of haar classifier cascade */
-GpuHidHaarClassifierCascade *
-gpuCreateHidHaarClassifierCascade( CvHaarClassifierCascade *cascade, int *size, int *totalclassifier)
+static GpuHidHaarClassifierCascade * gpuCreateHidHaarClassifierCascade( CvHaarClassifierCascade *cascade, int *size, int *totalclassifier)
{
GpuHidHaarClassifierCascade *out = 0;
((rect).p0[offset] - (rect).p1[offset] - (rect).p2[offset] + (rect).p3[offset])
-CV_IMPL void
-gpuSetImagesForHaarClassifierCascade( CvHaarClassifierCascade *_cascade,
+static void gpuSetImagesForHaarClassifierCascade( CvHaarClassifierCascade *_cascade,
/* const CvArr* _sum,
const CvArr* _sqsum,
const CvArr* _tilted_sum,*/
} /* j */
}
}
-CV_IMPL void
-gpuSetHaarClassifierCascade( CvHaarClassifierCascade *_cascade
+
+static void gpuSetHaarClassifierCascade( CvHaarClassifierCascade *_cascade
/*double scale=0.0,*/
/*int step*/)
{
int datasize=0;
int totalclassifier=0;
- void *out;
+ //void *out;
GpuHidHaarClassifierCascade *gcascade;
GpuHidHaarStageClassifier *stage;
GpuHidHaarClassifier *classifier;
//gsqsum1 = oclMat( gimg.rows + 1, gimg.cols + 1, CV_32FC1 );
if( !cascade->hid_cascade )
- out = (void *)gpuCreateHidHaarClassifierCascade(cascade, &datasize, &totalclassifier);
+ /*out = (void *)*/gpuCreateHidHaarClassifierCascade(cascade, &datasize, &totalclassifier);
if( cascade->hid_cascade->has_tilted_features )
gtilted1 = oclMat( gimg.rows + 1, gimg.cols + 1, CV_32SC1 );
}
-CvHaarClassifierCascade *
-gpuLoadCascadeCART( const char **input_cascade, int n, CvSize orig_window_size )
-{
- int i;
- CvHaarClassifierCascade *cascade = gpuCreateHaarClassifierCascade(n);
- cascade->orig_window_size = orig_window_size;
-
- for( i = 0; i < n; i++ )
- {
- int j, count, l;
- float threshold = 0;
- const char *stage = input_cascade[i];
- int dl = 0;
-
- /* tree links */
- int parent = -1;
- int next = -1;
-
- sscanf( stage, "%d%n", &count, &dl );
- stage += dl;
-
- assert( count > 0 );
- cascade->stage_classifier[i].count = count;
- cascade->stage_classifier[i].classifier =
- (CvHaarClassifier *)cvAlloc( count * sizeof(cascade->stage_classifier[i].classifier[0]));
-
- for( j = 0; j < count; j++ )
- {
- CvHaarClassifier *classifier = cascade->stage_classifier[i].classifier + j;
- int k, rects = 0;
- char str[100];
-
- sscanf( stage, "%d%n", &classifier->count, &dl );
- stage += dl;
-
- classifier->haar_feature = (CvHaarFeature *) cvAlloc(
- classifier->count * ( sizeof( *classifier->haar_feature ) +
- sizeof( *classifier->threshold ) +
- sizeof( *classifier->left ) +
- sizeof( *classifier->right ) ) +
- (classifier->count + 1) * sizeof( *classifier->alpha ) );
- classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
- classifier->left = (int *) (classifier->threshold + classifier->count);
- classifier->right = (int *) (classifier->left + classifier->count);
- classifier->alpha = (float *) (classifier->right + classifier->count);
-
- for( l = 0; l < classifier->count; l++ )
- {
- sscanf( stage, "%d%n", &rects, &dl );
- stage += dl;
-
- assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
-
- for( k = 0; k < rects; k++ )
- {
- CvRect r;
- int band = 0;
- sscanf( stage, "%d%d%d%d%d%f%n",
- &r.x, &r.y, &r.width, &r.height, &band,
- &(classifier->haar_feature[l].rect[k].weight), &dl );
- stage += dl;
- classifier->haar_feature[l].rect[k].r = r;
- }
- sscanf( stage, "%s%n", str, &dl );
- stage += dl;
-
- classifier->haar_feature[l].tilted = strncmp( str, "tilted", 6 ) == 0;
-
- for( k = rects; k < CV_HAAR_FEATURE_MAX; k++ )
- {
- memset( classifier->haar_feature[l].rect + k, 0,
- sizeof(classifier->haar_feature[l].rect[k]) );
- }
-
- sscanf( stage, "%f%d%d%n", &(classifier->threshold[l]),
- &(classifier->left[l]),
- &(classifier->right[l]), &dl );
- stage += dl;
- }
- for( l = 0; l <= classifier->count; l++ )
- {
- sscanf( stage, "%f%n", &(classifier->alpha[l]), &dl );
- stage += dl;
- }
- }
-
- sscanf( stage, "%f%n", &threshold, &dl );
- stage += dl;
-
- cascade->stage_classifier[i].threshold = threshold;
-
- /* load tree links */
- if( sscanf( stage, "%d%d%n", &parent, &next, &dl ) != 2 )
- {
- parent = i - 1;
- next = -1;
- }
- stage += dl;
-
- cascade->stage_classifier[i].parent = parent;
- cascade->stage_classifier[i].next = next;
- cascade->stage_classifier[i].child = -1;
-
- if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
- {
- cascade->stage_classifier[parent].child = i;
- }
- }
-
- return cascade;
-}
+// static CvHaarClassifierCascade * gpuLoadCascadeCART( const char **input_cascade, int n, CvSize orig_window_size )
+// {
+// int i;
+// CvHaarClassifierCascade *cascade = gpuCreateHaarClassifierCascade(n);
+// cascade->orig_window_size = orig_window_size;
+
+// for( i = 0; i < n; i++ )
+// {
+// int j, count, l;
+// float threshold = 0;
+// const char *stage = input_cascade[i];
+// int dl = 0;
+
+// /* tree links */
+// int parent = -1;
+// int next = -1;
+
+// sscanf( stage, "%d%n", &count, &dl );
+// stage += dl;
+
+// assert( count > 0 );
+// cascade->stage_classifier[i].count = count;
+// cascade->stage_classifier[i].classifier =
+// (CvHaarClassifier *)cvAlloc( count * sizeof(cascade->stage_classifier[i].classifier[0]));
+
+// for( j = 0; j < count; j++ )
+// {
+// CvHaarClassifier *classifier = cascade->stage_classifier[i].classifier + j;
+// int k, rects = 0;
+// char str[100];
+
+// sscanf( stage, "%d%n", &classifier->count, &dl );
+// stage += dl;
+
+// classifier->haar_feature = (CvHaarFeature *) cvAlloc(
+// classifier->count * ( sizeof( *classifier->haar_feature ) +
+// sizeof( *classifier->threshold ) +
+// sizeof( *classifier->left ) +
+// sizeof( *classifier->right ) ) +
+// (classifier->count + 1) * sizeof( *classifier->alpha ) );
+// classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
+// classifier->left = (int *) (classifier->threshold + classifier->count);
+// classifier->right = (int *) (classifier->left + classifier->count);
+// classifier->alpha = (float *) (classifier->right + classifier->count);
+
+// for( l = 0; l < classifier->count; l++ )
+// {
+// sscanf( stage, "%d%n", &rects, &dl );
+// stage += dl;
+
+// assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
+
+// for( k = 0; k < rects; k++ )
+// {
+// CvRect r;
+// int band = 0;
+// sscanf( stage, "%d%d%d%d%d%f%n",
+// &r.x, &r.y, &r.width, &r.height, &band,
+// &(classifier->haar_feature[l].rect[k].weight), &dl );
+// stage += dl;
+// classifier->haar_feature[l].rect[k].r = r;
+// }
+// sscanf( stage, "%s%n", str, &dl );
+// stage += dl;
+
+// classifier->haar_feature[l].tilted = strncmp( str, "tilted", 6 ) == 0;
+
+// for( k = rects; k < CV_HAAR_FEATURE_MAX; k++ )
+// {
+// memset( classifier->haar_feature[l].rect + k, 0,
+// sizeof(classifier->haar_feature[l].rect[k]) );
+// }
+
+// sscanf( stage, "%f%d%d%n", &(classifier->threshold[l]),
+// &(classifier->left[l]),
+// &(classifier->right[l]), &dl );
+// stage += dl;
+// }
+// for( l = 0; l <= classifier->count; l++ )
+// {
+// sscanf( stage, "%f%n", &(classifier->alpha[l]), &dl );
+// stage += dl;
+// }
+// }
+
+// sscanf( stage, "%f%n", &threshold, &dl );
+// stage += dl;
+
+// cascade->stage_classifier[i].threshold = threshold;
+
+// /* load tree links */
+// if( sscanf( stage, "%d%d%n", &parent, &next, &dl ) != 2 )
+// {
+// parent = i - 1;
+// next = -1;
+// }
+// stage += dl;
+
+// cascade->stage_classifier[i].parent = parent;
+// cascade->stage_classifier[i].next = next;
+// cascade->stage_classifier[i].child = -1;
+
+// if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
+// {
+// cascade->stage_classifier[parent].child = i;
+// }
+// }
+
+// return cascade;
+// }
#ifndef _MAX_PATH
#define _MAX_PATH 1024
#endif
-CV_IMPL CvHaarClassifierCascade *
-gpuLoadHaarClassifierCascade( const char *directory, CvSize orig_window_size )
-{
- const char **input_cascade = 0;
- CvHaarClassifierCascade *cascade = 0;
-
- int i, n;
- const char *slash;
- char name[_MAX_PATH];
- int size = 0;
- char *ptr = 0;
-
- if( !directory )
- CV_Error( CV_StsNullPtr, "Null path is passed" );
-
- n = (int)strlen(directory) - 1;
- slash = directory[n] == '\\' || directory[n] == '/' ? "" : "/";
-
- /* try to read the classifier from directory */
- for( n = 0; ; n++ )
- {
- sprintf( name, "%s%s%d/AdaBoostCARTHaarClassifier.txt", directory, slash, n );
- FILE *f = fopen( name, "rb" );
- if( !f )
- break;
- fseek( f, 0, SEEK_END );
- size += ftell( f ) + 1;
- fclose(f);
- }
-
- if( n == 0 && slash[0] )
- return (CvHaarClassifierCascade *)cvLoad( directory );
-
- if( n == 0 )
- CV_Error( CV_StsBadArg, "Invalid path" );
-
- size += (n + 1) * sizeof(char *);
- input_cascade = (const char **)cvAlloc( size );
- ptr = (char *)(input_cascade + n + 1);
-
- for( i = 0; i < n; i++ )
- {
- sprintf( name, "%s/%d/AdaBoostCARTHaarClassifier.txt", directory, i );
- FILE *f = fopen( name, "rb" );
- if( !f )
- CV_Error( CV_StsError, "" );
- fseek( f, 0, SEEK_END );
- size = ftell( f );
- fseek( f, 0, SEEK_SET );
- fread( ptr, 1, size, f );
- fclose(f);
- input_cascade[i] = ptr;
- ptr += size;
- *ptr++ = '\0';
- }
-
- input_cascade[n] = 0;
- cascade = gpuLoadCascadeCART( input_cascade, n, orig_window_size );
-
- if( input_cascade )
- cvFree( &input_cascade );
-
- return cascade;
-}
-
-
-CV_IMPL void
-gpuReleaseHaarClassifierCascade( CvHaarClassifierCascade **_cascade )
-{
- if( _cascade && *_cascade )
- {
- int i, j;
- CvHaarClassifierCascade *cascade = *_cascade;
-
- for( i = 0; i < cascade->count; i++ )
- {
- for( j = 0; j < cascade->stage_classifier[i].count; j++ )
- cvFree( &cascade->stage_classifier[i].classifier[j].haar_feature );
- cvFree( &cascade->stage_classifier[i].classifier );
- }
- gpuReleaseHidHaarClassifierCascade( (GpuHidHaarClassifierCascade **)&cascade->hid_cascade );
- cvFree( _cascade );
- }
-}
+// static CvHaarClassifierCascade * gpuLoadHaarClassifierCascade( const char *directory, CvSize orig_window_size )
+// {
+// const char **input_cascade = 0;
+// CvHaarClassifierCascade *cascade = 0;
+
+// int i, n;
+// const char *slash;
+// char name[_MAX_PATH];
+// int size = 0;
+// char *ptr = 0;
+
+// if( !directory )
+// CV_Error( CV_StsNullPtr, "Null path is passed" );
+
+// n = (int)strlen(directory) - 1;
+// slash = directory[n] == '\\' || directory[n] == '/' ? "" : "/";
+
+// /* try to read the classifier from directory */
+// for( n = 0; ; n++ )
+// {
+// sprintf( name, "%s%s%d/AdaBoostCARTHaarClassifier.txt", directory, slash, n );
+// FILE *f = fopen( name, "rb" );
+// if( !f )
+// break;
+// fseek( f, 0, SEEK_END );
+// size += ftell( f ) + 1;
+// fclose(f);
+// }
+
+// if( n == 0 && slash[0] )
+// return (CvHaarClassifierCascade *)cvLoad( directory );
+
+// if( n == 0 )
+// CV_Error( CV_StsBadArg, "Invalid path" );
+
+// size += (n + 1) * sizeof(char *);
+// input_cascade = (const char **)cvAlloc( size );
+// ptr = (char *)(input_cascade + n + 1);
+
+// for( i = 0; i < n; i++ )
+// {
+// sprintf( name, "%s/%d/AdaBoostCARTHaarClassifier.txt", directory, i );
+// FILE *f = fopen( name, "rb" );
+// if( !f )
+// CV_Error( CV_StsError, "" );
+// fseek( f, 0, SEEK_END );
+// size = ftell( f );
+// fseek( f, 0, SEEK_SET );
+// CV_Assert((size_t)size == fread( ptr, 1, size, f ));
+// fclose(f);
+// input_cascade[i] = ptr;
+// ptr += size;
+// *ptr++ = '\0';
+// }
+
+// input_cascade[n] = 0;
+// cascade = gpuLoadCascadeCART( input_cascade, n, orig_window_size );
+
+// if( input_cascade )
+// cvFree( &input_cascade );
+
+// return cascade;
+// }
+
+
+// static void gpuReleaseHaarClassifierCascade( CvHaarClassifierCascade **_cascade )
+// {
+// if( _cascade && *_cascade )
+// {
+// int i, j;
+// CvHaarClassifierCascade *cascade = *_cascade;
+
+// for( i = 0; i < cascade->count; i++ )
+// {
+// for( j = 0; j < cascade->stage_classifier[i].count; j++ )
+// cvFree( &cascade->stage_classifier[i].classifier[j].haar_feature );
+// cvFree( &cascade->stage_classifier[i].classifier );
+// }
+// gpuReleaseHidHaarClassifierCascade( (GpuHidHaarClassifierCascade **)&cascade->hid_cascade );
+// cvFree( _cascade );
+// }
+// }
/****************************************************************************************\
#define ICV_HAAR_PARENT_NAME "parent"
#define ICV_HAAR_NEXT_NAME "next"
-int
-gpuIsHaarClassifier( const void *struct_ptr )
-{
- return CV_IS_HAAR_CLASSIFIER( struct_ptr );
-}
-
-void *
-gpuReadHaarClassifier( CvFileStorage *fs, CvFileNode *node )
-{
- CvHaarClassifierCascade *cascade = NULL;
-
- char buf[256];
- CvFileNode *seq_fn = NULL; /* sequence */
- CvFileNode *fn = NULL;
- CvFileNode *stages_fn = NULL;
- CvSeqReader stages_reader;
- int n;
- int i, j, k, l;
- int parent, next;
-
- stages_fn = cvGetFileNodeByName( fs, node, ICV_HAAR_STAGES_NAME );
- if( !stages_fn || !CV_NODE_IS_SEQ( stages_fn->tag) )
- CV_Error( CV_StsError, "Invalid stages node" );
-
- n = stages_fn->data.seq->total;
- cascade = gpuCreateHaarClassifierCascade(n);
-
- /* read size */
- seq_fn = cvGetFileNodeByName( fs, node, ICV_HAAR_SIZE_NAME );
- if( !seq_fn || !CV_NODE_IS_SEQ( seq_fn->tag ) || seq_fn->data.seq->total != 2 )
- CV_Error( CV_StsError, "size node is not a valid sequence." );
- fn = (CvFileNode *) cvGetSeqElem( seq_fn->data.seq, 0 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0 )
- CV_Error( CV_StsError, "Invalid size node: width must be positive integer" );
- cascade->orig_window_size.width = fn->data.i;
- fn = (CvFileNode *) cvGetSeqElem( seq_fn->data.seq, 1 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0 )
- CV_Error( CV_StsError, "Invalid size node: height must be positive integer" );
- cascade->orig_window_size.height = fn->data.i;
-
- cvStartReadSeq( stages_fn->data.seq, &stages_reader );
- for( i = 0; i < n; ++i )
- {
- CvFileNode *stage_fn;
- CvFileNode *trees_fn;
- CvSeqReader trees_reader;
-
- stage_fn = (CvFileNode *) stages_reader.ptr;
- if( !CV_NODE_IS_MAP( stage_fn->tag ) )
- {
- sprintf( buf, "Invalid stage %d", i );
- CV_Error( CV_StsError, buf );
- }
-
- trees_fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_TREES_NAME );
- if( !trees_fn || !CV_NODE_IS_SEQ( trees_fn->tag )
- || trees_fn->data.seq->total <= 0 )
- {
- sprintf( buf, "Trees node is not a valid sequence. (stage %d)", i );
- CV_Error( CV_StsError, buf );
- }
-
- cascade->stage_classifier[i].classifier =
- (CvHaarClassifier *) cvAlloc( trees_fn->data.seq->total
- * sizeof( cascade->stage_classifier[i].classifier[0] ) );
- for( j = 0; j < trees_fn->data.seq->total; ++j )
- {
- cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
- }
- cascade->stage_classifier[i].count = trees_fn->data.seq->total;
-
- cvStartReadSeq( trees_fn->data.seq, &trees_reader );
- for( j = 0; j < trees_fn->data.seq->total; ++j )
- {
- CvFileNode *tree_fn;
- CvSeqReader tree_reader;
- CvHaarClassifier *classifier;
- int last_idx;
-
- classifier = &cascade->stage_classifier[i].classifier[j];
- tree_fn = (CvFileNode *) trees_reader.ptr;
- if( !CV_NODE_IS_SEQ( tree_fn->tag ) || tree_fn->data.seq->total <= 0 )
- {
- sprintf( buf, "Tree node is not a valid sequence."
- " (stage %d, tree %d)", i, j );
- CV_Error( CV_StsError, buf );
- }
-
- classifier->count = tree_fn->data.seq->total;
- classifier->haar_feature = (CvHaarFeature *) cvAlloc(
- classifier->count * ( sizeof( *classifier->haar_feature ) +
- sizeof( *classifier->threshold ) +
- sizeof( *classifier->left ) +
- sizeof( *classifier->right ) ) +
- (classifier->count + 1) * sizeof( *classifier->alpha ) );
- classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
- classifier->left = (int *) (classifier->threshold + classifier->count);
- classifier->right = (int *) (classifier->left + classifier->count);
- classifier->alpha = (float *) (classifier->right + classifier->count);
-
- cvStartReadSeq( tree_fn->data.seq, &tree_reader );
- for( k = 0, last_idx = 0; k < tree_fn->data.seq->total; ++k )
- {
- CvFileNode *node_fn;
- CvFileNode *feature_fn;
- CvFileNode *rects_fn;
- CvSeqReader rects_reader;
-
- node_fn = (CvFileNode *) tree_reader.ptr;
- if( !CV_NODE_IS_MAP( node_fn->tag ) )
- {
- sprintf( buf, "Tree node %d is not a valid map. (stage %d, tree %d)",
- k, i, j );
- CV_Error( CV_StsError, buf );
- }
- feature_fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_FEATURE_NAME );
- if( !feature_fn || !CV_NODE_IS_MAP( feature_fn->tag ) )
- {
- sprintf( buf, "Feature node is not a valid map. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- rects_fn = cvGetFileNodeByName( fs, feature_fn, ICV_HAAR_RECTS_NAME );
- if( !rects_fn || !CV_NODE_IS_SEQ( rects_fn->tag )
- || rects_fn->data.seq->total < 1
- || rects_fn->data.seq->total > CV_HAAR_FEATURE_MAX )
- {
- sprintf( buf, "Rects node is not a valid sequence. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- cvStartReadSeq( rects_fn->data.seq, &rects_reader );
- for( l = 0; l < rects_fn->data.seq->total; ++l )
- {
- CvFileNode *rect_fn;
- CvRect r;
-
- rect_fn = (CvFileNode *) rects_reader.ptr;
- if( !CV_NODE_IS_SEQ( rect_fn->tag ) || rect_fn->data.seq->total != 5 )
- {
- sprintf( buf, "Rect %d is not a valid sequence. "
- "(stage %d, tree %d, node %d)", l, i, j, k );
- CV_Error( CV_StsError, buf );
- }
-
- fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 0 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i < 0 )
- {
- sprintf( buf, "x coordinate must be non-negative integer. "
- "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
- CV_Error( CV_StsError, buf );
- }
- r.x = fn->data.i;
- fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 1 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i < 0 )
- {
- sprintf( buf, "y coordinate must be non-negative integer. "
- "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
- CV_Error( CV_StsError, buf );
- }
- r.y = fn->data.i;
- fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 2 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0
- || r.x + fn->data.i > cascade->orig_window_size.width )
- {
- sprintf( buf, "width must be positive integer and "
- "(x + width) must not exceed window width. "
- "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
- CV_Error( CV_StsError, buf );
- }
- r.width = fn->data.i;
- fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 3 );
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0
- || r.y + fn->data.i > cascade->orig_window_size.height )
- {
- sprintf( buf, "height must be positive integer and "
- "(y + height) must not exceed window height. "
- "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
- CV_Error( CV_StsError, buf );
- }
- r.height = fn->data.i;
- fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 4 );
- if( !CV_NODE_IS_REAL( fn->tag ) )
- {
- sprintf( buf, "weight must be real number. "
- "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
- CV_Error( CV_StsError, buf );
- }
-
- classifier->haar_feature[k].rect[l].weight = (float) fn->data.f;
- classifier->haar_feature[k].rect[l].r = r;
-
- CV_NEXT_SEQ_ELEM( sizeof( *rect_fn ), rects_reader );
- } /* for each rect */
- for( l = rects_fn->data.seq->total; l < CV_HAAR_FEATURE_MAX; ++l )
- {
- classifier->haar_feature[k].rect[l].weight = 0;
- classifier->haar_feature[k].rect[l].r = cvRect( 0, 0, 0, 0 );
- }
-
- fn = cvGetFileNodeByName( fs, feature_fn, ICV_HAAR_TILTED_NAME);
- if( !fn || !CV_NODE_IS_INT( fn->tag ) )
- {
- sprintf( buf, "tilted must be 0 or 1. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- classifier->haar_feature[k].tilted = ( fn->data.i != 0 );
- fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_THRESHOLD_NAME);
- if( !fn || !CV_NODE_IS_REAL( fn->tag ) )
- {
- sprintf( buf, "threshold must be real number. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- classifier->threshold[k] = (float) fn->data.f;
- fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_LEFT_NODE_NAME);
- if( fn )
- {
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= k
- || fn->data.i >= tree_fn->data.seq->total )
- {
- sprintf( buf, "left node must be valid node number. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- /* left node */
- classifier->left[k] = fn->data.i;
- }
- else
- {
- fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_LEFT_VAL_NAME );
- if( !fn )
- {
- sprintf( buf, "left node or left value must be specified. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- if( !CV_NODE_IS_REAL( fn->tag ) )
- {
- sprintf( buf, "left value must be real number. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- /* left value */
- if( last_idx >= classifier->count + 1 )
- {
- sprintf( buf, "Tree structure is broken: too many values. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- classifier->left[k] = -last_idx;
- classifier->alpha[last_idx++] = (float) fn->data.f;
- }
- fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_RIGHT_NODE_NAME);
- if( fn )
- {
- if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= k
- || fn->data.i >= tree_fn->data.seq->total )
- {
- sprintf( buf, "right node must be valid node number. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- /* right node */
- classifier->right[k] = fn->data.i;
- }
- else
- {
- fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_RIGHT_VAL_NAME );
- if( !fn )
- {
- sprintf( buf, "right node or right value must be specified. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- if( !CV_NODE_IS_REAL( fn->tag ) )
- {
- sprintf( buf, "right value must be real number. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- /* right value */
- if( last_idx >= classifier->count + 1 )
- {
- sprintf( buf, "Tree structure is broken: too many values. "
- "(stage %d, tree %d, node %d)", i, j, k );
- CV_Error( CV_StsError, buf );
- }
- classifier->right[k] = -last_idx;
- classifier->alpha[last_idx++] = (float) fn->data.f;
- }
-
- CV_NEXT_SEQ_ELEM( sizeof( *node_fn ), tree_reader );
- } /* for each node */
- if( last_idx != classifier->count + 1 )
- {
- sprintf( buf, "Tree structure is broken: too few values. "
- "(stage %d, tree %d)", i, j );
- CV_Error( CV_StsError, buf );
- }
-
- CV_NEXT_SEQ_ELEM( sizeof( *tree_fn ), trees_reader );
- } /* for each tree */
-
- fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_STAGE_THRESHOLD_NAME);
- if( !fn || !CV_NODE_IS_REAL( fn->tag ) )
- {
- sprintf( buf, "stage threshold must be real number. (stage %d)", i );
- CV_Error( CV_StsError, buf );
- }
- cascade->stage_classifier[i].threshold = (float) fn->data.f;
-
- parent = i - 1;
- next = -1;
-
- fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_PARENT_NAME );
- if( !fn || !CV_NODE_IS_INT( fn->tag )
- || fn->data.i < -1 || fn->data.i >= cascade->count )
- {
- sprintf( buf, "parent must be integer number. (stage %d)", i );
- CV_Error( CV_StsError, buf );
- }
- parent = fn->data.i;
- fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_NEXT_NAME );
- if( !fn || !CV_NODE_IS_INT( fn->tag )
- || fn->data.i < -1 || fn->data.i >= cascade->count )
- {
- sprintf( buf, "next must be integer number. (stage %d)", i );
- CV_Error( CV_StsError, buf );
- }
- next = fn->data.i;
-
- cascade->stage_classifier[i].parent = parent;
- cascade->stage_classifier[i].next = next;
- cascade->stage_classifier[i].child = -1;
-
- if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
- {
- cascade->stage_classifier[parent].child = i;
- }
-
- CV_NEXT_SEQ_ELEM( sizeof( *stage_fn ), stages_reader );
- } /* for each stage */
-
- return cascade;
-}
-
-void
-gpuWriteHaarClassifier( CvFileStorage *fs, const char *name, const void *struct_ptr,
- CvAttrList attributes )
-{
- int i, j, k, l;
- char buf[256];
- const CvHaarClassifierCascade *cascade = (const CvHaarClassifierCascade *) struct_ptr;
-
- /* TODO: parameters check */
-
- cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_HAAR, attributes );
-
- cvStartWriteStruct( fs, ICV_HAAR_SIZE_NAME, CV_NODE_SEQ | CV_NODE_FLOW );
- cvWriteInt( fs, NULL, cascade->orig_window_size.width );
- cvWriteInt( fs, NULL, cascade->orig_window_size.height );
- cvEndWriteStruct( fs ); /* size */
-
- cvStartWriteStruct( fs, ICV_HAAR_STAGES_NAME, CV_NODE_SEQ );
- for( i = 0; i < cascade->count; ++i )
- {
- cvStartWriteStruct( fs, NULL, CV_NODE_MAP );
- sprintf( buf, "stage %d", i );
- cvWriteComment( fs, buf, 1 );
-
- cvStartWriteStruct( fs, ICV_HAAR_TREES_NAME, CV_NODE_SEQ );
-
- for( j = 0; j < cascade->stage_classifier[i].count; ++j )
- {
- CvHaarClassifier *tree = &cascade->stage_classifier[i].classifier[j];
-
- cvStartWriteStruct( fs, NULL, CV_NODE_SEQ );
- sprintf( buf, "tree %d", j );
- cvWriteComment( fs, buf, 1 );
-
- for( k = 0; k < tree->count; ++k )
- {
- CvHaarFeature *feature = &tree->haar_feature[k];
-
- cvStartWriteStruct( fs, NULL, CV_NODE_MAP );
- if( k )
- {
- sprintf( buf, "node %d", k );
- }
- else
- {
- sprintf( buf, "root node" );
- }
- cvWriteComment( fs, buf, 1 );
-
- cvStartWriteStruct( fs, ICV_HAAR_FEATURE_NAME, CV_NODE_MAP );
-
- cvStartWriteStruct( fs, ICV_HAAR_RECTS_NAME, CV_NODE_SEQ );
- for( l = 0; l < CV_HAAR_FEATURE_MAX && feature->rect[l].r.width != 0; ++l )
- {
- cvStartWriteStruct( fs, NULL, CV_NODE_SEQ | CV_NODE_FLOW );
- cvWriteInt( fs, NULL, feature->rect[l].r.x );
- cvWriteInt( fs, NULL, feature->rect[l].r.y );
- cvWriteInt( fs, NULL, feature->rect[l].r.width );
- cvWriteInt( fs, NULL, feature->rect[l].r.height );
- cvWriteReal( fs, NULL, feature->rect[l].weight );
- cvEndWriteStruct( fs ); /* rect */
- }
- cvEndWriteStruct( fs ); /* rects */
- cvWriteInt( fs, ICV_HAAR_TILTED_NAME, feature->tilted );
- cvEndWriteStruct( fs ); /* feature */
-
- cvWriteReal( fs, ICV_HAAR_THRESHOLD_NAME, tree->threshold[k]);
-
- if( tree->left[k] > 0 )
- {
- cvWriteInt( fs, ICV_HAAR_LEFT_NODE_NAME, tree->left[k] );
- }
- else
- {
- cvWriteReal( fs, ICV_HAAR_LEFT_VAL_NAME,
- tree->alpha[-tree->left[k]] );
- }
-
- if( tree->right[k] > 0 )
- {
- cvWriteInt( fs, ICV_HAAR_RIGHT_NODE_NAME, tree->right[k] );
- }
- else
- {
- cvWriteReal( fs, ICV_HAAR_RIGHT_VAL_NAME,
- tree->alpha[-tree->right[k]] );
- }
-
- cvEndWriteStruct( fs ); /* split */
- }
-
- cvEndWriteStruct( fs ); /* tree */
- }
-
- cvEndWriteStruct( fs ); /* trees */
-
- cvWriteReal( fs, ICV_HAAR_STAGE_THRESHOLD_NAME, cascade->stage_classifier[i].threshold);
- cvWriteInt( fs, ICV_HAAR_PARENT_NAME, cascade->stage_classifier[i].parent );
- cvWriteInt( fs, ICV_HAAR_NEXT_NAME, cascade->stage_classifier[i].next );
-
- cvEndWriteStruct( fs ); /* stage */
- } /* for each stage */
-
- cvEndWriteStruct( fs ); /* stages */
- cvEndWriteStruct( fs ); /* root */
-}
-
-void *
-gpuCloneHaarClassifier( const void *struct_ptr )
-{
- CvHaarClassifierCascade *cascade = NULL;
-
- int i, j, k, n;
- const CvHaarClassifierCascade *cascade_src =
- (const CvHaarClassifierCascade *) struct_ptr;
-
- n = cascade_src->count;
- cascade = gpuCreateHaarClassifierCascade(n);
- cascade->orig_window_size = cascade_src->orig_window_size;
-
- for( i = 0; i < n; ++i )
- {
- cascade->stage_classifier[i].parent = cascade_src->stage_classifier[i].parent;
- cascade->stage_classifier[i].next = cascade_src->stage_classifier[i].next;
- cascade->stage_classifier[i].child = cascade_src->stage_classifier[i].child;
- cascade->stage_classifier[i].threshold = cascade_src->stage_classifier[i].threshold;
-
- cascade->stage_classifier[i].count = 0;
- cascade->stage_classifier[i].classifier =
- (CvHaarClassifier *) cvAlloc( cascade_src->stage_classifier[i].count
- * sizeof( cascade->stage_classifier[i].classifier[0] ) );
-
- cascade->stage_classifier[i].count = cascade_src->stage_classifier[i].count;
-
- for( j = 0; j < cascade->stage_classifier[i].count; ++j )
- cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
-
- for( j = 0; j < cascade->stage_classifier[i].count; ++j )
- {
- const CvHaarClassifier *classifier_src =
- &cascade_src->stage_classifier[i].classifier[j];
- CvHaarClassifier *classifier =
- &cascade->stage_classifier[i].classifier[j];
-
- classifier->count = classifier_src->count;
- classifier->haar_feature = (CvHaarFeature *) cvAlloc(
- classifier->count * ( sizeof( *classifier->haar_feature ) +
- sizeof( *classifier->threshold ) +
- sizeof( *classifier->left ) +
- sizeof( *classifier->right ) ) +
- (classifier->count + 1) * sizeof( *classifier->alpha ) );
- classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
- classifier->left = (int *) (classifier->threshold + classifier->count);
- classifier->right = (int *) (classifier->left + classifier->count);
- classifier->alpha = (float *) (classifier->right + classifier->count);
- for( k = 0; k < classifier->count; ++k )
- {
- classifier->haar_feature[k] = classifier_src->haar_feature[k];
- classifier->threshold[k] = classifier_src->threshold[k];
- classifier->left[k] = classifier_src->left[k];
- classifier->right[k] = classifier_src->right[k];
- classifier->alpha[k] = classifier_src->alpha[k];
- }
- classifier->alpha[classifier->count] =
- classifier_src->alpha[classifier->count];
- }
- }
-
- return cascade;
-}
+// static int gpuIsHaarClassifier( const void *struct_ptr )
+// {
+// return CV_IS_HAAR_CLASSIFIER( struct_ptr );
+// }
+
+// static void * gpuReadHaarClassifier( CvFileStorage *fs, CvFileNode *node )
+// {
+// CvHaarClassifierCascade *cascade = NULL;
+
+// char buf[256];
+// CvFileNode *seq_fn = NULL; /* sequence */
+// CvFileNode *fn = NULL;
+// CvFileNode *stages_fn = NULL;
+// CvSeqReader stages_reader;
+// int n;
+// int i, j, k, l;
+// int parent, next;
+
+// stages_fn = cvGetFileNodeByName( fs, node, ICV_HAAR_STAGES_NAME );
+// if( !stages_fn || !CV_NODE_IS_SEQ( stages_fn->tag) )
+// CV_Error( CV_StsError, "Invalid stages node" );
+
+// n = stages_fn->data.seq->total;
+// cascade = gpuCreateHaarClassifierCascade(n);
+
+// /* read size */
+// seq_fn = cvGetFileNodeByName( fs, node, ICV_HAAR_SIZE_NAME );
+// if( !seq_fn || !CV_NODE_IS_SEQ( seq_fn->tag ) || seq_fn->data.seq->total != 2 )
+// CV_Error( CV_StsError, "size node is not a valid sequence." );
+// fn = (CvFileNode *) cvGetSeqElem( seq_fn->data.seq, 0 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0 )
+// CV_Error( CV_StsError, "Invalid size node: width must be positive integer" );
+// cascade->orig_window_size.width = fn->data.i;
+// fn = (CvFileNode *) cvGetSeqElem( seq_fn->data.seq, 1 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0 )
+// CV_Error( CV_StsError, "Invalid size node: height must be positive integer" );
+// cascade->orig_window_size.height = fn->data.i;
+
+// cvStartReadSeq( stages_fn->data.seq, &stages_reader );
+// for( i = 0; i < n; ++i )
+// {
+// CvFileNode *stage_fn;
+// CvFileNode *trees_fn;
+// CvSeqReader trees_reader;
+
+// stage_fn = (CvFileNode *) stages_reader.ptr;
+// if( !CV_NODE_IS_MAP( stage_fn->tag ) )
+// {
+// sprintf( buf, "Invalid stage %d", i );
+// CV_Error( CV_StsError, buf );
+// }
+
+// trees_fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_TREES_NAME );
+// if( !trees_fn || !CV_NODE_IS_SEQ( trees_fn->tag )
+// || trees_fn->data.seq->total <= 0 )
+// {
+// sprintf( buf, "Trees node is not a valid sequence. (stage %d)", i );
+// CV_Error( CV_StsError, buf );
+// }
+
+// cascade->stage_classifier[i].classifier =
+// (CvHaarClassifier *) cvAlloc( trees_fn->data.seq->total
+// * sizeof( cascade->stage_classifier[i].classifier[0] ) );
+// for( j = 0; j < trees_fn->data.seq->total; ++j )
+// {
+// cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
+// }
+// cascade->stage_classifier[i].count = trees_fn->data.seq->total;
+
+// cvStartReadSeq( trees_fn->data.seq, &trees_reader );
+// for( j = 0; j < trees_fn->data.seq->total; ++j )
+// {
+// CvFileNode *tree_fn;
+// CvSeqReader tree_reader;
+// CvHaarClassifier *classifier;
+// int last_idx;
+
+// classifier = &cascade->stage_classifier[i].classifier[j];
+// tree_fn = (CvFileNode *) trees_reader.ptr;
+// if( !CV_NODE_IS_SEQ( tree_fn->tag ) || tree_fn->data.seq->total <= 0 )
+// {
+// sprintf( buf, "Tree node is not a valid sequence."
+// " (stage %d, tree %d)", i, j );
+// CV_Error( CV_StsError, buf );
+// }
+
+// classifier->count = tree_fn->data.seq->total;
+// classifier->haar_feature = (CvHaarFeature *) cvAlloc(
+// classifier->count * ( sizeof( *classifier->haar_feature ) +
+// sizeof( *classifier->threshold ) +
+// sizeof( *classifier->left ) +
+// sizeof( *classifier->right ) ) +
+// (classifier->count + 1) * sizeof( *classifier->alpha ) );
+// classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
+// classifier->left = (int *) (classifier->threshold + classifier->count);
+// classifier->right = (int *) (classifier->left + classifier->count);
+// classifier->alpha = (float *) (classifier->right + classifier->count);
+
+// cvStartReadSeq( tree_fn->data.seq, &tree_reader );
+// for( k = 0, last_idx = 0; k < tree_fn->data.seq->total; ++k )
+// {
+// CvFileNode *node_fn;
+// CvFileNode *feature_fn;
+// CvFileNode *rects_fn;
+// CvSeqReader rects_reader;
+
+// node_fn = (CvFileNode *) tree_reader.ptr;
+// if( !CV_NODE_IS_MAP( node_fn->tag ) )
+// {
+// sprintf( buf, "Tree node %d is not a valid map. (stage %d, tree %d)",
+// k, i, j );
+// CV_Error( CV_StsError, buf );
+// }
+// feature_fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_FEATURE_NAME );
+// if( !feature_fn || !CV_NODE_IS_MAP( feature_fn->tag ) )
+// {
+// sprintf( buf, "Feature node is not a valid map. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// rects_fn = cvGetFileNodeByName( fs, feature_fn, ICV_HAAR_RECTS_NAME );
+// if( !rects_fn || !CV_NODE_IS_SEQ( rects_fn->tag )
+// || rects_fn->data.seq->total < 1
+// || rects_fn->data.seq->total > CV_HAAR_FEATURE_MAX )
+// {
+// sprintf( buf, "Rects node is not a valid sequence. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// cvStartReadSeq( rects_fn->data.seq, &rects_reader );
+// for( l = 0; l < rects_fn->data.seq->total; ++l )
+// {
+// CvFileNode *rect_fn;
+// CvRect r;
+
+// rect_fn = (CvFileNode *) rects_reader.ptr;
+// if( !CV_NODE_IS_SEQ( rect_fn->tag ) || rect_fn->data.seq->total != 5 )
+// {
+// sprintf( buf, "Rect %d is not a valid sequence. "
+// "(stage %d, tree %d, node %d)", l, i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+
+// fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 0 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i < 0 )
+// {
+// sprintf( buf, "x coordinate must be non-negative integer. "
+// "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
+// CV_Error( CV_StsError, buf );
+// }
+// r.x = fn->data.i;
+// fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 1 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i < 0 )
+// {
+// sprintf( buf, "y coordinate must be non-negative integer. "
+// "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
+// CV_Error( CV_StsError, buf );
+// }
+// r.y = fn->data.i;
+// fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 2 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0
+// || r.x + fn->data.i > cascade->orig_window_size.width )
+// {
+// sprintf( buf, "width must be positive integer and "
+// "(x + width) must not exceed window width. "
+// "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
+// CV_Error( CV_StsError, buf );
+// }
+// r.width = fn->data.i;
+// fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 3 );
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= 0
+// || r.y + fn->data.i > cascade->orig_window_size.height )
+// {
+// sprintf( buf, "height must be positive integer and "
+// "(y + height) must not exceed window height. "
+// "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
+// CV_Error( CV_StsError, buf );
+// }
+// r.height = fn->data.i;
+// fn = CV_SEQ_ELEM( rect_fn->data.seq, CvFileNode, 4 );
+// if( !CV_NODE_IS_REAL( fn->tag ) )
+// {
+// sprintf( buf, "weight must be real number. "
+// "(stage %d, tree %d, node %d, rect %d)", i, j, k, l );
+// CV_Error( CV_StsError, buf );
+// }
+
+// classifier->haar_feature[k].rect[l].weight = (float) fn->data.f;
+// classifier->haar_feature[k].rect[l].r = r;
+
+// CV_NEXT_SEQ_ELEM( sizeof( *rect_fn ), rects_reader );
+// } /* for each rect */
+// for( l = rects_fn->data.seq->total; l < CV_HAAR_FEATURE_MAX; ++l )
+// {
+// classifier->haar_feature[k].rect[l].weight = 0;
+// classifier->haar_feature[k].rect[l].r = cvRect( 0, 0, 0, 0 );
+// }
+
+// fn = cvGetFileNodeByName( fs, feature_fn, ICV_HAAR_TILTED_NAME);
+// if( !fn || !CV_NODE_IS_INT( fn->tag ) )
+// {
+// sprintf( buf, "tilted must be 0 or 1. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// classifier->haar_feature[k].tilted = ( fn->data.i != 0 );
+// fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_THRESHOLD_NAME);
+// if( !fn || !CV_NODE_IS_REAL( fn->tag ) )
+// {
+// sprintf( buf, "threshold must be real number. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// classifier->threshold[k] = (float) fn->data.f;
+// fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_LEFT_NODE_NAME);
+// if( fn )
+// {
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= k
+// || fn->data.i >= tree_fn->data.seq->total )
+// {
+// sprintf( buf, "left node must be valid node number. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// /* left node */
+// classifier->left[k] = fn->data.i;
+// }
+// else
+// {
+// fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_LEFT_VAL_NAME );
+// if( !fn )
+// {
+// sprintf( buf, "left node or left value must be specified. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// if( !CV_NODE_IS_REAL( fn->tag ) )
+// {
+// sprintf( buf, "left value must be real number. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// /* left value */
+// if( last_idx >= classifier->count + 1 )
+// {
+// sprintf( buf, "Tree structure is broken: too many values. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// classifier->left[k] = -last_idx;
+// classifier->alpha[last_idx++] = (float) fn->data.f;
+// }
+// fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_RIGHT_NODE_NAME);
+// if( fn )
+// {
+// if( !CV_NODE_IS_INT( fn->tag ) || fn->data.i <= k
+// || fn->data.i >= tree_fn->data.seq->total )
+// {
+// sprintf( buf, "right node must be valid node number. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// /* right node */
+// classifier->right[k] = fn->data.i;
+// }
+// else
+// {
+// fn = cvGetFileNodeByName( fs, node_fn, ICV_HAAR_RIGHT_VAL_NAME );
+// if( !fn )
+// {
+// sprintf( buf, "right node or right value must be specified. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// if( !CV_NODE_IS_REAL( fn->tag ) )
+// {
+// sprintf( buf, "right value must be real number. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// /* right value */
+// if( last_idx >= classifier->count + 1 )
+// {
+// sprintf( buf, "Tree structure is broken: too many values. "
+// "(stage %d, tree %d, node %d)", i, j, k );
+// CV_Error( CV_StsError, buf );
+// }
+// classifier->right[k] = -last_idx;
+// classifier->alpha[last_idx++] = (float) fn->data.f;
+// }
+
+// CV_NEXT_SEQ_ELEM( sizeof( *node_fn ), tree_reader );
+// } /* for each node */
+// if( last_idx != classifier->count + 1 )
+// {
+// sprintf( buf, "Tree structure is broken: too few values. "
+// "(stage %d, tree %d)", i, j );
+// CV_Error( CV_StsError, buf );
+// }
+
+// CV_NEXT_SEQ_ELEM( sizeof( *tree_fn ), trees_reader );
+// } /* for each tree */
+
+// fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_STAGE_THRESHOLD_NAME);
+// if( !fn || !CV_NODE_IS_REAL( fn->tag ) )
+// {
+// sprintf( buf, "stage threshold must be real number. (stage %d)", i );
+// CV_Error( CV_StsError, buf );
+// }
+// cascade->stage_classifier[i].threshold = (float) fn->data.f;
+
+// parent = i - 1;
+// next = -1;
+
+// fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_PARENT_NAME );
+// if( !fn || !CV_NODE_IS_INT( fn->tag )
+// || fn->data.i < -1 || fn->data.i >= cascade->count )
+// {
+// sprintf( buf, "parent must be integer number. (stage %d)", i );
+// CV_Error( CV_StsError, buf );
+// }
+// parent = fn->data.i;
+// fn = cvGetFileNodeByName( fs, stage_fn, ICV_HAAR_NEXT_NAME );
+// if( !fn || !CV_NODE_IS_INT( fn->tag )
+// || fn->data.i < -1 || fn->data.i >= cascade->count )
+// {
+// sprintf( buf, "next must be integer number. (stage %d)", i );
+// CV_Error( CV_StsError, buf );
+// }
+// next = fn->data.i;
+
+// cascade->stage_classifier[i].parent = parent;
+// cascade->stage_classifier[i].next = next;
+// cascade->stage_classifier[i].child = -1;
+
+// if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
+// {
+// cascade->stage_classifier[parent].child = i;
+// }
+
+// CV_NEXT_SEQ_ELEM( sizeof( *stage_fn ), stages_reader );
+// } /* for each stage */
+
+// return cascade;
+// }
+
+// static void gpuWriteHaarClassifier( CvFileStorage *fs, const char *name, const void *struct_ptr,
+// CvAttrList attributes )
+// {
+// int i, j, k, l;
+// char buf[256];
+// const CvHaarClassifierCascade *cascade = (const CvHaarClassifierCascade *) struct_ptr;
+
+// /* TODO: parameters check */
+
+// cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_HAAR, attributes );
+
+// cvStartWriteStruct( fs, ICV_HAAR_SIZE_NAME, CV_NODE_SEQ | CV_NODE_FLOW );
+// cvWriteInt( fs, NULL, cascade->orig_window_size.width );
+// cvWriteInt( fs, NULL, cascade->orig_window_size.height );
+// cvEndWriteStruct( fs ); /* size */
+
+// cvStartWriteStruct( fs, ICV_HAAR_STAGES_NAME, CV_NODE_SEQ );
+// for( i = 0; i < cascade->count; ++i )
+// {
+// cvStartWriteStruct( fs, NULL, CV_NODE_MAP );
+// sprintf( buf, "stage %d", i );
+// cvWriteComment( fs, buf, 1 );
+
+// cvStartWriteStruct( fs, ICV_HAAR_TREES_NAME, CV_NODE_SEQ );
+
+// for( j = 0; j < cascade->stage_classifier[i].count; ++j )
+// {
+// CvHaarClassifier *tree = &cascade->stage_classifier[i].classifier[j];
+
+// cvStartWriteStruct( fs, NULL, CV_NODE_SEQ );
+// sprintf( buf, "tree %d", j );
+// cvWriteComment( fs, buf, 1 );
+
+// for( k = 0; k < tree->count; ++k )
+// {
+// CvHaarFeature *feature = &tree->haar_feature[k];
+
+// cvStartWriteStruct( fs, NULL, CV_NODE_MAP );
+// if( k )
+// {
+// sprintf( buf, "node %d", k );
+// }
+// else
+// {
+// sprintf( buf, "root node" );
+// }
+// cvWriteComment( fs, buf, 1 );
+
+// cvStartWriteStruct( fs, ICV_HAAR_FEATURE_NAME, CV_NODE_MAP );
+
+// cvStartWriteStruct( fs, ICV_HAAR_RECTS_NAME, CV_NODE_SEQ );
+// for( l = 0; l < CV_HAAR_FEATURE_MAX && feature->rect[l].r.width != 0; ++l )
+// {
+// cvStartWriteStruct( fs, NULL, CV_NODE_SEQ | CV_NODE_FLOW );
+// cvWriteInt( fs, NULL, feature->rect[l].r.x );
+// cvWriteInt( fs, NULL, feature->rect[l].r.y );
+// cvWriteInt( fs, NULL, feature->rect[l].r.width );
+// cvWriteInt( fs, NULL, feature->rect[l].r.height );
+// cvWriteReal( fs, NULL, feature->rect[l].weight );
+// cvEndWriteStruct( fs ); /* rect */
+// }
+// cvEndWriteStruct( fs ); /* rects */
+// cvWriteInt( fs, ICV_HAAR_TILTED_NAME, feature->tilted );
+// cvEndWriteStruct( fs ); /* feature */
+
+// cvWriteReal( fs, ICV_HAAR_THRESHOLD_NAME, tree->threshold[k]);
+
+// if( tree->left[k] > 0 )
+// {
+// cvWriteInt( fs, ICV_HAAR_LEFT_NODE_NAME, tree->left[k] );
+// }
+// else
+// {
+// cvWriteReal( fs, ICV_HAAR_LEFT_VAL_NAME,
+// tree->alpha[-tree->left[k]] );
+// }
+
+// if( tree->right[k] > 0 )
+// {
+// cvWriteInt( fs, ICV_HAAR_RIGHT_NODE_NAME, tree->right[k] );
+// }
+// else
+// {
+// cvWriteReal( fs, ICV_HAAR_RIGHT_VAL_NAME,
+// tree->alpha[-tree->right[k]] );
+// }
+
+// cvEndWriteStruct( fs ); /* split */
+// }
+
+// cvEndWriteStruct( fs ); /* tree */
+// }
+
+// cvEndWriteStruct( fs ); /* trees */
+
+// cvWriteReal( fs, ICV_HAAR_STAGE_THRESHOLD_NAME, cascade->stage_classifier[i].threshold);
+// cvWriteInt( fs, ICV_HAAR_PARENT_NAME, cascade->stage_classifier[i].parent );
+// cvWriteInt( fs, ICV_HAAR_NEXT_NAME, cascade->stage_classifier[i].next );
+
+// cvEndWriteStruct( fs ); /* stage */
+// } /* for each stage */
+
+// cvEndWriteStruct( fs ); /* stages */
+// cvEndWriteStruct( fs ); /* root */
+// }
+
+// static void * gpuCloneHaarClassifier( const void *struct_ptr )
+// {
+// CvHaarClassifierCascade *cascade = NULL;
+
+// int i, j, k, n;
+// const CvHaarClassifierCascade *cascade_src =
+// (const CvHaarClassifierCascade *) struct_ptr;
+
+// n = cascade_src->count;
+// cascade = gpuCreateHaarClassifierCascade(n);
+// cascade->orig_window_size = cascade_src->orig_window_size;
+
+// for( i = 0; i < n; ++i )
+// {
+// cascade->stage_classifier[i].parent = cascade_src->stage_classifier[i].parent;
+// cascade->stage_classifier[i].next = cascade_src->stage_classifier[i].next;
+// cascade->stage_classifier[i].child = cascade_src->stage_classifier[i].child;
+// cascade->stage_classifier[i].threshold = cascade_src->stage_classifier[i].threshold;
+
+// cascade->stage_classifier[i].count = 0;
+// cascade->stage_classifier[i].classifier =
+// (CvHaarClassifier *) cvAlloc( cascade_src->stage_classifier[i].count
+// * sizeof( cascade->stage_classifier[i].classifier[0] ) );
+
+// cascade->stage_classifier[i].count = cascade_src->stage_classifier[i].count;
+
+// for( j = 0; j < cascade->stage_classifier[i].count; ++j )
+// cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
+
+// for( j = 0; j < cascade->stage_classifier[i].count; ++j )
+// {
+// const CvHaarClassifier *classifier_src =
+// &cascade_src->stage_classifier[i].classifier[j];
+// CvHaarClassifier *classifier =
+// &cascade->stage_classifier[i].classifier[j];
+
+// classifier->count = classifier_src->count;
+// classifier->haar_feature = (CvHaarFeature *) cvAlloc(
+// classifier->count * ( sizeof( *classifier->haar_feature ) +
+// sizeof( *classifier->threshold ) +
+// sizeof( *classifier->left ) +
+// sizeof( *classifier->right ) ) +
+// (classifier->count + 1) * sizeof( *classifier->alpha ) );
+// classifier->threshold = (float *) (classifier->haar_feature + classifier->count);
+// classifier->left = (int *) (classifier->threshold + classifier->count);
+// classifier->right = (int *) (classifier->left + classifier->count);
+// classifier->alpha = (float *) (classifier->right + classifier->count);
+// for( k = 0; k < classifier->count; ++k )
+// {
+// classifier->haar_feature[k] = classifier_src->haar_feature[k];
+// classifier->threshold[k] = classifier_src->threshold[k];
+// classifier->left[k] = classifier_src->left[k];
+// classifier->right[k] = classifier_src->right[k];
+// classifier->alpha[k] = classifier_src->alpha[k];
+// }
+// classifier->alpha[classifier->count] =
+// classifier_src->alpha[classifier->count];
+// }
+// }
+
+// return cascade;
+// }
#if 0
CvType haar_type( CV_TYPE_NAME_HAAR, gpuIsHaarClassifier,
*/
-CV_IMPL int
-gpuRunHaarClassifierCascade( /*const CvHaarClassifierCascade *_cascade,
+static int gpuRunHaarClassifierCascade( /*const CvHaarClassifierCascade *_cascade,
CvPoint pt, int start_stage */)
{
/*
typedef void (*gpuThresh_t)(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type);
- void threshold_8u(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type)
+ static void threshold_8u(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type)
{
CV_Assert( (src.cols == dst.cols) && (src.rows == dst.rows) );
Context *clCxt = src.clCxt;
openCLExecuteKernel(clCxt, &imgproc_threshold, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth());
}
- void threshold_32f(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type)
+ static void threshold_32f(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type)
{
CV_Assert( (src.cols == dst.cols) && (src.rows == dst.rows) );
Context *clCxt = src.clCxt;
////////////////////////////////////////////////////////////////////////////////////////////
// resize
- void resize_gpu( const oclMat &src, oclMat &dst, double fx, double fy, int interpolation)
+ static void resize_gpu( const oclMat &src, oclMat &dst, double fx, double fy, int interpolation)
{
CV_Assert( (src.channels() == dst.channels()) );
Context *clCxt = src.clCxt;
int dstOffset = dst.offset / dst.elemSize();
int __bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101};
const char *borderstr[] = {"BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT_101"};
- int bordertype_index;
+ size_t bordertype_index;
for(bordertype_index = 0; bordertype_index < sizeof(__bordertype) / sizeof(int); bordertype_index++)
{
if(__bordertype[bordertype_index] == bordertype)
{
#define Sd(y,x) (Sd[y*3+x])
#define Dd(y,x) (Dd[y*3+x])
-#define det3(m) (m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) - \
- m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) + \
- m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0)))
+#define det3(m) (m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) - \
+ m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) + \
+ m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0)))
double *Sd = M;
double *Dd = M;
double d = det3(Sd);
int warpInd = (flags & WARP_INVERSE_MAP) >> 4;
F coeffs[2][3];
- Mat coeffsMat(2, 3, CV_64F, (void *)coeffs);
+
+ double coeffsM[2*3];
+ Mat coeffsMat(2, 3, CV_64F, (void *)coeffsM);
M.convertTo(coeffsMat, coeffsMat.type());
if(!warpInd)
{
- convert_coeffs((F *)(&coeffs[0][0]));
+ convert_coeffs(coeffsM);
}
+
+ for(int i = 0; i < 2; ++i)
+ for(int j = 0; j < 3; ++j)
+ coeffs[i][j] = coeffsM[i*3+j];
+
warpAffine_gpu(src, dst, coeffs, interpolation);
}
int warpInd = (flags & WARP_INVERSE_MAP) >> 4;
double coeffs[3][3];
- Mat coeffsMat(3, 3, CV_64F, (void *)coeffs);
+
+ double coeffsM[3*3];
+ Mat coeffsMat(3, 3, CV_64F, (void *)coeffsM);
M.convertTo(coeffsMat, coeffsMat.type());
if(!warpInd)
{
- invert((double *)(&coeffs[0][0]));
+ invert(coeffsM);
}
+ for(int i = 0; i < 3; ++i)
+ for(int j = 0; j < 3; ++j)
+ coeffs[i][j] = coeffsM[i*3+j];
+
warpPerspective_gpu(src, dst, coeffs, interpolation);
}
}
/////////////////////// corner //////////////////////////////
- void extractCovData(const oclMat &src, oclMat &Dx, oclMat &Dy,
+ static void extractCovData(const oclMat &src, oclMat &Dx, oclMat &Dy,
int blockSize, int ksize, int borderType)
{
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_32FC1);
CV_Assert(Dx.offset == 0 && Dy.offset == 0);
}
- void corner_ocl(const char *src_str, string kernelName, int block_size, float k, oclMat &Dx, oclMat &Dy,
+ static void corner_ocl(const char *src_str, string kernelName, int block_size, float k, oclMat &Dx, oclMat &Dy,
oclMat &dst, int border_type)
{
char borderType[30];
corner_ocl(imgproc_calcMinEigenVal, "calcMinEigenVal", blockSize, 0, Dx, Dy, dst, borderType);
}
/////////////////////////////////// MeanShiftfiltering ///////////////////////////////////////////////
- void meanShiftFiltering_gpu(const oclMat &src, oclMat dst, int sp, int sr, int maxIter, float eps)
+ static void meanShiftFiltering_gpu(const oclMat &src, oclMat dst, int sp, int sr, int maxIter, float eps)
{
CV_Assert( (src.cols == dst.cols) && (src.rows == dst.rows) );
CV_Assert( !(dst.step & 0x3) );
}
- void meanShiftProc_gpu(const oclMat &src, oclMat dstr, oclMat dstsp, int sp, int sr, int maxIter, float eps)
+ static void meanShiftProc_gpu(const oclMat &src, oclMat dstr, oclMat dstsp, int sp, int sr, int maxIter, float eps)
{
//sanity checks
CV_Assert( (src.cols == dstr.cols) && (src.rows == dstr.rows) &&
const int HISTOGRAM256_BIN_COUNT = 256;
}
///////////////////////////////calcHist/////////////////////////////////////////////////////////////////
- void calc_sub_hist(const oclMat &mat_src, const oclMat &mat_sub_hist)
+ static void calc_sub_hist(const oclMat &mat_src, const oclMat &mat_sub_hist)
{
using namespace histograms;
openCLExecuteKernel(clCxt, &imgproc_histogram, kernelName, globalThreads, localThreads, args, -1, depth);
}
}
- void merge_sub_hist(const oclMat &sub_hist, oclMat &mat_hist)
+ static void merge_sub_hist(const oclMat &sub_hist, oclMat &mat_hist)
{
using namespace histograms;
{
int cn = src.channels();
int i, j, maxk, radius;
- Size size = src.size();
CV_Assert( (src.channels() == 1 || src.channels() == 3) &&
src.type() == dst.type() && src.size() == dst.size() &&
{
return (total + grain - 1) / grain;
}
-void convolve_run(const oclMat &src, const oclMat &temp1, oclMat &dst, string kernelName, const char **kernelString)
+static void convolve_run(const oclMat &src, const oclMat &temp1, oclMat &dst, string kernelName, const char **kernelString)
{
CV_Assert(src.depth() == CV_32FC1);
CV_Assert(temp1.depth() == CV_32F);
int getDevice(std::vector<Info> &oclinfo, int devicetype)
{
- cl_device_type _devicetype;
switch(devicetype)
{
case CVCL_DEVICE_TYPE_DEFAULT:
- _devicetype = CL_DEVICE_TYPE_DEFAULT;
- break;
case CVCL_DEVICE_TYPE_CPU:
- _devicetype = CL_DEVICE_TYPE_CPU;
- break;
case CVCL_DEVICE_TYPE_GPU:
- _devicetype = CL_DEVICE_TYPE_GPU;
- break;
case CVCL_DEVICE_TYPE_ACCELERATOR:
- _devicetype = CL_DEVICE_TYPE_ACCELERATOR;
- break;
case CVCL_DEVICE_TYPE_ALL:
- _devicetype = CL_DEVICE_TYPE_ALL;
break;
default:
CV_Error(CV_GpuApiCallError, "Unkown device type");
size_t extends_size;
openCLSafeCall(clGetDeviceInfo(oclinfo.impl->devices[devnum], CL_DEVICE_EXTENSIONS,
EXT_LEN, (void *)extends_set, &extends_size));
- CV_Assert(extends_size < EXT_LEN);
+ CV_Assert(extends_size < (size_t)EXT_LEN);
extends_set[EXT_LEN - 1] = 0;
memset(oclinfo.impl->extra_options, 0, 512);
oclinfo.impl->double_support = 0;
size_t binarySize = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *binary = new char[binarySize];
- fread(binary, binarySize, 1, fp);
+ CV_Assert(1 == fread(binary, binarySize, 1, fp));
fclose(fp);
cl_int status = 0;
program = clCreateProgramWithBinary(clCxt->impl->clContext,
openCLFree(texture);
}
-#if CL_VERSION_1_2
+#ifdef CL_VERSION_1_2
cl_image_desc desc;
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
desc.image_width = img.step / img.elemSize();
// Evaluates optimal template's area threshold. If
// template's area is less than the threshold, we use naive match
// template version, otherwise FFT-based (if available)
- int getTemplateThreshold(int method, int depth)
+ static int getTemplateThreshold(int method, int depth)
{
switch (method)
{
////////////////////////////////////////////////////////////////////////
// convert_C3C4
-void convert_C3C4(const cl_mem &src, oclMat &dst)
+static void convert_C3C4(const cl_mem &src, oclMat &dst)
{
int dstStep_in_pixel = dst.step1() / dst.oclchannels();
int pixel_end = dst.wholecols * dst.wholerows - 1;
}
////////////////////////////////////////////////////////////////////////
// convert_C4C3
-void convert_C4C3(const oclMat &src, cl_mem &dst)
+static void convert_C4C3(const oclMat &src, cl_mem &dst)
{
int srcStep_in_pixel = src.step1() / src.oclchannels();
int pixel_end = src.wholecols * src.wholerows - 1;
///////////////////////////////////////////////////////////////////////////
////////////////////////////////// CopyTo /////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-void copy_to_with_mask(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName)
+static void copy_to_with_mask(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName)
{
CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols &&
src.rows == dst.rows && src.cols == dst.cols
///////////////////////////////////////////////////////////////////////////
//////////////////////////////// ConvertTo ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-void convert_run(const oclMat &src, oclMat &dst, double alpha, double beta)
+static void convert_run(const oclMat &src, oclMat &dst, double alpha, double beta)
{
string kernelName = "convert_to_S";
stringstream idxStr;
setTo(s);
return *this;
}
-void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, string kernelName)
+static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, string kernelName)
{
vector<pair<size_t , const void *> > args;
default:
CV_Error(CV_StsUnsupportedFormat, "unknown depth");
}
-#if CL_VERSION_1_2
+#ifdef CL_VERSION_1_2
if(dst.offset == 0 && dst.cols == dst.wholecols)
{
clEnqueueFillBuffer(dst.clCxt->impl->clCmdQueue, (cl_mem)dst.data, args[0].second, args[0].first, 0, dst.step * dst.rows, 0, NULL, NULL);
#endif
}
-void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const oclMat &mask, string kernelName)
+static void set_to_withmask_run(const oclMat &dst, const Scalar &scalar, const oclMat &mask, string kernelName)
{
CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols);
vector<pair<size_t , const void *> > args;
}
// provide additional methods for the user to interact with the command queue after a task is fired
- void openCLExecuteKernel_2(Context *clCxt , const char **source, string kernelName, size_t globalThreads[3],
+ static void openCLExecuteKernel_2(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)
{
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
-#if _MSC_VER >= 1200
+#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 )
#endif
//////////////////////////////////////////////////////////////////////////////
/////////////////////// add subtract multiply divide /////////////////////////
//////////////////////////////////////////////////////////////////////////////
-void pyrdown_run(const oclMat &src, const oclMat &dst)
+static void pyrdown_run(const oclMat &src, const oclMat &dst)
{
CV_Assert(src.type() == dst.type());
///////////////////////////////////////////////////////////////////////////
//////////////////////////////// ConvertTo ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-void convert_run_cus(const oclMat &src, oclMat &dst, double alpha, double beta)
+static void convert_run_cus(const oclMat &src, oclMat &dst, double alpha, double beta)
{
string kernelName = "convert_to_S";
stringstream idxStr;
// setTo(s);
// return *this;
//}
-void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, string kernelName)
+static void set_to_withoutmask_run_cus(const oclMat &dst, const Scalar &scalar, string kernelName)
{
vector<pair<size_t , const void *> > args;
default:
CV_Error(CV_StsUnsupportedFormat, "unknown depth");
}
-#if CL_VERSION_1_2
+#ifdef CL_VERSION_1_2
if(dst.offset == 0 && dst.cols == dst.wholecols)
{
clEnqueueFillBuffer(dst.clCxt->impl->clCmdQueue, (cl_mem)dst.data, args[0].second, args[0].first, 0, dst.step * dst.rows, 0, NULL, NULL);
#endif
}
-oclMat &setTo(oclMat &src, const Scalar &scalar)
+static oclMat &setTo(oclMat &src, const Scalar &scalar)
{
CV_Assert( src.depth() >= 0 && src.depth() <= 6 );
CV_DbgAssert( !src.empty());
///////////////////////////////////////////////////////////////////////////
////////////////////////////////// CopyTo /////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-void copy_to_with_mask_cus(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName)
-{
- CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols &&
- src.rows == dst.rows && src.cols == dst.cols
- && mask.type() == CV_8UC1);
-
- vector<pair<size_t , const void *> > args;
-
- std::string string_types[4][7] = {{"uchar", "char", "ushort", "short", "int", "float", "double"},
- {"uchar2", "char2", "ushort2", "short2", "int2", "float2", "double2"},
- {"uchar3", "char3", "ushort3", "short3", "int3", "float3", "double3"},
- {"uchar4", "char4", "ushort4", "short4", "int4", "float4", "double4"}
- };
- char compile_option[32];
- sprintf(compile_option, "-D GENTYPE=%s", string_types[dst.oclchannels() - 1][dst.depth()].c_str());
- size_t localThreads[3] = {16, 16, 1};
- size_t globalThreads[3];
-
- globalThreads[0] = divUp(dst.cols, localThreads[0]) * localThreads[0];
- globalThreads[1] = divUp(dst.rows, localThreads[1]) * localThreads[1];
- globalThreads[2] = 1;
-
- int dststep_in_pixel = dst.step / dst.elemSize(), dstoffset_in_pixel = dst.offset / dst.elemSize();
- int srcstep_in_pixel = src.step / src.elemSize(), srcoffset_in_pixel = src.offset / src.elemSize();
-
- args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data ));
- args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data ));
- args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step ));
- args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset ));
-
- openCLExecuteKernel2(dst.clCxt , &operator_copyToM, kernelName, globalThreads,
- localThreads, args, -1, -1, compile_option, CLFLUSH);
-}
-
-void copyTo(const oclMat &src, oclMat &m )
+// static void copy_to_with_mask_cus(const oclMat &src, oclMat &dst, const oclMat &mask, string kernelName)
+// {
+// CV_DbgAssert( dst.rows == mask.rows && dst.cols == mask.cols &&
+// src.rows == dst.rows && src.cols == dst.cols
+// && mask.type() == CV_8UC1);
+
+// vector<pair<size_t , const void *> > args;
+
+// std::string string_types[4][7] = {{"uchar", "char", "ushort", "short", "int", "float", "double"},
+// {"uchar2", "char2", "ushort2", "short2", "int2", "float2", "double2"},
+// {"uchar3", "char3", "ushort3", "short3", "int3", "float3", "double3"},
+// {"uchar4", "char4", "ushort4", "short4", "int4", "float4", "double4"}
+// };
+// char compile_option[32];
+// sprintf(compile_option, "-D GENTYPE=%s", string_types[dst.oclchannels() - 1][dst.depth()].c_str());
+// size_t localThreads[3] = {16, 16, 1};
+// size_t globalThreads[3];
+
+// globalThreads[0] = divUp(dst.cols, localThreads[0]) * localThreads[0];
+// globalThreads[1] = divUp(dst.rows, localThreads[1]) * localThreads[1];
+// globalThreads[2] = 1;
+
+// int dststep_in_pixel = dst.step / dst.elemSize(), dstoffset_in_pixel = dst.offset / dst.elemSize();
+// int srcstep_in_pixel = src.step / src.elemSize(), srcoffset_in_pixel = src.offset / src.elemSize();
+
+// args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data ));
+// args.push_back( make_pair( sizeof(cl_mem) , (void *)&dst.data ));
+// args.push_back( make_pair( sizeof(cl_mem) , (void *)&mask.data ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&srcstep_in_pixel ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&srcoffset_in_pixel ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&dststep_in_pixel ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&dstoffset_in_pixel ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.step ));
+// args.push_back( make_pair( sizeof(cl_int) , (void *)&mask.offset ));
+
+// openCLExecuteKernel2(dst.clCxt , &operator_copyToM, kernelName, globalThreads,
+// localThreads, args, -1, -1, compile_option, CLFLUSH);
+// }
+
+static void copyTo(const oclMat &src, oclMat &m )
{
CV_DbgAssert(!src.empty());
m.create(src.size(), src.type());
src.data, src.step, src.cols * src.elemSize(), src.rows, src.offset);
}
-void copyTo(const oclMat &src, oclMat &mat, const oclMat &mask)
-{
- if (mask.empty())
- {
- copyTo(src, mat);
- }
- else
- {
- mat.create(src.size(), src.type());
- copy_to_with_mask_cus(src, mat, mask, "copy_to_with_mask");
- }
-}
-
-void arithmetic_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString, void *_scalar)
+// static void copyTo(const oclMat &src, oclMat &mat, const oclMat &mask)
+// {
+// if (mask.empty())
+// {
+// copyTo(src, mat);
+// }
+// else
+// {
+// mat.create(src.size(), src.type());
+// copy_to_with_mask_cus(src, mat, mask, "copy_to_with_mask");
+// }
+// }
+
+static void arithmetic_run(const oclMat &src1, oclMat &dst, string kernelName, const char **kernelString, void *_scalar)
{
if(src1.clCxt -> impl -> double_support == 0 && src1.type() == CV_64F)
{
openCLExecuteKernel2(clCxt, kernelString, kernelName, globalThreads, localThreads, args, -1, src1.depth(), CLFLUSH);
}
-void multiply_cus(const oclMat &src1, oclMat &dst, float scalar)
+static void multiply_cus(const oclMat &src1, oclMat &dst, float scalar)
{
arithmetic_run(src1, dst, "arithm_muls", &arithm_mul, (void *)(&scalar));
}
-void pyrdown_run_cus(const oclMat &src, const oclMat &dst)
+static void pyrdown_run_cus(const oclMat &src, const oclMat &dst)
{
CV_Assert(src.type() == dst.type());
openCLExecuteKernel2(clCxt, &pyr_down, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth(), CLFLUSH);
}
-void pyrDown_cus(const oclMat &src, oclMat &dst)
+static void pyrDown_cus(const oclMat &src, oclMat &dst)
{
CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);
// //}
//}
-cl_mem bindTexture(const oclMat &mat, int depth, int channels)
+static cl_mem bindTexture(const oclMat &mat, int depth, int channels)
{
cl_mem texture;
cl_image_format format;
{
format.image_channel_order = CL_RGBA;
}
-#if CL_VERSION_1_2
+#ifdef CL_VERSION_1_2
cl_image_desc desc;
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
desc.image_width = mat.step / mat.elemSize();
return texture;
}
-void releaseTexture(cl_mem texture)
+static void releaseTexture(cl_mem texture)
{
openCLFree(texture);
}
-void lkSparse_run(oclMat &I, oclMat &J,
+static void lkSparse_run(oclMat &I, oclMat &J,
const oclMat &prevPts, oclMat &nextPts, oclMat &status, oclMat& err, bool /*GET_MIN_EIGENVALS*/, int ptcount,
int level, /*dim3 block, */dim3 patch, Size winSize, int iters)
{
delete err;
}
-void lkDense_run(oclMat &I, oclMat &J, oclMat &u, oclMat &v,
+static void lkDense_run(oclMat &I, oclMat &J, oclMat &u, oclMat &v,
oclMat &prevU, oclMat &prevV, oclMat *err, Size winSize, int iters)
{
Context *clCxt = I.clCxt;
////////////////////////////////////////////////////////////////////////////
////////////////////merge//////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
- void merge_vector_run_no_roi(const oclMat *mat_src, size_t n, oclMat &mat_dst)
- {
- Context *clCxt = mat_dst.clCxt;
- int channels = mat_dst.oclchannels();
- int depth = mat_dst.depth();
-
- string kernelName = "merge_vector";
-
- int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
- {4, 4, 2, 2, 1, 1, 1},
- {4, 4, 2, 2 , 1, 1, 1},
- {4, 4, 2, 2, 1, 1, 1}
- };
-
- size_t index = indexes[channels - 1][mat_dst.depth()];
- int cols = divUp(mat_dst.cols, index);
- size_t localThreads[3] = { 64, 4, 1 };
- size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
- divUp(mat_dst.rows, localThreads[1]) *localThreads[1],
- 1
- };
-
- vector<pair<size_t , const void *> > args;
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows));
- args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step));
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step));
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step));
- if(n >= 3)
- {
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step));
- }
- if(n >= 4)
- {
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step));
- }
-
- openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth);
- }
-
- void merge_vector_run(const oclMat *mat_src, size_t n, oclMat &mat_dst)
+ // static void merge_vector_run_no_roi(const oclMat *mat_src, size_t n, oclMat &mat_dst)
+ // {
+ // Context *clCxt = mat_dst.clCxt;
+ // int channels = mat_dst.oclchannels();
+ // int depth = mat_dst.depth();
+
+ // string kernelName = "merge_vector";
+
+ // int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
+ // {4, 4, 2, 2, 1, 1, 1},
+ // {4, 4, 2, 2 , 1, 1, 1},
+ // {4, 4, 2, 2, 1, 1, 1}
+ // };
+
+ // size_t index = indexes[channels - 1][mat_dst.depth()];
+ // int cols = divUp(mat_dst.cols, index);
+ // size_t localThreads[3] = { 64, 4, 1 };
+ // size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
+ // divUp(mat_dst.rows, localThreads[1]) *localThreads[1],
+ // 1
+ // };
+
+ // vector<pair<size_t , const void *> > args;
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step));
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step));
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step));
+ // if(n >= 3)
+ // {
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step));
+ // }
+ // if(n >= 4)
+ // {
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step));
+ // }
+
+ // openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth);
+ // }
+
+ static void merge_vector_run(const oclMat *mat_src, size_t n, oclMat &mat_dst)
{
if(mat_dst.clCxt -> impl -> double_support == 0 && mat_dst.type() == CV_64F)
{
openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth);
}
- void merge(const oclMat *mat_src, size_t n, oclMat &mat_dst)
+ static void merge(const oclMat *mat_src, size_t n, oclMat &mat_dst)
{
CV_Assert(mat_src);
CV_Assert(n > 0);
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////split/////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
- void split_vector_run_no_roi(const oclMat &mat_src, oclMat *mat_dst)
- {
- Context *clCxt = mat_src.clCxt;
- int channels = mat_src.oclchannels();
- int depth = mat_src.depth();
-
- string kernelName = "split_vector";
-
- int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
- {8, 8, 8, 8, 4, 4, 2},
- {8, 8, 8, 8 , 4, 4, 4},
- {4, 4, 2, 2, 1, 1, 1}
- };
-
- size_t index = indexes[channels - 1][mat_dst[0].depth()];
- int cols = divUp(mat_src.cols, index);
- size_t localThreads[3] = { 64, 4, 1 };
- size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
- divUp(mat_src.rows, localThreads[1]) *localThreads[1],
- 1
- };
-
- vector<pair<size_t , const void *> > args;
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows));
- args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].step));
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].step));
- if(channels >= 3)
- {
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].step));
- }
- if(channels >= 4)
- {
- args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data));
- args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].step));
- }
-
- openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth);
- }
- void split_vector_run(const oclMat &mat_src, oclMat *mat_dst)
+ // static void split_vector_run_no_roi(const oclMat &mat_src, oclMat *mat_dst)
+ // {
+ // Context *clCxt = mat_src.clCxt;
+ // int channels = mat_src.oclchannels();
+ // int depth = mat_src.depth();
+
+ // string kernelName = "split_vector";
+
+ // int indexes[4][7] = {{0, 0, 0, 0, 0, 0, 0},
+ // {8, 8, 8, 8, 4, 4, 2},
+ // {8, 8, 8, 8 , 4, 4, 4},
+ // {4, 4, 2, 2, 1, 1, 1}
+ // };
+
+ // size_t index = indexes[channels - 1][mat_dst[0].depth()];
+ // int cols = divUp(mat_src.cols, index);
+ // size_t localThreads[3] = { 64, 4, 1 };
+ // size_t globalThreads[3] = { divUp(cols, localThreads[0]) *localThreads[0],
+ // divUp(mat_src.rows, localThreads[1]) *localThreads[1],
+ // 1
+ // };
+
+ // vector<pair<size_t , const void *> > args;
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src.data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.step));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src.rows));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[0].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[0].step));
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[1].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[1].step));
+ // if(channels >= 3)
+ // {
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[2].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[2].step));
+ // }
+ // if(channels >= 4)
+ // {
+ // args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst[3].data));
+ // args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst[3].step));
+ // }
+
+ // openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth);
+ // }
+ static void split_vector_run(const oclMat &mat_src, oclMat *mat_dst)
{
if(mat_src.clCxt -> impl -> double_support == 0 && mat_src.type() == CV_64F)
openCLExecuteKernel(clCxt, &split_mat, kernelName, globalThreads, localThreads, args, channels, depth);
}
- void split(const oclMat &mat_src, oclMat *mat_dst)
+ static void split(const oclMat &mat_src, oclMat *mat_dst)
{
CV_Assert(mat_dst);
openCLFree(texture);
}
-#if CL_VERSION_1_2
+#ifdef CL_VERSION_1_2
cl_image_desc desc;
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
desc.image_width = img.step / img.elemSize();
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
+
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wmissing-declarations"
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic ignored "-Wmissing-prototypes"
+# pragma GCC diagnostic ignored "-Wextra"
+# endif
+#endif
+
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
for(int j = 0; j < LOOP_TIMES; j++)
{
// random_roi();
- int64 start, end;
- start = cv::getTickCount();
+ // int64 start, end;
+ // start = cv::getTickCount();
for(int i = 0; i < mat1.rows; ++i)
for(int j = 0; j < mat1.cols; ++j)
{
// ((float *)(dst.data))[i*dst.step/4 +j]= val1 * val1 +val2 * val2;
}
- end = cv::getTickCount();
+ // end = cv::getTickCount();
else
blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
- EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1 : 1e-5f, NULL)
+ EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.f : 1e-5f, 0);
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, Combine(
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor_YUV420, testing::Combine(
testing::Values(cv::Size(128, 45), cv::Size(46, 132), cv::Size(1024, 1023)),
- testing::Values(CV_YUV2RGBA_NV12, CV_YUV2BGRA_NV12, CV_YUV2RGB_NV12, CV_YUV2BGR_NV12)
+ testing::Values((int)CV_YUV2RGBA_NV12, (int)CV_YUV2BGRA_NV12, (int)CV_YUV2RGB_NV12, (int)CV_YUV2BGR_NV12)
));
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor_Gray2RGB, testing::Combine(
DIFFERENT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)),
- testing::Values(CV_GRAY2BGR, CV_GRAY2BGRA, CV_GRAY2RGB, CV_GRAY2RGBA)
+ testing::Values((int)CV_GRAY2BGR, (int)CV_GRAY2BGRA, (int)CV_GRAY2RGB, (int)CV_GRAY2RGBA)
));
}
#endif
//double t = 0;
vector<Rect> faces, oclfaces;
- const static Scalar colors[] = { CV_RGB(0, 0, 255),
- CV_RGB(0, 128, 255),
- CV_RGB(0, 255, 255),
- CV_RGB(0, 255, 0),
- CV_RGB(255, 128, 0),
- CV_RGB(255, 255, 0),
- CV_RGB(255, 0, 0),
- CV_RGB(255, 0, 255)
- } ;
+ // const static Scalar colors[] = { CV_RGB(0, 0, 255),
+ // CV_RGB(0, 128, 255),
+ // CV_RGB(0, 255, 255),
+ // CV_RGB(0, 255, 0),
+ // CV_RGB(255, 128, 0),
+ // CV_RGB(255, 255, 0),
+ // CV_RGB(255, 0, 0),
+ // CV_RGB(255, 0, 255)
+ // } ;
Mat gray, smallImg(cvRound (img.rows / scale), cvRound(img.cols / scale), CV_8UC1 );
MemStorage storage(cvCreateMemStorage(0));
}
else
{
- for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
+ for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
for(int j = 0; j < LOOP_TIMES; j++)
{
random_roi();
- if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE)) && (mat1_roi.cols <= radius) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
+ if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE) && (mat1_roi.cols <= radius)) || (mat1_roi.cols <= radius) || (mat1_roi.rows <= radius) || (mat1_roi.rows <= radius))
{
continue;
}
}
else
{
- for(int i = 0; i < sizeof(bordertype) / sizeof(int); i++)
+ for(size_t i = 0; i < sizeof(bordertype) / sizeof(int); i++)
for(int j = 0; j < LOOP_TIMES; j++)
{
random_roi();
cv::RNG &rng = TS::ptr()->get_rng();
cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT);
- cv::Size dstSize = cv::Size(MWIDTH, MHEIGHT);
cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT);
double min = 5, max = 16;
EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss);
-#if PERF_TEST
+#ifdef PERF_TEST
{
P_TEST_FULL( {}, {cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);}, {});
P_TEST_FULL( {}, {cv::matchTemplate(image, templ, dst_gold, method);}, {});
EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss);
-#if PERF_TEST
+#ifdef PERF_TEST
{
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
std::cout << "Image Size: (" << size.width << ", " << size.height << ")" << std::endl;
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
}
-//#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
-//{ \
-// ASSERT_EQ(mat1.type(), mat2.type()); \
-// ASSERT_EQ(mat1.size(), mat2.size()); \
-// EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
-//}
+/*#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
+{ \
+ ASSERT_EQ(mat1.type(), mat2.type()); \
+ ASSERT_EQ(mat1.size(), mat2.size()); \
+ EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
+}*/
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
{ \