Skip to content

Commit cb9e110

Browse files
author
elenagvo
committed
add HAL for BoxFilter
1 parent 800294a commit cb9e110

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

modules/imgproc/src/hal_replacement.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,25 @@ inline int hal_ni_threshold(const uchar* src_data, size_t src_step, uchar* dst_d
664664
#define cv_hal_threshold hal_ni_threshold
665665
//! @endcond
666666

667+
/**
668+
@brief Calculate box filter
669+
@param src_depth, dst_depth Depths of source and destination image
670+
@param src_data, src_step Source image
671+
@param dst_data, dst_step Destination image
672+
@param ksize Size of kernel
673+
@param anchor Anchor point
674+
@param normalize If true then result is normalized
675+
@param border_type Border type
676+
@param margins Margins for source image
677+
@param width, height Source image dimensions
678+
@param cn Number of channels
679+
*/
680+
inline int hal_ni_boxFilter(int src_depth, int dst_depth, const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, CvSize ksize, CvPoint anchor, bool normalize, int border_type, CvRect margins, int width, int height, int cn) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
681+
682+
//! @cond IGNORED
683+
#define cv_hal_boxFilter hal_ni_boxFilter
684+
//! @endcond
685+
667686
//! @}
668687

669688
#if defined __GNUC__

modules/imgproc/src/smooth.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,19 +1552,25 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
15521552
if( src.cols == 1 )
15531553
ksize.width = 1;
15541554
}
1555-
#ifdef HAVE_TEGRA_OPTIMIZATION
1556-
if ( tegra::useTegra() && tegra::box(src, dst, ksize, anchor, normalize, borderType) )
1557-
return;
1558-
#endif
1559-
1560-
CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType));
15611555

15621556
Point ofs;
15631557
Size wsz(src.cols, src.rows);
15641558
if(!(borderType&BORDER_ISOLATED))
15651559
src.locateROI( wsz, ofs );
15661560
borderType = (borderType&~BORDER_ISOLATED);
15671561

1562+
CvRect margin = cvRect(ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y);
1563+
1564+
CALL_HAL(boxFilter, cv_hal_boxFilter, sdepth, ddepth, src.ptr(), src.step, dst.ptr(), dst.step,
1565+
(CvSize)(ksize), (CvPoint)(anchor), normalize, borderType, margin, src.cols, src.rows, cn);
1566+
1567+
#ifdef HAVE_TEGRA_OPTIMIZATION
1568+
if ( tegra::useTegra() && tegra::box(src, dst, ksize, anchor, normalize, borderType) )
1569+
return;
1570+
#endif
1571+
1572+
CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType));
1573+
15681574
Ptr<FilterEngine> f = createBoxFilter( src.type(), dst.type(),
15691575
ksize, anchor, normalize, borderType );
15701576

0 commit comments

Comments
 (0)