github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/gmetaarg.hpp (about) 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. 4 // 5 // Copyright (C) 2018 Intel Corporation 6 7 8 #ifndef OPENCV_GAPI_GMETAARG_HPP 9 #define OPENCV_GAPI_GMETAARG_HPP 10 11 #include <vector> 12 #include <type_traits> 13 14 #include <opencv2/gapi/util/util.hpp> 15 #include <opencv2/gapi/util/variant.hpp> 16 17 #include <opencv2/gapi/gmat.hpp> 18 #include <opencv2/gapi/gscalar.hpp> 19 #include <opencv2/gapi/garray.hpp> 20 #include <opencv2/gapi/gopaque.hpp> 21 #include <opencv2/gapi/gframe.hpp> 22 23 namespace cv 24 { 25 // FIXME: Rename to GMeta? 26 // FIXME: user shouldn't deal with it - put to detail? 27 // GMetaArg is an union type over descriptions of G-types which can serve as 28 // GComputation's in/output slots. 29 // 30 // GMetaArg objects are passed as arguments to GComputation::compile() 31 // to specify which data a compiled computation should be specialized on. 32 // For manual compile(), user must supply this metadata, in case of apply() 33 // this metadata is taken from arguments computation should operate on. 34 // 35 // The first type (monostate) is equal to "uninitialized"/"unresolved" meta. 36 using GMetaArg = util::variant 37 < util::monostate 38 , GMatDesc 39 , GScalarDesc 40 , GArrayDesc 41 , GOpaqueDesc 42 , GFrameDesc 43 >; 44 GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &); 45 46 using GMetaArgs = std::vector<GMetaArg>; 47 48 namespace detail 49 { 50 // These traits are used by GComputation::compile() 51 52 // FIXME: is_constructible<T> doesn't work as variant doesn't do any SFINAE 53 // in its current template constructor 54 55 template<typename T> struct is_meta_descr : std::false_type {}; 56 template<> struct is_meta_descr<GMatDesc> : std::true_type {}; 57 template<> struct is_meta_descr<GScalarDesc> : std::true_type {}; 58 template<> struct is_meta_descr<GArrayDesc> : std::true_type {}; 59 template<> struct is_meta_descr<GOpaqueDesc> : std::true_type {}; 60 61 template<typename... Ts> 62 using are_meta_descrs = all_satisfy<is_meta_descr, Ts...>; 63 64 template<typename... Ts> 65 using are_meta_descrs_but_last = all_satisfy<is_meta_descr, typename all_but_last<Ts...>::type>; 66 67 } // namespace detail 68 69 // Note: descr_of(std::vector<..>) returns a GArrayDesc, while 70 // descrs_of(std::vector<..>) returns an array of Meta args! 71 class UMat; 72 GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector<cv::Mat> &vec); 73 GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector<cv::UMat> &vec); 74 namespace gapi { namespace own { 75 GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector<Mat> &vec); 76 }} // namespace gapi::own 77 78 } // namespace cv 79 80 #endif // OPENCV_GAPI_GMETAARG_HPP