gapi_mock_kernels.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. #include <opencv2/gapi/cpu/gcpukernel.hpp>
  7. #include "api/gbackend_priv.hpp" // directly instantiate GBackend::Priv
  8. namespace opencv_test
  9. {
  10. namespace {
  11. // FIXME: Currently every Kernel implementation in this test file has
  12. // its own backend() method and it is incorrect! API classes should
  13. // provide it out of the box.
  14. namespace I
  15. {
  16. G_TYPED_KERNEL(Foo, <cv::GMat(cv::GMat)>, "test.kernels.foo")
  17. {
  18. static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
  19. };
  20. G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
  21. {
  22. static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
  23. };
  24. G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")
  25. {
  26. static cv::GScalarDesc outMeta(const cv::GMatDesc &) { return cv::empty_scalar_desc(); }
  27. };
  28. G_TYPED_KERNEL(Qux, <cv::GMat(cv::GMat, cv::GScalar)>, "test.kernels.qux")
  29. {
  30. static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GScalarDesc &) { return in; }
  31. };
  32. G_TYPED_KERNEL(Quux, <cv::GMat(cv::GScalar, cv::GMat)>, "test.kernels.quux")
  33. {
  34. static cv::GMatDesc outMeta(const cv::GScalarDesc &, const cv::GMatDesc& in) { return in; }
  35. };
  36. }
  37. // Kernel implementations for imaginary Jupiter device
  38. namespace Jupiter
  39. {
  40. namespace detail
  41. {
  42. static cv::gapi::GBackend backend(std::make_shared<cv::gapi::GBackend::Priv>());
  43. }
  44. inline cv::gapi::GBackend backend() { return detail::backend; }
  45. GAPI_OCV_KERNEL(Foo, I::Foo)
  46. {
  47. static void run(const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
  48. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  49. };
  50. GAPI_OCV_KERNEL(Bar, I::Bar)
  51. {
  52. static void run(const cv::Mat &, const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
  53. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  54. };
  55. GAPI_OCV_KERNEL(Baz, I::Baz)
  56. {
  57. static void run(const cv::Mat &, cv::Scalar &) { /*Do nothing*/ }
  58. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  59. };
  60. GAPI_OCV_KERNEL(Qux, I::Qux)
  61. {
  62. static void run(const cv::Mat &, const cv::Scalar&, cv::Mat &) { /*Do nothing*/ }
  63. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  64. };
  65. GAPI_OCV_KERNEL(Quux, I::Quux)
  66. {
  67. static void run(const cv::Scalar&, const cv::Mat&, cv::Mat &) { /*Do nothing*/ }
  68. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  69. };
  70. } // namespace Jupiter
  71. // Kernel implementations for imaginary Saturn device
  72. namespace Saturn
  73. {
  74. namespace detail
  75. {
  76. static cv::gapi::GBackend backend(std::make_shared<cv::gapi::GBackend::Priv>());
  77. }
  78. inline cv::gapi::GBackend backend() { return detail::backend; }
  79. GAPI_OCV_KERNEL(Foo, I::Foo)
  80. {
  81. static void run(const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
  82. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  83. };
  84. GAPI_OCV_KERNEL(Bar, I::Bar)
  85. {
  86. static void run(const cv::Mat &, const cv::Mat &, cv::Mat &) { /*Do nothing*/ }
  87. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  88. };
  89. GAPI_OCV_KERNEL(Baz, I::Baz)
  90. {
  91. static void run(const cv::Mat &, cv::Scalar &) { /*Do nothing*/ }
  92. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  93. };
  94. GAPI_OCV_KERNEL(Qux, I::Qux)
  95. {
  96. static void run(const cv::Mat &, const cv::Scalar&, cv::Mat &) { /*Do nothing*/ }
  97. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  98. };
  99. GAPI_OCV_KERNEL(Quux, I::Quux)
  100. {
  101. static void run(const cv::Scalar&, const cv::Mat&, cv::Mat &) { /*Do nothing*/ }
  102. static cv::gapi::GBackend backend() { return detail::backend; } // FIXME: Must be removed
  103. };
  104. } // namespace Saturn
  105. } // anonymous namespace
  106. } // namespace opencv_test