source.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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) 2021 Intel Corporation
  6. #ifndef OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP
  7. #define OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP
  8. #include <opencv2/gapi/garg.hpp>
  9. #include <opencv2/gapi/streaming/meta.hpp>
  10. #include <opencv2/gapi/streaming/source.hpp>
  11. #include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
  12. #include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
  13. #include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
  14. namespace cv {
  15. namespace gapi {
  16. namespace wip {
  17. namespace onevpl {
  18. using CfgParams = std::vector<CfgParam>;
  19. /**
  20. * @brief G-API streaming source based on OneVPL implementation.
  21. *
  22. * This class implements IStreamSource interface.
  23. * Its constructor takes source file path (in usual way) or @ref onevpl::IDataProvider
  24. * interface implementation (for not file-based sources). It also allows to pass-through
  25. * oneVPL configuration parameters by using several @ref onevpl::CfgParam.
  26. *
  27. * @note stream sources are passed to G-API via shared pointers, so
  28. * please gapi::make_onevpl_src<> to create objects and ptr() to pass a
  29. * GSource to cv::gin().
  30. */
  31. class GAPI_EXPORTS GSource : public IStreamSource
  32. {
  33. public:
  34. struct Priv;
  35. GSource(const std::string& filePath,
  36. const CfgParams& cfg_params = CfgParams{});
  37. GSource(const std::string& filePath,
  38. const CfgParams& cfg_params,
  39. const std::string& device_id,
  40. void* accel_device_ptr,
  41. void* accel_ctx_ptr);
  42. GSource(const std::string& filePath,
  43. const CfgParams& cfg_params,
  44. const Device &device, const Context &ctx);
  45. GSource(const std::string& filePath,
  46. const CfgParams& cfg_params,
  47. std::shared_ptr<IDeviceSelector> selector);
  48. GSource(std::shared_ptr<IDataProvider> source,
  49. const CfgParams& cfg_params = CfgParams{});
  50. GSource(std::shared_ptr<IDataProvider> source,
  51. const CfgParams& cfg_params,
  52. const std::string& device_id,
  53. void* accel_device_ptr,
  54. void* accel_ctx_ptr);
  55. GSource(std::shared_ptr<IDataProvider> source,
  56. const CfgParams& cfg_params,
  57. std::shared_ptr<IDeviceSelector> selector);
  58. ~GSource() override;
  59. bool pull(cv::gapi::wip::Data& data) override;
  60. GMetaArg descr_of() const override;
  61. private:
  62. explicit GSource(std::unique_ptr<Priv>&& impl);
  63. std::unique_ptr<Priv> m_priv;
  64. };
  65. } // namespace onevpl
  66. using GVPLSource = onevpl::GSource;
  67. template<class... Args>
  68. GAPI_EXPORTS_W cv::Ptr<IStreamSource> inline make_onevpl_src(Args&&... args)
  69. {
  70. return make_src<onevpl::GSource>(std::forward<Args>(args)...);
  71. }
  72. } // namespace wip
  73. } // namespace gapi
  74. } // namespace cv
  75. #endif // OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP