diff --git a/modules/gapi/include/opencv2/gapi/gkernel.hpp b/modules/gapi/include/opencv2/gapi/gkernel.hpp index b7ff883c66..9e1704a68b 100644 --- a/modules/gapi/include/opencv2/gapi/gkernel.hpp +++ b/modules/gapi/include/opencv2/gapi/gkernel.hpp @@ -228,6 +228,20 @@ public: } }; +namespace detail { +// This tiny class eliminates the semantic difference between +// GKernelType and GKernelTypeM. +template class KernelTypeMedium; + +template +class KernelTypeMedium(Args...)>> : + public cv::GKernelTypeM(Args...)>> {}; + +template +class KernelTypeMedium> : + public cv::GKernelType> {}; +} // namespace detail + } // namespace cv @@ -256,12 +270,12 @@ public: * * @param Class type name for this operation. * @param API an `std::function<>`-like signature for the operation; - * return type is a single value. + * return type is a single value or a tuple of multiple values. * @param Id string identifier for the operation. Must be unique. */ -#define G_TYPED_KERNEL_HELPER(Class, API, Id) \ - G_ID_HELPER_BODY(Class, Id) \ - struct Class final: public cv::GKernelType, \ +#define G_TYPED_KERNEL_HELPER(Class, API, Id) \ + G_ID_HELPER_BODY(Class, Id) \ + struct Class final: public cv::detail::KernelTypeMedium, \ public G_ID_HELPER_CLASS(Class) // {body} is to be defined by user @@ -319,10 +333,7 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _ * return type is a tuple of multiple values. * @param Id string identifier for the operation. Must be unique. */ -#define G_TYPED_KERNEL_M_HELPER(Class, API, Id) \ - G_ID_HELPER_BODY(Class, Id) \ - struct Class final: public cv::GKernelTypeM, \ - public G_ID_HELPER_CLASS(Class) +#define G_TYPED_KERNEL_M_HELPER G_TYPED_KERNEL_HELPER // {body} is to be defined by user #define G_TYPED_KERNEL_M_HELPER_2(Class, _1, _2, Id) \ @@ -358,21 +369,10 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _ * * @param Class type name for this operation. */ -#define G_TYPED_KERNEL_M(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \ - G_TYPED_KERNEL_M_HELPER_10, \ - G_TYPED_KERNEL_M_HELPER_9, \ - G_TYPED_KERNEL_M_HELPER_8, \ - G_TYPED_KERNEL_M_HELPER_7, \ - G_TYPED_KERNEL_M_HELPER_6, \ - G_TYPED_KERNEL_M_HELPER_5, \ - G_TYPED_KERNEL_M_HELPER_4, \ - G_TYPED_KERNEL_M_HELPER_3, \ - G_TYPED_KERNEL_M_HELPER_2, \ - G_TYPED_KERNEL_M_HELPER)(Class, __VA_ARGS__)) \ -// {body} is to be defined by user +#define G_TYPED_KERNEL_M G_TYPED_KERNEL #define G_API_OP G_TYPED_KERNEL -#define G_API_OP_M G_TYPED_KERNEL_M +#define G_API_OP_M G_API_OP namespace cv { diff --git a/modules/gapi/include/opencv2/gapi/infer.hpp b/modules/gapi/include/opencv2/gapi/infer.hpp index a6ffb7a9ff..5a4caff1f3 100644 --- a/modules/gapi/include/opencv2/gapi/infer.hpp +++ b/modules/gapi/include/opencv2/gapi/infer.hpp @@ -23,23 +23,6 @@ namespace cv { -namespace detail { - // This tiny class eliminates the semantic difference between - // GKernelType and GKernelTypeM. - // FIXME: Something similar can be reused for regular kernels - template - struct KernelTypeMedium; - - template - struct KernelTypeMedium(Args...)> >: - public GKernelTypeM(Args...)> > {}; - - template - struct KernelTypeMedium >: - public GKernelType > {}; - -} // namespace detail - template class GNetworkType; // TODO: maybe tuple_wrap_helper from util.hpp may help with this.