gcall.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #ifndef OPENCV_GAPI_GCALL_HPP
  7. #define OPENCV_GAPI_GCALL_HPP
  8. #include <opencv2/gapi/garg.hpp> // GArg
  9. #include <opencv2/gapi/gmat.hpp> // GMat
  10. #include <opencv2/gapi/gscalar.hpp> // GScalar
  11. #include <opencv2/gapi/gframe.hpp> // GFrame
  12. #include <opencv2/gapi/garray.hpp> // GArray<T>
  13. #include <opencv2/gapi/gopaque.hpp> // GOpaque<T>
  14. namespace cv {
  15. struct GKernel;
  16. // The whole idea of this class is to represent an operation
  17. // which is applied to arguments. This is part of public API,
  18. // since it is what users should use to define kernel interfaces.
  19. class GAPI_EXPORTS GCall final
  20. {
  21. public:
  22. class Priv;
  23. explicit GCall(const GKernel &k);
  24. ~GCall();
  25. template<typename... Ts>
  26. GCall& pass(Ts&&... args)
  27. {
  28. setArgs({cv::GArg(std::move(args))...});
  29. return *this;
  30. }
  31. // A generic yield method - obtain a link to operator's particular GMat output
  32. GMat yield (int output = 0);
  33. GMatP yieldP (int output = 0);
  34. GScalar yieldScalar(int output = 0);
  35. GFrame yieldFrame (int output = 0);
  36. template<class T> GArray<T> yieldArray(int output = 0)
  37. {
  38. return GArray<T>(yieldArray(output));
  39. }
  40. template<class T> GOpaque<T> yieldOpaque(int output = 0)
  41. {
  42. return GOpaque<T>(yieldOpaque(output));
  43. }
  44. // Internal use only
  45. Priv& priv();
  46. const Priv& priv() const;
  47. // GKernel and params can be modified, it's needed for infer<Generic>,
  48. // because information about output shapes doesn't exist in compile time
  49. GKernel& kernel();
  50. cv::util::any& params();
  51. void setArgs(std::vector<GArg> &&args);
  52. protected:
  53. std::shared_ptr<Priv> m_priv;
  54. // Public versions return a typed array or opaque, those are implementation details
  55. detail::GArrayU yieldArray(int output = 0);
  56. detail::GOpaqueU yieldOpaque(int output = 0);
  57. };
  58. } // namespace cv
  59. #endif // OPENCV_GAPI_GCALL_HPP