mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
use format on filtering.cpp
This commit is contained in:
parent
56c1a7fab6
commit
9060365f5e
@ -170,53 +170,53 @@ void cv::ocl::morphologyEx( const oclMat &, oclMat &, int, const Mat &, Point, i
|
||||
//helper routines
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
///////////////////////////OpenCL kernel strings///////////////////////////
|
||||
extern const char *filtering_boxFilter;
|
||||
extern const char *filter_sep_row;
|
||||
extern const char *filter_sep_col;
|
||||
extern const char *filtering_laplacian;
|
||||
extern const char *filtering_morph;
|
||||
}
|
||||
namespace ocl
|
||||
{
|
||||
///////////////////////////OpenCL kernel strings///////////////////////////
|
||||
extern const char *filtering_boxFilter;
|
||||
extern const char *filter_sep_row;
|
||||
extern const char *filter_sep_col;
|
||||
extern const char *filtering_laplacian;
|
||||
extern const char *filtering_morph;
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
inline int divUp(int total, int grain)
|
||||
{
|
||||
inline int divUp(int total, int grain)
|
||||
{
|
||||
return (total + grain - 1) / grain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
inline void normalizeAnchor(int &anchor, int ksize)
|
||||
{
|
||||
inline void normalizeAnchor(int &anchor, int ksize)
|
||||
{
|
||||
if (anchor < 0)
|
||||
anchor = ksize >> 1;
|
||||
|
||||
CV_Assert(0 <= anchor && anchor < ksize);
|
||||
}
|
||||
}
|
||||
|
||||
inline void normalizeAnchor(Point &anchor, const Size &ksize)
|
||||
{
|
||||
inline void normalizeAnchor(Point &anchor, const Size &ksize)
|
||||
{
|
||||
normalizeAnchor(anchor.x, ksize.width);
|
||||
normalizeAnchor(anchor.y, ksize.height);
|
||||
}
|
||||
}
|
||||
|
||||
inline void normalizeROI(Rect &roi, const Size &ksize, const Point &anchor, const Size &src_size)
|
||||
{
|
||||
inline void normalizeROI(Rect &roi, const Size &ksize, const Point &anchor, const Size &src_size)
|
||||
{
|
||||
if (roi == Rect(0, 0, -1, -1))
|
||||
roi = Rect(0, 0, src_size.width, src_size.height);
|
||||
CV_Assert(ksize.height > 0 && ksize.width > 0 && ((ksize.height & 1) == 1) && ((ksize.width & 1) == 1));
|
||||
CV_Assert((anchor.x == -1 && anchor.y == -1) || (anchor.x == ksize.width >> 1 && anchor.y == ksize.height >> 1));
|
||||
CV_Assert(roi.x >= 0 && roi.y >= 0 && roi.width <= src_size.width && roi.height <= src_size.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void normalizeKernel(const Mat &kernel, oclMat &gpu_krnl, int type = CV_8U, int *nDivisor = 0, bool reverse = false)
|
||||
{
|
||||
inline void normalizeKernel(const Mat &kernel, oclMat &gpu_krnl, int type = CV_8U, int *nDivisor = 0, bool reverse = false)
|
||||
{
|
||||
int scale = nDivisor && (kernel.depth() == CV_32F || kernel.depth() == CV_64F) ? 256 : 1;
|
||||
if (nDivisor) *nDivisor = scale;
|
||||
|
||||
@ -234,16 +234,16 @@ namespace
|
||||
}
|
||||
|
||||
gpu_krnl.upload(cont_krnl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Filter2D
|
||||
namespace
|
||||
{
|
||||
class Filter2DEngine_GPU : public FilterEngine_GPU
|
||||
{
|
||||
public:
|
||||
class Filter2DEngine_GPU : public FilterEngine_GPU
|
||||
{
|
||||
public:
|
||||
Filter2DEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_) : filter2D(filter2D_) {}
|
||||
|
||||
virtual void apply(const oclMat &src, oclMat &dst, Rect roi = Rect(0, 0, -1, -1))
|
||||
@ -263,7 +263,7 @@ namespace
|
||||
}
|
||||
|
||||
Ptr<BaseFilter_GPU> filter2D;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Ptr<FilterEngine_GPU> cv::ocl::createFilter2D_GPU(const Ptr<BaseFilter_GPU> filter2D)
|
||||
@ -275,11 +275,11 @@ Ptr<FilterEngine_GPU> cv::ocl::createFilter2D_GPU(const Ptr<BaseFilter_GPU> filt
|
||||
// Box Filter
|
||||
namespace
|
||||
{
|
||||
typedef void (*FilterBox_t)(const oclMat & , oclMat & , Size &, const Point, const int);
|
||||
typedef void (*FilterBox_t)(const oclMat & , oclMat & , Size &, const Point, const int);
|
||||
|
||||
class GPUBoxFilter : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
class GPUBoxFilter : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
GPUBoxFilter(const Size &ksize_, const Point &anchor_, const int borderType_, FilterBox_t func_) :
|
||||
BaseFilter_GPU(ksize_, anchor_, borderType_), func(func_) {}
|
||||
|
||||
@ -290,7 +290,7 @@ namespace
|
||||
|
||||
FilterBox_t func;
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -298,11 +298,11 @@ namespace
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef void (*GPUMorfFilter_t)(const oclMat & , oclMat & , oclMat & , Size &, const Point);
|
||||
typedef void (*GPUMorfFilter_t)(const oclMat & , oclMat & , oclMat & , Size &, const Point);
|
||||
|
||||
class MorphFilter_GPU : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
class MorphFilter_GPU : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
MorphFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUMorfFilter_t func_) :
|
||||
BaseFilter_GPU(ksize_, anchor_, BORDER_CONSTANT), kernel(kernel_), func(func_) {}
|
||||
|
||||
@ -313,7 +313,7 @@ namespace
|
||||
|
||||
oclMat kernel;
|
||||
GPUMorfFilter_t func;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
@ -483,9 +483,9 @@ Ptr<BaseFilter_GPU> cv::ocl::getMorphologyFilter_GPU(int op, int type, const Mat
|
||||
|
||||
namespace
|
||||
{
|
||||
class MorphologyFilterEngine_GPU : public Filter2DEngine_GPU
|
||||
{
|
||||
public:
|
||||
class MorphologyFilterEngine_GPU : public Filter2DEngine_GPU
|
||||
{
|
||||
public:
|
||||
MorphologyFilterEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_, int iters_) :
|
||||
Filter2DEngine_GPU(filter2D_), iters(iters_) {}
|
||||
|
||||
@ -523,7 +523,7 @@ namespace
|
||||
|
||||
int iters;
|
||||
oclMat morfBuf;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Ptr<FilterEngine_GPU> cv::ocl::createMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Point &anchor, int iterations)
|
||||
@ -539,8 +539,8 @@ Ptr<FilterEngine_GPU> cv::ocl::createMorphologyFilter_GPU(int op, int type, cons
|
||||
|
||||
namespace
|
||||
{
|
||||
void morphOp(int op, const oclMat &src, oclMat &dst, const Mat &_kernel, Point anchor, int iterations, int borderType, const Scalar &borderValue)
|
||||
{
|
||||
void morphOp(int op, const oclMat &src, oclMat &dst, const Mat &_kernel, Point anchor, int iterations, int borderType, const Scalar &borderValue)
|
||||
{
|
||||
if((borderType != cv::BORDER_CONSTANT) || (borderValue != morphologyDefaultBorderValue()))
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "unsupported border type");
|
||||
@ -577,7 +577,7 @@ namespace
|
||||
Ptr<FilterEngine_GPU> f = createMorphologyFilter_GPU(op, src.type(), kernel, anchor, iterations);
|
||||
|
||||
f->apply(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cv::ocl::erode( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor, int iterations,
|
||||
@ -645,11 +645,11 @@ void cv::ocl::morphologyEx( const oclMat &src, oclMat &dst, int op, const Mat &k
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef void (*GPUFilter2D_t)(const oclMat & , oclMat & , oclMat & , Size &, const Point, const int);
|
||||
typedef void (*GPUFilter2D_t)(const oclMat & , oclMat & , oclMat & , Size &, const Point, const int);
|
||||
|
||||
class LinearFilter_GPU : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
class LinearFilter_GPU : public BaseFilter_GPU
|
||||
{
|
||||
public:
|
||||
LinearFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUFilter2D_t func_,
|
||||
int borderType_) :
|
||||
BaseFilter_GPU(ksize_, anchor_, borderType_), kernel(kernel_), func(func_) {}
|
||||
@ -661,7 +661,7 @@ namespace
|
||||
|
||||
oclMat kernel;
|
||||
GPUFilter2D_t func;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel,
|
||||
@ -764,9 +764,9 @@ void cv::ocl::filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &ke
|
||||
|
||||
namespace
|
||||
{
|
||||
class SeparableFilterEngine_GPU : public FilterEngine_GPU
|
||||
{
|
||||
public:
|
||||
class SeparableFilterEngine_GPU : public FilterEngine_GPU
|
||||
{
|
||||
public:
|
||||
SeparableFilterEngine_GPU(const Ptr<BaseRowFilter_GPU> &rowFilter_,
|
||||
const Ptr<BaseColumnFilter_GPU> &columnFilter_) :
|
||||
rowFilter(rowFilter_), columnFilter(columnFilter_)
|
||||
@ -807,7 +807,7 @@ namespace
|
||||
oclMat srcROI;
|
||||
oclMat dstROI;
|
||||
oclMat dstBufROI;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Ptr<FilterEngine_GPU> cv::ocl::createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU> &rowFilter,
|
||||
@ -1107,11 +1107,11 @@ void cv::ocl::boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize,
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef void (*gpuFilter1D_t)(const oclMat &src, const oclMat &dst, oclMat kernel, int ksize, int anchor, int bordertype);
|
||||
typedef void (*gpuFilter1D_t)(const oclMat &src, const oclMat &dst, oclMat kernel, int ksize, int anchor, int bordertype);
|
||||
|
||||
class GpuLinearRowFilter : public BaseRowFilter_GPU
|
||||
{
|
||||
public:
|
||||
class GpuLinearRowFilter : public BaseRowFilter_GPU
|
||||
{
|
||||
public:
|
||||
GpuLinearRowFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) :
|
||||
BaseRowFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {}
|
||||
|
||||
@ -1122,7 +1122,7 @@ namespace
|
||||
|
||||
oclMat kernel;
|
||||
gpuFilter1D_t func;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T> struct index_and_sizeof;
|
||||
@ -1263,9 +1263,9 @@ Ptr<BaseRowFilter_GPU> cv::ocl::getLinearRowFilter_GPU(int srcType, int /*bufTyp
|
||||
|
||||
namespace
|
||||
{
|
||||
class GpuLinearColumnFilter : public BaseColumnFilter_GPU
|
||||
{
|
||||
public:
|
||||
class GpuLinearColumnFilter : public BaseColumnFilter_GPU
|
||||
{
|
||||
public:
|
||||
GpuLinearColumnFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) :
|
||||
BaseColumnFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {}
|
||||
|
||||
@ -1276,7 +1276,7 @@ namespace
|
||||
|
||||
oclMat kernel;
|
||||
gpuFilter1D_t func;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user