1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
5 // Copyright (C) 2018-2019 Intel Corporation
8 #ifndef OPENCV_GAPI_GMETAARG_HPP
9 #define OPENCV_GAPI_GMETAARG_HPP
12 #include <type_traits>
14 #include "opencv2/gapi/util/util.hpp"
15 #include "opencv2/gapi/util/variant.hpp"
17 #include "opencv2/gapi/gmat.hpp"
18 #include "opencv2/gapi/gscalar.hpp"
19 #include "opencv2/gapi/garray.hpp"
23 // FIXME: Rename to GMeta?
24 // FIXME: user shouldn't deal with it - put to detail?
25 // GMetaArg is an union type over descriptions of G-types which can serve as
26 // GComputation's in/output slots.
28 // GMetaArg objects are passed as arguments to GComputation::compile()
29 // to specify which data a compiled computation should be specialized on.
30 // For manual compile(), user must supply this metadata, in case of apply()
31 // this metadata is taken from arguments computation should operate on.
33 // The first type (monostate) is equal to "uninitialized"/"unresolved" meta.
34 using GMetaArg = util::variant
40 GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &);
42 using GMetaArgs = std::vector<GMetaArg>;
46 // These traits are used by GComputation::compile()
48 // FIXME: is_constructible<T> doesn't work as variant doesn't do any SFINAE
49 // in its current template constructor
51 template<typename T> struct is_meta_descr : std::false_type {};
52 template<> struct is_meta_descr<GMatDesc> : std::true_type {};
53 template<> struct is_meta_descr<GScalarDesc> : std::true_type {};
54 template<> struct is_meta_descr<GArrayDesc> : std::true_type {};
56 template<typename... Ts>
57 using are_meta_descrs = all_satisfy<is_meta_descr, Ts...>;
59 template<typename... Ts>
60 using are_meta_descrs_but_last = all_satisfy<is_meta_descr, typename all_but_last<Ts...>::type>;
66 GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::Mat> &vec);
67 GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::UMat> &vec);
68 namespace gapi { namespace own {
70 GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<Mat> &vec);
71 }} // namespace gapi::own
75 #endif // OPENCV_GAPI_GMETAARG_HPP