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_GPROTO_HPP
9 #define OPENCV_GAPI_GPROTO_HPP
11 #include <type_traits>
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"
20 #include "opencv2/gapi/garg.hpp"
21 #include "opencv2/gapi/gmetaarg.hpp"
25 // FIXME: user shouldn't deal with it - put to detail?
26 // GProtoArg is an union type over G-types which can serve as
27 // GComputation's in/output slots. In other words, GProtoArg
28 // wraps any type which can serve as G-API exchange type.
30 // In Runtime, GProtoArgs are substituted with appropriate GRunArgs.
32 // GProtoArg objects are constructed in-place when user describes
33 // (captures) computations, user doesn't interact with these types
35 using GProtoArg = util::variant
38 , detail::GArrayU // instead of GArray<T>
41 using GProtoArgs = std::vector<GProtoArg>;
45 template<typename... Ts> inline GProtoArgs packArgs(Ts... args)
47 return GProtoArgs{ GProtoArg(wrap_gapi_helper<Ts>::wrap(args))... };
56 explicit GIOProtoArgs(const GProtoArgs& args) : m_args(args) {}
57 explicit GIOProtoArgs(GProtoArgs &&args) : m_args(std::move(args)) {}
65 using GProtoInputArgs = GIOProtoArgs<In_Tag>;
66 using GProtoOutputArgs = GIOProtoArgs<Out_Tag>;
69 template<typename... Ts> inline GProtoInputArgs GIn(Ts&&... ts)
71 return GProtoInputArgs(detail::packArgs(std::forward<Ts>(ts)...));
74 template<typename... Ts> inline GProtoOutputArgs GOut(Ts&&... ts)
76 return GProtoOutputArgs(detail::packArgs(std::forward<Ts>(ts)...));
79 // Extract run-time arguments from node origin
80 // Can be used to extract constant values associated with G-objects
81 // (like GScalar) at graph construction time
82 GRunArg value_of(const GOrigin &origin);
84 // Transform run-time computation arguments into a collection of metadata
85 // extracted from that arguments
86 GMetaArg GAPI_EXPORTS descr_of(const GRunArg &arg );
87 GMetaArgs GAPI_EXPORTS descr_of(const GRunArgs &args);
89 // Transform run-time operation result argument into metadata extracted from that argument
90 // Used to compare the metadata, which generated at compile time with the metadata result operation in run time
91 GMetaArg GAPI_EXPORTS descr_of(const GRunArgP& argp);
96 #endif // OPENCV_GAPI_GPROTO_HPP