Commit 9060365f authored by yao's avatar yao Committed by Andrey Kamaev

use format on filtering.cpp

parent 56c1a7fa
...@@ -170,53 +170,53 @@ void cv::ocl::morphologyEx( const oclMat &, oclMat &, int, const Mat &, Point, i ...@@ -170,53 +170,53 @@ void cv::ocl::morphologyEx( const oclMat &, oclMat &, int, const Mat &, Point, i
//helper routines //helper routines
namespace cv namespace cv
{ {
namespace ocl namespace ocl
{ {
///////////////////////////OpenCL kernel strings/////////////////////////// ///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *filtering_boxFilter; extern const char *filtering_boxFilter;
extern const char *filter_sep_row; extern const char *filter_sep_row;
extern const char *filter_sep_col; extern const char *filter_sep_col;
extern const char *filtering_laplacian; extern const char *filtering_laplacian;
extern const char *filtering_morph; extern const char *filtering_morph;
} }
} }
namespace namespace
{ {
inline int divUp(int total, int grain) inline int divUp(int total, int grain)
{ {
return (total + grain - 1) / grain; return (total + grain - 1) / grain;
} }
} }
namespace namespace
{ {
inline void normalizeAnchor(int &anchor, int ksize) inline void normalizeAnchor(int &anchor, int ksize)
{ {
if (anchor < 0) if (anchor < 0)
anchor = ksize >> 1; anchor = ksize >> 1;
CV_Assert(0 <= anchor && anchor < ksize); 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.x, ksize.width);
normalizeAnchor(anchor.y, ksize.height); 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)) if (roi == Rect(0, 0, -1, -1))
roi = Rect(0, 0, src_size.width, src_size.height); 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(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((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); 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; int scale = nDivisor && (kernel.depth() == CV_32F || kernel.depth() == CV_64F) ? 256 : 1;
if (nDivisor) *nDivisor = scale; if (nDivisor) *nDivisor = scale;
...@@ -234,16 +234,16 @@ namespace ...@@ -234,16 +234,16 @@ namespace
} }
gpu_krnl.upload(cont_krnl); gpu_krnl.upload(cont_krnl);
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Filter2D // Filter2D
namespace namespace
{ {
class Filter2DEngine_GPU : public FilterEngine_GPU class Filter2DEngine_GPU : public FilterEngine_GPU
{ {
public: public:
Filter2DEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_) : filter2D(filter2D_) {} Filter2DEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_) : filter2D(filter2D_) {}
virtual void apply(const oclMat &src, oclMat &dst, Rect roi = Rect(0, 0, -1, -1)) virtual void apply(const oclMat &src, oclMat &dst, Rect roi = Rect(0, 0, -1, -1))
...@@ -263,7 +263,7 @@ namespace ...@@ -263,7 +263,7 @@ namespace
} }
Ptr<BaseFilter_GPU> filter2D; Ptr<BaseFilter_GPU> filter2D;
}; };
} }
Ptr<FilterEngine_GPU> cv::ocl::createFilter2D_GPU(const 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 ...@@ -275,11 +275,11 @@ Ptr<FilterEngine_GPU> cv::ocl::createFilter2D_GPU(const Ptr<BaseFilter_GPU> filt
// Box Filter // Box Filter
namespace 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 class GPUBoxFilter : public BaseFilter_GPU
{ {
public: public:
GPUBoxFilter(const Size &ksize_, const Point &anchor_, const int borderType_, FilterBox_t func_) : GPUBoxFilter(const Size &ksize_, const Point &anchor_, const int borderType_, FilterBox_t func_) :
BaseFilter_GPU(ksize_, anchor_, borderType_), func(func_) {} BaseFilter_GPU(ksize_, anchor_, borderType_), func(func_) {}
...@@ -290,7 +290,7 @@ namespace ...@@ -290,7 +290,7 @@ namespace
FilterBox_t func; FilterBox_t func;
}; };
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -298,11 +298,11 @@ namespace ...@@ -298,11 +298,11 @@ namespace
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 class MorphFilter_GPU : public BaseFilter_GPU
{ {
public: public:
MorphFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUMorfFilter_t func_) : MorphFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUMorfFilter_t func_) :
BaseFilter_GPU(ksize_, anchor_, BORDER_CONSTANT), kernel(kernel_), func(func_) {} BaseFilter_GPU(ksize_, anchor_, BORDER_CONSTANT), kernel(kernel_), func(func_) {}
...@@ -313,7 +313,7 @@ namespace ...@@ -313,7 +313,7 @@ namespace
oclMat kernel; oclMat kernel;
GPUMorfFilter_t func; GPUMorfFilter_t func;
}; };
} }
/* /*
...@@ -483,9 +483,9 @@ Ptr<BaseFilter_GPU> cv::ocl::getMorphologyFilter_GPU(int op, int type, const Mat ...@@ -483,9 +483,9 @@ Ptr<BaseFilter_GPU> cv::ocl::getMorphologyFilter_GPU(int op, int type, const Mat
namespace namespace
{ {
class MorphologyFilterEngine_GPU : public Filter2DEngine_GPU class MorphologyFilterEngine_GPU : public Filter2DEngine_GPU
{ {
public: public:
MorphologyFilterEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_, int iters_) : MorphologyFilterEngine_GPU(const Ptr<BaseFilter_GPU> &filter2D_, int iters_) :
Filter2DEngine_GPU(filter2D_), iters(iters_) {} Filter2DEngine_GPU(filter2D_), iters(iters_) {}
...@@ -523,7 +523,7 @@ namespace ...@@ -523,7 +523,7 @@ namespace
int iters; int iters;
oclMat morfBuf; oclMat morfBuf;
}; };
} }
Ptr<FilterEngine_GPU> cv::ocl::createMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Point &anchor, int iterations) 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 ...@@ -539,8 +539,8 @@ Ptr<FilterEngine_GPU> cv::ocl::createMorphologyFilter_GPU(int op, int type, cons
namespace 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())) if((borderType != cv::BORDER_CONSTANT) || (borderValue != morphologyDefaultBorderValue()))
{ {
CV_Error(CV_StsBadArg, "unsupported border type"); CV_Error(CV_StsBadArg, "unsupported border type");
...@@ -577,7 +577,7 @@ namespace ...@@ -577,7 +577,7 @@ namespace
Ptr<FilterEngine_GPU> f = createMorphologyFilter_GPU(op, src.type(), kernel, anchor, iterations); Ptr<FilterEngine_GPU> f = createMorphologyFilter_GPU(op, src.type(), kernel, anchor, iterations);
f->apply(src, dst); f->apply(src, dst);
} }
} }
void cv::ocl::erode( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor, int iterations, 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 ...@@ -645,11 +645,11 @@ void cv::ocl::morphologyEx( const oclMat &src, oclMat &dst, int op, const Mat &k
namespace 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 class LinearFilter_GPU : public BaseFilter_GPU
{ {
public: public:
LinearFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUFilter2D_t func_, LinearFilter_GPU(const Size &ksize_, const Point &anchor_, const oclMat &kernel_, GPUFilter2D_t func_,
int borderType_) : int borderType_) :
BaseFilter_GPU(ksize_, anchor_, borderType_), kernel(kernel_), func(func_) {} BaseFilter_GPU(ksize_, anchor_, borderType_), kernel(kernel_), func(func_) {}
...@@ -661,7 +661,7 @@ namespace ...@@ -661,7 +661,7 @@ namespace
oclMat kernel; oclMat kernel;
GPUFilter2D_t func; GPUFilter2D_t func;
}; };
} }
void GPUFilter2D(const oclMat &src, oclMat &dst, oclMat &mat_kernel, 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 ...@@ -764,9 +764,9 @@ void cv::ocl::filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &ke
namespace namespace
{ {
class SeparableFilterEngine_GPU : public FilterEngine_GPU class SeparableFilterEngine_GPU : public FilterEngine_GPU
{ {
public: public:
SeparableFilterEngine_GPU(const Ptr<BaseRowFilter_GPU> &rowFilter_, SeparableFilterEngine_GPU(const Ptr<BaseRowFilter_GPU> &rowFilter_,
const Ptr<BaseColumnFilter_GPU> &columnFilter_) : const Ptr<BaseColumnFilter_GPU> &columnFilter_) :
rowFilter(rowFilter_), columnFilter(columnFilter_) rowFilter(rowFilter_), columnFilter(columnFilter_)
...@@ -807,7 +807,7 @@ namespace ...@@ -807,7 +807,7 @@ namespace
oclMat srcROI; oclMat srcROI;
oclMat dstROI; oclMat dstROI;
oclMat dstBufROI; oclMat dstBufROI;
}; };
} }
Ptr<FilterEngine_GPU> cv::ocl::createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU> &rowFilter, 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, ...@@ -1107,11 +1107,11 @@ void cv::ocl::boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize,
namespace 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 class GpuLinearRowFilter : public BaseRowFilter_GPU
{ {
public: public:
GpuLinearRowFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) : GpuLinearRowFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) :
BaseRowFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {} BaseRowFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {}
...@@ -1122,7 +1122,7 @@ namespace ...@@ -1122,7 +1122,7 @@ namespace
oclMat kernel; oclMat kernel;
gpuFilter1D_t func; gpuFilter1D_t func;
}; };
} }
template <typename T> struct index_and_sizeof; template <typename T> struct index_and_sizeof;
...@@ -1263,9 +1263,9 @@ Ptr<BaseRowFilter_GPU> cv::ocl::getLinearRowFilter_GPU(int srcType, int /*bufTyp ...@@ -1263,9 +1263,9 @@ Ptr<BaseRowFilter_GPU> cv::ocl::getLinearRowFilter_GPU(int srcType, int /*bufTyp
namespace namespace
{ {
class GpuLinearColumnFilter : public BaseColumnFilter_GPU class GpuLinearColumnFilter : public BaseColumnFilter_GPU
{ {
public: public:
GpuLinearColumnFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) : GpuLinearColumnFilter(int ksize_, int anchor_, const oclMat &kernel_, gpuFilter1D_t func_, int bordertype_) :
BaseColumnFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {} BaseColumnFilter_GPU(ksize_, anchor_, bordertype_), kernel(kernel_), func(func_) {}
...@@ -1276,7 +1276,7 @@ namespace ...@@ -1276,7 +1276,7 @@ namespace
oclMat kernel; oclMat kernel;
gpuFilter1D_t func; gpuFilter1D_t func;
}; };
} }
template <typename T> template <typename T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment