mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #16221 from TolyaTalamanov:at/fix-g_typed_kernel_m
G-API: Fix G_TYPED_KERNEL_M macro * Fix G_TYPED_KERNEL_M macro * Fixes * Fix windows build * Fix doxygen * Added several macros * Add overloads for G_TYPED_KERNEL
This commit is contained in:
parent
fb61f88b9c
commit
55f2370f36
@ -240,8 +240,13 @@ public:
|
||||
}; \
|
||||
//! @endcond
|
||||
|
||||
#define GET_G_TYPED_KERNEL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, NAME, ...) NAME
|
||||
#define COMBINE_SIGNATURE(...) __VA_ARGS__
|
||||
// Ensure correct __VA_ARGS__ expansion on Windows
|
||||
#define __WRAP_VAARGS(x) x
|
||||
|
||||
/**
|
||||
* Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* Helper for G_TYPED_KERNEL declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
@ -249,27 +254,118 @@ public:
|
||||
* return type is a single value.
|
||||
* @param Id string identifier for the operation. Must be unique.
|
||||
*/
|
||||
#define G_TYPED_KERNEL(Class, API, Id) \
|
||||
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelType<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
// {body} is to be defined by user
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_2(Class, _1, _2, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_3(Class, _1, _2, _3, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_4(Class, _1, _2, _3, _4, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_5(Class, _1, _2, _3, _4, _5, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_6(Class, _1, _2, _3, _4, _5, _6, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_7(Class, _1, _2, _3, _4, _5, _6, _7, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_8(Class, _1, _2, _3, _4, _5, _6, _7, _8, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_9(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_HELPER_10(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Id) \
|
||||
G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Id)
|
||||
|
||||
/**
|
||||
* Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
*/
|
||||
#define G_TYPED_KERNEL(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \
|
||||
G_TYPED_KERNEL_HELPER_10, \
|
||||
G_TYPED_KERNEL_HELPER_9, \
|
||||
G_TYPED_KERNEL_HELPER_8, \
|
||||
G_TYPED_KERNEL_HELPER_7, \
|
||||
G_TYPED_KERNEL_HELPER_6, \
|
||||
G_TYPED_KERNEL_HELPER_5, \
|
||||
G_TYPED_KERNEL_HELPER_4, \
|
||||
G_TYPED_KERNEL_HELPER_3, \
|
||||
G_TYPED_KERNEL_HELPER_2, \
|
||||
G_TYPED_KERNEL_HELPER)(Class, __VA_ARGS__)) \
|
||||
|
||||
/**
|
||||
* Helper for G_TYPED_KERNEL_M declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
* @param API an `std::function<>`-like signature for the operation;
|
||||
* return type is a tuple of multiple values.
|
||||
* @param Id string identifier for the operation. Must be unique.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_M(Class, API, Id) \
|
||||
#define G_TYPED_KERNEL_M_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelTypeM<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
// {body} is to be defined by user
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_2(Class, _1, _2, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_3(Class, _1, _2, _3, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_4(Class, _1, _2, _3, _4, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_5(Class, _1, _2, _3, _4, _5, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_6(Class, _1, _2, _3, _4, _5, _6, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_7(Class, _1, _2, _3, _4, _5, _6, _7, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_8(Class, _1, _2, _3, _4, _5, _6, _7, _8, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_9(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9), Id)
|
||||
|
||||
#define G_TYPED_KERNEL_M_HELPER_10(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Id) \
|
||||
G_TYPED_KERNEL_M_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Id)
|
||||
|
||||
/**
|
||||
* Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api)
|
||||
* for more details.
|
||||
*
|
||||
* @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_API_OP G_TYPED_KERNEL
|
||||
#define G_API_OP_M G_TYPED_KERNEL_M
|
||||
|
||||
|
@ -286,7 +286,7 @@ struct Mosaic
|
||||
* @brief Mosaic constructor
|
||||
*
|
||||
* @param mos_ Coordinates of the mosaic
|
||||
* @param cellSz_ Cell size (same for X, Y). Note: mos size must be multiple of cell size
|
||||
* @param cellSz_ Cell size (same for X, Y)
|
||||
* @param decim_ Decimation (0 stands for no decimation)
|
||||
*/
|
||||
Mosaic(const cv::Rect& mos_,
|
||||
@ -298,7 +298,7 @@ struct Mosaic
|
||||
|
||||
/*@{*/
|
||||
cv::Rect mos; //!< Coordinates of the mosaic
|
||||
int cellSz; //!< Cell size (same for X, Y). Note: mosaic size must be a multiple of cell size
|
||||
int cellSz; //!< Cell size (same for X, Y)
|
||||
int decim; //!< Decimation (0 stands for no decimation)
|
||||
/*@{*/
|
||||
};
|
||||
|
@ -11,9 +11,6 @@
|
||||
#include <ade/util/iota_range.hpp>
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <opencv2/gapi/plaidml/core.hpp>
|
||||
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
@ -44,6 +41,27 @@ namespace
|
||||
out = in.clone();
|
||||
}
|
||||
};
|
||||
|
||||
// These definitons test the correct macro work if the kernel has multiple output values
|
||||
G_TYPED_KERNEL(GRetGArrayTupleOfGMat2Kernel, <GArray<std::tuple<GMat, GMat>>(GMat, Scalar)>, "org.opencv.test.retarrayoftupleofgmat2kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat3Kernel, <GArray<std::tuple<GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat3kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat4Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat4kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat5Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat5kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat6Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat6kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat7Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat7kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat8Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat8kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat9Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat9kernel") {};
|
||||
G_TYPED_KERNEL(GRetGArraTupleyOfGMat10Kernel, <GArray<std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>>(GMat)>, "org.opencv.test.retarrayoftupleofgmat10kernel") {};
|
||||
|
||||
G_TYPED_KERNEL_M(GRetGMat2Kernel, <std::tuple<GMat, GMat>(GMat, GMat, GMat)>, "org.opencv.test.retgmat2kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat3Kernel, <std::tuple<GMat, GMat, GMat>(GMat, GScalar)>, "org.opencv.test.retgmat3kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat4Kernel, <std::tuple<GMat, GMat, GMat, GMat>(GMat, GArray<int>, GScalar)>, "org.opencv.test.retgmat4kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat5Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat5kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat6Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat6kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat7Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat7kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat8Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat8kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat9Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat9kernel") {};
|
||||
G_TYPED_KERNEL_M(GRetGMat10Kernel, <std::tuple<GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat, GMat>(GMat)>, "org.opencv.test.retgmat10kernel") {};
|
||||
}
|
||||
|
||||
TEST(GAPI_Pipeline, OverloadUnary_MatMat)
|
||||
|
Loading…
Reference in New Issue
Block a user