bindings_onnx.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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
  3. // directory of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP
  5. #define OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP
  6. #include <opencv2/gapi/gkernel.hpp> // GKernelPackage
  7. #include <opencv2/gapi/infer/onnx.hpp> // Params
  8. #include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
  9. #include <opencv2/gapi/util/any.hpp>
  10. #include <string>
  11. namespace cv {
  12. namespace gapi {
  13. namespace onnx {
  14. // NB: Used by python wrapper
  15. // This class can be marked as SIMPLE, because it's implemented as pimpl
  16. class GAPI_EXPORTS_W_SIMPLE PyParams {
  17. public:
  18. GAPI_WRAP
  19. PyParams() = default;
  20. GAPI_WRAP
  21. PyParams(const std::string& tag, const std::string& model_path);
  22. GAPI_WRAP
  23. PyParams& cfgMeanStd(const std::string &layer_name,
  24. const cv::Scalar &m,
  25. const cv::Scalar &s);
  26. GAPI_WRAP
  27. PyParams& cfgNormalize(const std::string &layer_name, bool flag);
  28. GAPI_WRAP
  29. PyParams& cfgAddExecutionProvider(ep::OpenVINO ep);
  30. GAPI_WRAP
  31. PyParams& cfgAddExecutionProvider(ep::DirectML ep);
  32. GAPI_WRAP
  33. PyParams& cfgAddExecutionProvider(ep::CoreML ep);
  34. GAPI_WRAP
  35. PyParams& cfgAddExecutionProvider(ep::CUDA ep);
  36. GAPI_WRAP
  37. PyParams& cfgAddExecutionProvider(ep::TensorRT ep);
  38. GAPI_WRAP
  39. PyParams& cfgDisableMemPattern();
  40. GAPI_WRAP
  41. PyParams& cfgSessionOptions(const std::map<std::string, std::string>& options);
  42. GAPI_WRAP
  43. PyParams& cfgOptLevel(const int opt_level);
  44. GBackend backend() const;
  45. std::string tag() const;
  46. cv::util::any params() const;
  47. private:
  48. std::shared_ptr<Params<cv::gapi::Generic>> m_priv;
  49. };
  50. GAPI_EXPORTS_W PyParams params(const std::string& tag, const std::string& model_path);
  51. } // namespace onnx
  52. } // namespace gapi
  53. } // namespace cv
  54. #endif // OPENCV_GAPI_INFER_BINDINGS_ONNX_HPP