From 058f93d9e802dff57be0b731926a17291160654b Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Tue, 11 Oct 2016 12:13:41 +0300 Subject: [PATCH] OpenVX based implementation for integral image HAL API. --- 3rdparty/openvx/include/openvx_hal.hpp | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/3rdparty/openvx/include/openvx_hal.hpp b/3rdparty/openvx/include/openvx_hal.hpp index 100c14938c..ba95b802d7 100644 --- a/3rdparty/openvx/include/openvx_hal.hpp +++ b/3rdparty/openvx/include/openvx_hal.hpp @@ -100,6 +100,24 @@ struct VX_Traits }; }; +template <> +struct VX_Traits +{ + enum { + ImgType = VX_DF_IMAGE_U32, + DataType = VX_TYPE_UINT32 + }; +}; + +template <> +struct VX_Traits +{ + enum { + ImgType = VX_DF_IMAGE_S32, + DataType = VX_TYPE_INT32 + }; +}; + template <> struct VX_Traits { @@ -1018,6 +1036,32 @@ inline int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, return CV_HAL_ERROR_OK; } +inline int ovx_hal_integral(int depth, int sdepth, int , const uchar * a, size_t astep, uchar * b, size_t bstep, uchar * c, size_t , uchar * d, size_t , int w, int h, int cn) +{ + if (depth != CV_8U || sdepth != CV_32S || c != NULL || d != NULL || cn != 1) + return CV_HAL_ERROR_NOT_IMPLEMENTED; + + try + { + vxContext * ctx = vxContext::getContext(); + vxImage ia(*ctx, a, astep, w, h); + vxImage ib(*ctx, (unsigned int *)(b+bstep+sizeof(unsigned int)), bstep, w, h); + vxErr::check(vxuIntegralImage(ctx->ctx, ia.img, ib.img)); + memset(b, 0, (w+1)*sizeof(unsigned int)); + b += bstep; + for (int i = 0; i < h; i++, b += bstep) + { + *((unsigned int*)b) = 0; + } + } + catch (vxErr & e) + { + e.print(); + return CV_HAL_ERROR_UNKNOWN; + } + return CV_HAL_ERROR_OK; +} + //================================================================================================== // functions redefinition // ... @@ -1096,5 +1140,7 @@ inline int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, #define cv_hal_cvtBGRtoThreePlaneYUV ovx_hal_cvtBGRtoThreePlaneYUV #undef cv_hal_cvtOnePlaneYUVtoBGR #define cv_hal_cvtOnePlaneYUVtoBGR ovx_hal_cvtOnePlaneYUVtoBGR +#undef cv_hal_integral +#define cv_hal_integral ovx_hal_integral #endif