From 78b80b6abd12be0fdb71a9d7e73664b3fb82bd64 Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Tue, 29 Nov 2016 19:34:46 +0300 Subject: [PATCH] Added wrappers for OpenVX context attributes and setter for convolution scale attribute (#7732) --- 3rdparty/openvx/include/ivx.hpp | 148 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/3rdparty/openvx/include/ivx.hpp b/3rdparty/openvx/include/ivx.hpp index b813ac9..f47831d 100644 --- a/3rdparty/openvx/include/ivx.hpp +++ b/3rdparty/openvx/include/ivx.hpp @@ -696,6 +696,11 @@ protected: #endif // IVX_USE_EXTERNAL_REFCOUNT +#ifndef VX_VERSION_1_1 +//TODO: provide wrapper for border mode +typedef vx_border_mode_t vx_border_t; +#endif + /// vx_context wrapper class Context : public RefWrapper { @@ -719,6 +724,146 @@ public: /// vxLoadKernels() wrapper void loadKernels(const std::string& module) { IVX_CHECK_STATUS( vxLoadKernels(ref, module.c_str()) ); } + + /// vxQueryContext() wrapper + template + void query(vx_enum att, T& value) const + { IVX_CHECK_STATUS(vxQueryContext(ref, att, &value, sizeof(value))); } + +#ifndef VX_VERSION_1_1 + static const vx_enum + VX_CONTEXT_VENDOR_ID = VX_CONTEXT_ATTRIBUTE_VENDOR_ID, + VX_CONTEXT_VERSION = VX_CONTEXT_ATTRIBUTE_VERSION, + VX_CONTEXT_UNIQUE_KERNELS = VX_CONTEXT_ATTRIBUTE_UNIQUE_KERNELS, + VX_CONTEXT_MODULES = VX_CONTEXT_ATTRIBUTE_MODULES, + VX_CONTEXT_REFERENCES = VX_CONTEXT_ATTRIBUTE_REFERENCES, + VX_CONTEXT_IMPLEMENTATION = VX_CONTEXT_ATTRIBUTE_IMPLEMENTATION, + VX_CONTEXT_EXTENSIONS_SIZE = VX_CONTEXT_ATTRIBUTE_EXTENSIONS_SIZE, + VX_CONTEXT_EXTENSIONS = VX_CONTEXT_ATTRIBUTE_EXTENSIONS, + VX_CONTEXT_CONVOLUTION_MAX_DIMENSION = VX_CONTEXT_ATTRIBUTE_CONVOLUTION_MAXIMUM_DIMENSION, + VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION = VX_CONTEXT_ATTRIBUTE_OPTICAL_FLOW_WINDOW_MAXIMUM_DIMENSION, + VX_CONTEXT_IMMEDIATE_BORDER = VX_CONTEXT_ATTRIBUTE_IMMEDIATE_BORDER_MODE, + VX_CONTEXT_UNIQUE_KERNEL_TABLE = VX_CONTEXT_ATTRIBUTE_UNIQUE_KERNEL_TABLE; +#endif + + /// vxQueryContext(VX_CONTEXT_VENDOR_ID) wrapper + vx_uint16 vendorID() const + { + vx_uint16 v; + query(VX_CONTEXT_VENDOR_ID, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_VERSION) wrapper + vx_uint16 version() const + { + vx_uint16 v; + query(VX_CONTEXT_VERSION, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_UNIQUE_KERNELS) wrapper + vx_uint32 uniqueKernels() const + { + vx_uint32 v; + query(VX_CONTEXT_UNIQUE_KERNELS, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_MODULES) wrapper + vx_uint32 modules() const + { + vx_uint32 v; + query(VX_CONTEXT_MODULES, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_REFERENCES) wrapper + vx_uint32 references() const + { + vx_uint32 v; + query(VX_CONTEXT_REFERENCES, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_EXTENSIONS_SIZE) wrapper + vx_size extensionsSize() const + { + vx_size v; + query(VX_CONTEXT_EXTENSIONS_SIZE, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_CONVOLUTION_MAX_DIMENSION) wrapper + vx_size convolutionMaxDimension() const + { + vx_size v; + query(VX_CONTEXT_CONVOLUTION_MAX_DIMENSION, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION) wrapper + vx_size opticalFlowMaxWindowSize() const + { + vx_size v; + query(VX_CONTEXT_OPTICAL_FLOW_MAX_WINDOW_DIMENSION, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_IMMEDIATE_BORDER) wrapper + vx_border_t borderMode() const + { + vx_border_t v; + query(VX_CONTEXT_IMMEDIATE_BORDER, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_IMPLEMENTATION) wrapper + std::string implementation() const + { + std::vector v(VX_MAX_IMPLEMENTATION_NAME); + IVX_CHECK_STATUS(vxQueryContext(ref, VX_CONTEXT_IMPLEMENTATION, &v[0], v.size() * sizeof(vx_char))); + return std::string(v.data()); + } + + /// vxQueryContext(VX_CONTEXT_EXTENSIONS) wrapper + std::string extensions() const + { + std::vector v(extensionsSize()); + IVX_CHECK_STATUS(vxQueryContext(ref, VX_CONTEXT_EXTENSIONS, &v[0], v.size() * sizeof(vx_char))); + return std::string(v.data()); + } + + /// vxQueryContext(VX_CONTEXT_UNIQUE_KERNEL_TABLE) wrapper + std::vector kernelTable() const + { + std::vector v(uniqueKernels()); + IVX_CHECK_STATUS(vxQueryContext(ref, VX_CONTEXT_UNIQUE_KERNEL_TABLE, &v[0], v.size() * sizeof(vx_kernel_info_t))); + return v; + } + +#ifdef VX_VERSION_1_1 + /// vxQueryContext(VX_CONTEXT_IMMEDIATE_BORDER_POLICY) wrapper + vx_enum borderPolicy() const + { + vx_enum v; + query(VX_CONTEXT_IMMEDIATE_BORDER_POLICY, v); + return v; + } + + /// vxQueryContext(VX_CONTEXT_NONLINEAR_MAX_DIMENSION) wrapper + vx_size nonlinearMaxDimension() const + { + vx_size v; + query(VX_CONTEXT_NONLINEAR_MAX_DIMENSION, v); + return v; + } +#endif + + /// vxSetContextAttribute(VX_CONTEXT_IMMEDIATE_BORDER) wrapper + void setBorderMode(vx_border_t &border) + { IVX_CHECK_STATUS(vxSetContextAttribute(ref, VX_CONTEXT_IMMEDIATE_BORDER, &border, sizeof(border))); } + }; /// vx_graph wrapper @@ -1752,6 +1897,9 @@ public: return VX_TYPE_INT16; } + void setScale(vx_uint32 newScale) + { IVX_CHECK_STATUS( vxSetConvolutionAttribute(ref, VX_CONVOLUTION_SCALE, &newScale, sizeof(newScale)) ); } + void copyTo(void* data) { if (!data) throw WrapperError(std::string(__func__) + "(): output pointer is 0"); -- 2.7.4