// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // Copyright (C) 2018 Intel Corporation #ifndef OPENCV_GAPI_GARG_HPP #define OPENCV_GAPI_GARG_HPP #include #include #include #include "opencv2/gapi/own/mat.hpp" #include "opencv2/gapi/util/any.hpp" #include "opencv2/gapi/util/variant.hpp" #include "opencv2/gapi/gmat.hpp" #include "opencv2/gapi/gscalar.hpp" #include "opencv2/gapi/garray.hpp" #include "opencv2/gapi/gtype_traits.hpp" #include "opencv2/gapi/gmetaarg.hpp" #include "opencv2/gapi/own/scalar.hpp" namespace cv { class GArg; namespace detail { template using is_garg = std::is_same::type>; } // Parameter holder class for a node // Depending on platform capabilities, can either support arbitrary types // (as `boost::any`) or a limited number of types (as `boot::variant`). // FIXME: put into "details" as a user shouldn't use it in his code class GAPI_EXPORTS GArg { public: GArg() {} template::value, int>::type = 0> explicit GArg(const T &t) : kind(detail::GTypeTraits::kind) , value(detail::wrap_gapi_helper::wrap(t)) { } template::value, int>::type = 0> explicit GArg(T &&t) : kind(detail::GTypeTraits::type>::kind) , value(detail::wrap_gapi_helper::wrap(t)) { } template inline T& get() { return util::any_cast::type>(value); } template inline const T& get() const { return util::any_cast::type>(value); } template inline T& unsafe_get() { return util::unsafe_any_cast::type>(value); } template inline const T& unsafe_get() const { return util::unsafe_any_cast::type>(value); } detail::ArgKind kind = detail::ArgKind::OPAQUE; protected: util::any value; }; using GArgs = std::vector; // FIXME: Express as M::type // FIXME: Move to a separate file! using GRunArg = util::variant< #if !defined(GAPI_STANDALONE) cv::Mat, cv::Scalar, cv::UMat, #endif // !defined(GAPI_STANDALONE) cv::gapi::own::Mat, cv::gapi::own::Scalar, cv::detail::VectorRef >; using GRunArgs = std::vector; using GRunArgP = util::variant< #if !defined(GAPI_STANDALONE) cv::Mat*, cv::Scalar*, cv::UMat*, #endif // !defined(GAPI_STANDALONE) cv::gapi::own::Mat*, cv::gapi::own::Scalar*, cv::detail::VectorRef >; using GRunArgsP = std::vector; template inline GRunArgs gin(const Ts&... args) { return GRunArgs{ GRunArg(detail::wrap_host_helper::wrap_in(args))... }; } template inline GRunArgsP gout(Ts&... args) { return GRunArgsP{ GRunArgP(detail::wrap_host_helper::wrap_out(args))... }; } } // namespace cv #endif // OPENCV_GAPI_GARG_HPP