@@ -228,6 +228,20 @@ class GKernelType<K, std::function<R(Args...)> >
228228 }
229229};
230230
231+ namespace detail {
232+ // This tiny class eliminates the semantic difference between
233+ // GKernelType and GKernelTypeM.
234+ template <typename , typename > class KernelTypeMedium ;
235+
236+ template <typename K, typename ... R, typename ... Args>
237+ class KernelTypeMedium <K, std::function<std::tuple<R...>(Args...)>> :
238+ public cv::GKernelTypeM<K, std::function<std::tuple<R...>(Args...)>> {};
239+
240+ template <typename K, typename R, typename ... Args>
241+ class KernelTypeMedium <K, std::function<R(Args...)>> :
242+ public cv::GKernelType<K, std::function<R(Args...)>> {};
243+ } // namespace detail
244+
231245} // namespace cv
232246
233247
@@ -256,12 +270,12 @@ class GKernelType<K, std::function<R(Args...)> >
256270 *
257271 * @param Class type name for this operation.
258272 * @param API an `std::function<>`-like signature for the operation;
259- * return type is a single value.
273+ * return type is a single value or a tuple of multiple values .
260274 * @param Id string identifier for the operation. Must be unique.
261275 */
262- #define G_TYPED_KERNEL_HELPER (Class, API, Id ) \
263- G_ID_HELPER_BODY (Class, Id) \
264- struct Class final : public cv::GKernelType <Class, std::function API >, \
276+ #define G_TYPED_KERNEL_HELPER (Class, API, Id ) \
277+ G_ID_HELPER_BODY (Class, Id) \
278+ struct Class final : public cv::detail::KernelTypeMedium <Class, std::function API >, \
265279 public G_ID_HELPER_CLASS(Class)
266280// {body} is to be defined by user
267281
@@ -319,10 +333,7 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _
319333 * return type is a tuple of multiple values.
320334 * @param Id string identifier for the operation. Must be unique.
321335 */
322- #define G_TYPED_KERNEL_M_HELPER (Class, API, Id ) \
323- G_ID_HELPER_BODY (Class, Id) \
324- struct Class final : public cv::GKernelTypeM<Class, std::function API >, \
325- public G_ID_HELPER_CLASS(Class)
336+ #define G_TYPED_KERNEL_M_HELPER G_TYPED_KERNEL_HELPER
326337// {body} is to be defined by user
327338
328339#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, _
358369 *
359370 * @param Class type name for this operation.
360371 */
361- #define G_TYPED_KERNEL_M (Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \
362- G_TYPED_KERNEL_M_HELPER_10, \
363- G_TYPED_KERNEL_M_HELPER_9, \
364- G_TYPED_KERNEL_M_HELPER_8, \
365- G_TYPED_KERNEL_M_HELPER_7, \
366- G_TYPED_KERNEL_M_HELPER_6, \
367- G_TYPED_KERNEL_M_HELPER_5, \
368- G_TYPED_KERNEL_M_HELPER_4, \
369- G_TYPED_KERNEL_M_HELPER_3, \
370- G_TYPED_KERNEL_M_HELPER_2, \
371- G_TYPED_KERNEL_M_HELPER)(Class, __VA_ARGS__)) \
372- // {body} is to be defined by user
372+ #define G_TYPED_KERNEL_M G_TYPED_KERNEL
373373
374374#define G_API_OP G_TYPED_KERNEL
375- #define G_API_OP_M G_TYPED_KERNEL_M
375+ #define G_API_OP_M G_API_OP
376376
377377namespace cv
378378{
0 commit comments