github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/streaming/meta.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) 2020 Intel Corporation
     6  
     7  
     8  #ifndef OPENCV_GAPI_GSTREAMING_META_HPP
     9  #define OPENCV_GAPI_GSTREAMING_META_HPP
    10  
    11  #include <opencv2/gapi/gopaque.hpp>
    12  #include <opencv2/gapi/gcall.hpp>
    13  #include <opencv2/gapi/gkernel.hpp>
    14  #include <opencv2/gapi/gtype_traits.hpp>
    15  
    16  namespace cv {
    17  namespace gapi {
    18  namespace streaming {
    19  
    20  // FIXME: the name is debatable
    21  namespace meta_tag {
    22  static constexpr const char * timestamp = "org.opencv.gapi.meta.timestamp";
    23  static constexpr const char * seq_id    = "org.opencv.gapi.meta.seq_id";
    24  } // namespace meta_tag
    25  
    26  namespace detail {
    27  struct GMeta {
    28      static const char *id() {
    29          return "org.opencv.streaming.meta";
    30      }
    31      // A universal yield for meta(), same as in GDesync
    32      template<typename... R, int... IIs>
    33      static std::tuple<R...> yield(cv::GCall &call, cv::detail::Seq<IIs...>) {
    34          return std::make_tuple(cv::detail::Yield<R>::yield(call, IIs)...);
    35      }
    36      // Also a universal outMeta stub here
    37      static GMetaArgs getOutMeta(const GMetaArgs &args, const GArgs &) {
    38          return args;
    39      }
    40  };
    41  } // namespace detail
    42  
    43  template<typename T, typename G>
    44  cv::GOpaque<T> meta(G g, const std::string &tag) {
    45      using O = cv::GOpaque<T>;
    46      cv::GKernel k{
    47            detail::GMeta::id()                    // kernel id
    48          , tag                                    // kernel tag. Use meta tag here
    49          , &detail::GMeta::getOutMeta             // outMeta callback
    50          , {cv::detail::GTypeTraits<O>::shape}    // output Shape
    51          , {cv::detail::GTypeTraits<G>::op_kind}  // input data kinds
    52          , {cv::detail::GObtainCtor<O>::get()}    // output template ctors
    53      };
    54      cv::GCall call(std::move(k));
    55      call.pass(g);
    56      return std::get<0>(detail::GMeta::yield<O>(call, cv::detail::MkSeq<1>::type()));
    57  }
    58  
    59  template<typename G>
    60  cv::GOpaque<int64_t> timestamp(G g) {
    61      return meta<int64_t>(g, meta_tag::timestamp);
    62  }
    63  
    64  template<typename G>
    65  cv::GOpaque<int64_t> seq_id(G g) {
    66      return meta<int64_t>(g, meta_tag::seq_id);
    67  }
    68  
    69  template<typename G>
    70  cv::GOpaque<int64_t> seqNo(G g) {
    71      // Old name, compatibility only
    72      return seq_id(g);
    73  }
    74  
    75  } // namespace streaming
    76  } // namespace gapi
    77  } // namespace cv
    78  
    79  #endif // OPENCV_GAPI_GSTREAMING_META_HPP