mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #21041 from sivanov-work:gin_gout_concept
G-API: GAPI introduce compile guard for some types for gin/gout params passing * Initial for taged solution * Move out tags to gtags.hpp & add protection for own::Mat * Add compile guard to proper place * Fix MACRO concat * Add unit tests * Remove class MACRO injection due to Python3 * Revert back unproper changes * Apply comments: reuse shape from traits * Throw away unused gtags * Apply comments * Handle own::* * Fix test * Fix test(1) * Fix unix build * Try on type list * Apply comments * Apply comments * Fix warning
This commit is contained in:
@@ -19,11 +19,25 @@
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/gapi/media.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include <opencv2/gapi/util/util.hpp>
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename, typename = void>
|
||||
struct contains_shape_field : std::false_type {};
|
||||
|
||||
template<typename TaggedTypeCandidate>
|
||||
struct contains_shape_field<TaggedTypeCandidate,
|
||||
void_t<decltype(TaggedTypeCandidate::shape)>> :
|
||||
std::is_same<typename std::decay<decltype(TaggedTypeCandidate::shape)>::type, GShape>
|
||||
{};
|
||||
|
||||
template<typename Type>
|
||||
struct has_gshape : contains_shape_field<Type> {};
|
||||
|
||||
// FIXME: These traits and enum and possible numerous switch(kind)
|
||||
// block may be replaced with a special Handler<T> object or with
|
||||
// a double dispatch
|
||||
@@ -181,10 +195,16 @@ namespace detail
|
||||
}
|
||||
template<typename U> static auto wrap_in (const U &u) -> typename GTypeTraits<T>::strip_type
|
||||
{
|
||||
static_assert(!(cv::detail::has_gshape<GTypeTraits<U>>::value
|
||||
|| cv::detail::contains<typename std::decay<U>::type, GAPI_OWN_TYPES_LIST>::value),
|
||||
"gin/gout must not be used with G* classes or cv::gapi::own::*");
|
||||
return GTypeTraits<T>::wrap_in(u);
|
||||
}
|
||||
template<typename U> static auto wrap_out(U &u) -> typename GTypeTraits<T>::strip_type
|
||||
{
|
||||
static_assert(!(cv::detail::has_gshape<GTypeTraits<U>>::value
|
||||
|| cv::detail::contains<typename std::decay<U>::type, GAPI_OWN_TYPES_LIST>::value),
|
||||
"gin/gout must not be used with G* classses or cv::gapi::own::*");
|
||||
return GTypeTraits<T>::wrap_out(u);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
# include <opencv2/core/cvdef.h>
|
||||
# include <opencv2/core/types.hpp>
|
||||
# include <opencv2/core/base.hpp>
|
||||
#define GAPI_OWN_TYPES_LIST cv::gapi::own::Rect, \
|
||||
cv::gapi::own::Size, \
|
||||
cv::gapi::own::Point, \
|
||||
cv::gapi::own::Point2f, \
|
||||
cv::gapi::own::Scalar, \
|
||||
cv::gapi::own::Mat
|
||||
#else // Without OpenCV
|
||||
# include <opencv2/gapi/own/cvdefs.hpp>
|
||||
# include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Rect/Size/Point
|
||||
@@ -28,6 +34,8 @@ namespace cv {
|
||||
using Scalar = gapi::own::Scalar;
|
||||
using Mat = gapi::own::Mat;
|
||||
} // namespace cv
|
||||
#define GAPI_OWN_TYPES_LIST cv::gapi::own::VoidType
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP
|
||||
|
||||
@@ -143,6 +143,7 @@ inline std::ostream& operator<<(std::ostream& o, const Size& s)
|
||||
return o;
|
||||
}
|
||||
|
||||
struct VoidType {};
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
@@ -116,6 +116,13 @@ namespace detail
|
||||
using type = std::tuple<Objs...>;
|
||||
static type get(std::tuple<Objs...>&& objs) { return std::forward<std::tuple<Objs...>>(objs); }
|
||||
};
|
||||
|
||||
template<typename... Ts>
|
||||
struct make_void { typedef void type;};
|
||||
|
||||
template<typename... Ts>
|
||||
using void_t = typename make_void<Ts...>::type;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
namespace util
|
||||
|
||||
Reference in New Issue
Block a user