Commit 27abd4d3 authored by Maksim Shabunin's avatar Maksim Shabunin

Filter2D HAL interface

parent 88a33a4e
#ifndef CV_IMGPROC_HAL_HPP
#define CV_IMGPROC_HAL_HPP
#include "opencv2/core/cvdef.h"
#include "opencv2/core/hal/interface.h"
namespace cv { namespace hal {
//! @addtogroup core_hal_functions
//! @{
struct FilterContext
{
void * impl;
FilterContext() : impl(0) {}
};
CV_EXPORTS
void init_filter2d(FilterContext &c,
uchar * kernel_data, size_t kernel_step, int kernel_type,
int kernel_width, int kernel_height,
int max_width, int max_height,
int stype, int dtype,
int borderType, double delta, int anchor_x, int anchor_y, bool isSubmatrix, bool isInplace);
CV_EXPORTS
void filter2d(FilterContext & c, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step,
int width, int height, int full_width, int full_height, int offset_x, int offset_y);
CV_EXPORTS
void free_filter2d(FilterContext & c);
CV_EXPORTS
void init_sepFilter2d(FilterContext & c, int stype, int dtype, int ktype,
uchar * kernelx_data, size_t kernelx_step, int kernelx_width, int kernelx_height,
uchar * kernely_data, size_t kernely_step, int kernely_width, int kernely_height,
int anchor_x, int anchor_y, double delta, int borderType);
CV_EXPORTS
void sepFilter2d(FilterContext & c, uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
int width, int height, int full_width, int full_height,
int offset_x, int offset_y);
CV_EXPORTS
void free_sepFilter2d(FilterContext & c);
//! @}
}}
#endif // CV_IMGPROC_HAL_HPP
......@@ -856,8 +856,12 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
wtype, ks, kd, Point(-1,-1), 0, borderType, borderType, Scalar() );
Mat src = _src.getMat(), dst = _dst.getMat();
int y = fx->start(src), dsty = 0, dy = 0;
fy->start(src);
Point ofs;
Size wsz(src.cols, src.rows);
src.locateROI( wsz, ofs );
int y = fx->start(src, wsz, ofs), dsty = 0, dy = 0;
fy->start(src, wsz, ofs);
const uchar* sptr = src.ptr() + src.step[0] * y;
int dy0 = std::min(std::max((int)(STRIPE_SIZE/(CV_ELEM_SIZE(stype)*src.cols)), 1), src.rows);
......
This diff is collapsed.
......@@ -228,19 +228,17 @@ public:
int _rowBorderType = BORDER_REPLICATE,
int _columnBorderType = -1,
const Scalar& _borderValue = Scalar());
//! starts filtering of the specified ROI of an image of size wholeSize.
virtual int start(Size wholeSize, Rect roi, int maxBufRows = -1);
virtual int start(const cv::Size &wholeSize, const cv::Size &sz, const cv::Point &ofs);
//! starts filtering of the specified ROI of the specified image.
virtual int start(const Mat& src, const Rect& srcRoi = Rect(0,0,-1,-1),
bool isolated = false, int maxBufRows = -1);
virtual int start(const Mat& src, const cv::Size &wsz, const cv::Point &ofs);
//! processes the next srcCount rows of the image.
virtual int proceed(const uchar* src, int srcStep, int srcCount,
uchar* dst, int dstStep);
//! applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered.
virtual void apply( const Mat& src, Mat& dst,
const Rect& srcRoi = Rect(0,0,-1,-1),
Point dstOfs = Point(0,0),
bool isolated = false);
virtual void apply(const Mat& src, Mat& dst, const cv::Size &wsz, const cv::Point &ofs);
//! returns true if the filter is separable
bool isSeparable() const { return !filter2D; }
//! returns the number
......
#ifndef OPENCV_IMGPROC_HAL_REPLACEMENT_HPP
#define OPENCV_IMGPROC_HAL_REPLACEMENT_HPP
#include "opencv2/core/hal/interface.h"
inline int hal_ni_filterInit(void **, uchar *, size_t, int, int, int, int, int, int, int, int, double, int, int, bool, bool) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
inline int hal_ni_filter(void *, uchar *, size_t, uchar *, size_t, int, int, int, int, int, int) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
inline int hal_ni_filterFree(void *) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
#define cv_hal_filterInit hal_ni_filterInit
#define cv_hal_filter hal_ni_filter
#define cv_hal_filterFree hal_ni_filterFree
inline int hal_ni_sepFilterInit(void **, int, int, int, uchar *, size_t, int, int, uchar *, size_t, int, int, int, int, double, int) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
inline int hal_ni_sepFilter(void *, uchar *, size_t, uchar*, size_t, int, int, int, int, int, int) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
inline int hal_ni_sepFilterFree(void *) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
#define cv_hal_sepFilterInit hal_ni_sepFilterInit
#define cv_hal_sepFilter hal_ni_sepFilter
#define cv_hal_sepFilterFree hal_ni_sepFilterFree
#include "custom_hal.hpp"
#endif // OPENCV_IMGPROC_HAL_REPLACEMENT_HPP
......@@ -1117,9 +1117,22 @@ public:
Ptr<FilterEngine> f = createMorphologyFilter(op, src.type(), kernel, anchor,
rowBorderType, columnBorderType, borderValue );
f->apply( srcStripe, dstStripe );
for( int i = 1; i < iterations; i++ )
f->apply( dstStripe, dstStripe );
{
Point ofs;
Size wsz(srcStripe.cols, srcStripe.rows);
srcStripe.locateROI( wsz, ofs );
f->apply( srcStripe, dstStripe, wsz, ofs );
}
{
Point ofs;
Size wsz(dstStripe.cols, dstStripe.rows);
dstStripe.locateROI( wsz, ofs );
for( int i = 1; i < iterations; i++ )
f->apply( dstStripe, dstStripe, wsz, ofs );
}
}
private:
......
......@@ -50,6 +50,7 @@
#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/core/hal/hal.hpp"
#include "opencv2/imgproc/hal/hal.hpp"
#include <math.h>
#include <assert.h>
......
......@@ -1439,7 +1439,11 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
Ptr<FilterEngine> f = createBoxFilter( src.type(), dst.type(),
ksize, anchor, normalize, borderType );
f->apply( src, dst );
Point ofs;
Size wsz(src.cols, src.rows);
src.locateROI( wsz, ofs );
f->apply( src, dst, wsz, ofs );
}
......@@ -1561,7 +1565,11 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
Ptr<FilterEngine> f = makePtr<FilterEngine>(Ptr<BaseFilter>(), rowFilter, columnFilter,
srcType, dstType, sumType, borderType );
f->apply( src, dst );
Point ofs;
Size wsz(src.cols, src.rows);
src.locateROI( wsz, ofs );
f->apply( src, dst, wsz, ofs );
}
......
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