infer.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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) 2022 Intel Corporation
  6. #ifndef OPENCV_GAPI_OAK_INFER_HPP
  7. #define OPENCV_GAPI_OAK_INFER_HPP
  8. #include <unordered_map>
  9. #include <string>
  10. #include <array>
  11. #include <tuple>
  12. #include <opencv2/gapi/opencv_includes.hpp>
  13. #include <opencv2/gapi/util/any.hpp>
  14. #include <opencv2/core/cvdef.h> // GAPI_EXPORTS
  15. #include <opencv2/gapi/gkernel.hpp> // GKernelPackage
  16. namespace cv {
  17. namespace gapi {
  18. namespace oak {
  19. namespace detail {
  20. /**
  21. * @brief This structure contains description of inference parameters
  22. * which is specific to OAK models.
  23. */
  24. struct ParamDesc {
  25. std::string blob_file;
  26. };
  27. } // namespace detail
  28. /**
  29. * Contains description of inference parameters and kit of functions that
  30. * fill this parameters.
  31. */
  32. template<typename Net> class Params {
  33. public:
  34. /** @brief Class constructor.
  35. Constructs Params based on model information and sets default values for other
  36. inference description parameters.
  37. @param model Path to model (.blob file)
  38. */
  39. explicit Params(const std::string &model) {
  40. desc.blob_file = model;
  41. };
  42. // BEGIN(G-API's network parametrization API)
  43. GBackend backend() const { return cv::gapi::oak::backend(); }
  44. std::string tag() const { return Net::tag(); }
  45. cv::util::any params() const { return { desc }; }
  46. // END(G-API's network parametrization API)
  47. protected:
  48. detail::ParamDesc desc;
  49. };
  50. } // namespace oak
  51. } // namespace gapi
  52. } // namespace cv
  53. #endif // OPENCV_GAPI_OAK_INFER_HPP