github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/streaming/source.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) 2019 Intel Corporation
     6  
     7  #ifndef OPENCV_GAPI_STREAMING_SOURCE_HPP
     8  #define OPENCV_GAPI_STREAMING_SOURCE_HPP
     9  
    10  #include <memory>                      // shared_ptr
    11  #include <type_traits>                 // is_base_of
    12  
    13  #include <opencv2/gapi/gmetaarg.hpp>   // GMetaArg
    14  
    15  
    16  namespace cv {
    17  namespace gapi {
    18  namespace wip {
    19      struct Data; // "forward-declaration" of GRunArg
    20  
    21  /**
    22   * @brief Abstract streaming pipeline source.
    23   *
    24   * Implement this interface if you want customize the way how data is
    25   * streaming into GStreamingCompiled.
    26   *
    27   * Objects implementing this interface can be passed to
    28   * GStreamingCompiled using setSource() with cv::gin(). Regular
    29   * compiled graphs (GCompiled) don't support input objects of this
    30   * type.
    31   *
    32   * Default cv::VideoCapture-based implementation is available, see
    33   * cv::gapi::wip::GCaptureSource.
    34   *
    35   * @note stream sources are passed to G-API via shared pointers, so
    36   *  please use ptr() when passing a IStreamSource implementation to
    37   *  cv::gin().
    38   */
    39  class IStreamSource: public std::enable_shared_from_this<IStreamSource>
    40  {
    41  public:
    42      using Ptr = std::shared_ptr<IStreamSource>;
    43      Ptr ptr() { return shared_from_this(); }
    44      virtual bool pull(Data &data) = 0;
    45      virtual GMetaArg descr_of() const = 0;
    46      virtual ~IStreamSource() = default;
    47  };
    48  
    49  template<class T, class... Args>
    50  IStreamSource::Ptr inline make_src(Args&&... args)
    51  {
    52      static_assert(std::is_base_of<IStreamSource, T>::value,
    53                    "T must implement the cv::gapi::IStreamSource interface!");
    54      auto src_ptr = std::make_shared<T>(std::forward<Args>(args)...);
    55      return src_ptr->ptr();
    56  }
    57  
    58  } // namespace wip
    59  } // namespace gapi
    60  } // namespace cv
    61  
    62  #endif // OPENCV_GAPI_STREAMING_SOURCE_HPP