diff --git a/modules/gapi/CMakeLists.txt b/modules/gapi/CMakeLists.txt index ec05b385cd..cc4cef7009 100644 --- a/modules/gapi/CMakeLists.txt +++ b/modules/gapi/CMakeLists.txt @@ -23,6 +23,7 @@ file(GLOB gapi_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/util/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cpu/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/gpu/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/ocl/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/fluid/*.hpp" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/own/*.hpp" ) @@ -72,11 +73,11 @@ set(gapi_srcs src/backends/fluid/gfluidimgproc_func.dispatch.cpp src/backends/fluid/gfluidcore.cpp - # GPU Backend (currently built-in) - src/backends/gpu/ggpubackend.cpp - src/backends/gpu/ggpukernel.cpp - src/backends/gpu/ggpuimgproc.cpp - src/backends/gpu/ggpucore.cpp + # OCL Backend (currently built-in) + src/backends/ocl/goclbackend.cpp + src/backends/ocl/goclkernel.cpp + src/backends/ocl/goclimgproc.cpp + src/backends/ocl/goclcore.cpp # Compound src/backends/common/gcompoundbackend.cpp diff --git a/modules/gapi/include/opencv2/gapi/gpu/core.hpp b/modules/gapi/include/opencv2/gapi/gpu/core.hpp index 98d49b5b8b..f780545dfc 100644 --- a/modules/gapi/include/opencv2/gapi/gpu/core.hpp +++ b/modules/gapi/include/opencv2/gapi/gpu/core.hpp @@ -7,17 +7,17 @@ #ifndef OPENCV_GAPI_GPU_CORE_API_HPP #define OPENCV_GAPI_GPU_CORE_API_HPP +/** @file +* @deprecated Use "opencv2/gapi/ocl/core.hpp" instead. +*/ -#include // GAPI_EXPORTS -#include // GKernelPackage +#include "opencv2/gapi/ocl/core.hpp" namespace cv { namespace gapi { namespace core { namespace gpu { - -GAPI_EXPORTS GKernelPackage kernels(); - + using namespace ocl; } // namespace gpu } // namespace core } // namespace gapi diff --git a/modules/gapi/include/opencv2/gapi/gpu/ggpukernel.hpp b/modules/gapi/include/opencv2/gapi/gpu/ggpukernel.hpp index e5a6215e3c..74926c0be4 100644 --- a/modules/gapi/include/opencv2/gapi/gpu/ggpukernel.hpp +++ b/modules/gapi/include/opencv2/gapi/gpu/ggpukernel.hpp @@ -7,238 +7,22 @@ #ifndef OPENCV_GAPI_GGPUKERNEL_HPP #define OPENCV_GAPI_GGPUKERNEL_HPP +/** @file +* @deprecated Use "opencv2/gapi/ocl/goclkernel.hpp" instead. +*/ -#include -#include -#include -#include +#include "opencv2/gapi/ocl/goclkernel.hpp" +#define GAPI_GPU_KERNEL GAPI_OCL_KERNEL -#include -#include -#include -#include - -// FIXME: namespace scheme for backends? namespace cv { - -namespace gimpl -{ - // Forward-declare an internal class - class GGPUExecutable; -} // namespace gimpl - -namespace gapi -{ -namespace gpu -{ - /** - * \addtogroup gapi_std_backends G-API Standard backends - * @{ - */ - /** - * @brief Get a reference to GPU backend. - * - * At the moment, the GPU backend is built atop of OpenCV - * "Transparent API" (T-API), see cv::UMat for details. - * - * @sa gapi_std_backends - */ - GAPI_EXPORTS cv::gapi::GBackend backend(); - /** @} */ +namespace gapi { +namespace core { +namespace gpu { + using namespace ocl; } // namespace gpu +} // namespace core } // namespace gapi - - -// Represents arguments which are passed to a wrapped GPU function -// FIXME: put into detail? -class GAPI_EXPORTS GGPUContext -{ -public: - // Generic accessor API - template - const T& inArg(int input) { return m_args.at(input).get(); } - - // Syntax sugar - const cv::UMat& inMat(int input); - cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() - - const cv::gapi::own::Scalar& inVal(int input); - cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR() - template std::vector& outVecR(int output) // FIXME: the same issue - { - return outVecRef(output).wref(); - } - -protected: - detail::VectorRef& outVecRef(int output); - - std::vector m_args; - std::unordered_map m_results; - - - friend class gimpl::GGPUExecutable; -}; - -class GAPI_EXPORTS GGPUKernel -{ -public: - // This function is kernel's execution entry point (does the processing work) - using F = std::function; - - GGPUKernel(); - explicit GGPUKernel(const F& f); - - void apply(GGPUContext &ctx); - -protected: - F m_f; -}; - -// FIXME: This is an ugly ad-hoc imlpementation. TODO: refactor - -namespace detail -{ -template struct gpu_get_in; -template<> struct gpu_get_in -{ - static cv::UMat get(GGPUContext &ctx, int idx) { return ctx.inMat(idx); } -}; -template<> struct gpu_get_in -{ - static cv::Scalar get(GGPUContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); } -}; -template struct gpu_get_in > -{ - static const std::vector& get(GGPUContext &ctx, int idx) { return ctx.inArg(idx).rref(); } -}; -template struct gpu_get_in -{ - static T get(GGPUContext &ctx, int idx) { return ctx.inArg(idx); } -}; - -struct tracked_cv_umat{ - //TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ? - //tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {} - tracked_cv_umat(cv::UMat& m) : r{ (m) }, original_data{ nullptr } {} - cv::UMat r; - uchar* original_data; - - operator cv::UMat& (){ return r;} - void validate() const{ - //if (r.getMat(ACCESS_RW).data != original_data) - //{ - // util::throw_error - // (std::logic_error - // ("OpenCV kernel output parameter was reallocated. \n" - // "Incorrect meta data was provided ?")); - //} - - } -}; - -struct scalar_wrapper_gpu -{ - //FIXME reuse CPU (OpenCV) plugin code - scalar_wrapper_gpu(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {}; - operator cv::Scalar& () { return m_s; } - void writeBack() const { m_org_s = to_own(m_s); } - - cv::Scalar m_s; - cv::gapi::own::Scalar& m_org_s; -}; - -template -void postprocess_gpu(Outputs&... outs) -{ - struct - { - void operator()(tracked_cv_umat* bm) { bm->validate(); } - void operator()(scalar_wrapper_gpu* sw) { sw->writeBack(); } - void operator()(...) { } - - } validate; - //dummy array to unfold parameter pack - int dummy[] = { 0, (validate(&outs), 0)... }; - cv::util::suppress_unused_warning(dummy); -} - -template struct gpu_get_out; -template<> struct gpu_get_out -{ - static tracked_cv_umat get(GGPUContext &ctx, int idx) - { - auto& r = ctx.outMatR(idx); - return{ r }; - } -}; -template<> struct gpu_get_out -{ - static scalar_wrapper_gpu get(GGPUContext &ctx, int idx) - { - auto& s = ctx.outValR(idx); - return{ s }; - } -}; -template struct gpu_get_out > -{ - static std::vector& get(GGPUContext &ctx, int idx) { return ctx.outVecR(idx); } -}; - -template -struct GPUCallHelper; - -// FIXME: probably can be simplified with std::apply or analogue. -template -struct GPUCallHelper, std::tuple > -{ - template - struct call_and_postprocess - { - template - static void call(Inputs&&... ins, Outputs&&... outs) - { - //not using a std::forward on outs is deliberate in order to - //cause compilation error, by tring to bind rvalue references to lvalue references - Impl::run(std::forward(ins)..., outs...); - - postprocess_gpu(outs...); - } - }; - - template - static void call_impl(GGPUContext &ctx, detail::Seq, detail::Seq) - { - //TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters - //by comparing it's state (data ptr) before and after the call. - //Convert own::Scalar to cv::Scalar before call kernel and run kernel - //convert cv::Scalar to own::Scalar after call kernel and write back results - call_and_postprocess::get(ctx, IIs))...>::call(gpu_get_in::get(ctx, IIs)..., gpu_get_out::get(ctx, OIs)...); - } - - static void call(GGPUContext &ctx) - { - call_impl(ctx, - typename detail::MkSeq::type(), - typename detail::MkSeq::type()); - } -}; - -} // namespace detail - -template -class GGPUKernelImpl: public detail::GPUCallHelper -{ - using P = detail::GPUCallHelper; - -public: - using API = K; - - static cv::gapi::GBackend backend() { return cv::gapi::gpu::backend(); } - static cv::GGPUKernel kernel() { return GGPUKernel(&P::call); } -}; - -#define GAPI_GPU_KERNEL(Name, API) struct Name: public cv::GGPUKernelImpl - } // namespace cv + #endif // OPENCV_GAPI_GGPUKERNEL_HPP diff --git a/modules/gapi/include/opencv2/gapi/gpu/imgproc.hpp b/modules/gapi/include/opencv2/gapi/gpu/imgproc.hpp index 6071dda98b..81ae0cb761 100644 --- a/modules/gapi/include/opencv2/gapi/gpu/imgproc.hpp +++ b/modules/gapi/include/opencv2/gapi/gpu/imgproc.hpp @@ -7,17 +7,18 @@ #ifndef OPENCV_GAPI_GPU_IMGPROC_API_HPP #define OPENCV_GAPI_GPU_IMGPROC_API_HPP +/** @file +* @deprecated Use "opencv2/gapi/ocl/imgproc.hpp" instead. +*/ + +#include "opencv2/gapi/ocl/imgproc.hpp" -#include // GAPI_EXPORTS -#include // GKernelPackage namespace cv { namespace gapi { namespace imgproc { namespace gpu { - -GAPI_EXPORTS GKernelPackage kernels(); - + using namespace ocl; } // namespace gpu } // namespace imgproc } // namespace gapi diff --git a/modules/gapi/include/opencv2/gapi/ocl/core.hpp b/modules/gapi/include/opencv2/gapi/ocl/core.hpp new file mode 100644 index 0000000000..473ed3f44c --- /dev/null +++ b/modules/gapi/include/opencv2/gapi/ocl/core.hpp @@ -0,0 +1,30 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_CORE_API_HPP +#define OPENCV_GAPI_OCL_CORE_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace core { +inline namespace ocl { + + GAPI_EXPORTS GKernelPackage kernels(); + +} // inline namespace ocl +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_CORE_API_HPP diff --git a/modules/gapi/include/opencv2/gapi/ocl/goclkernel.hpp b/modules/gapi/include/opencv2/gapi/ocl/goclkernel.hpp new file mode 100644 index 0000000000..ea2cda0bf8 --- /dev/null +++ b/modules/gapi/include/opencv2/gapi/ocl/goclkernel.hpp @@ -0,0 +1,244 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GOCLKERNEL_HPP +#define OPENCV_GAPI_GOCLKERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gimpl +{ + // Forward-declare an internal class + class GOCLExecutable; +} // namespace gimpl + +namespace gapi +{ +namespace ocl +{ + /** + * \addtogroup gapi_std_backends G-API Standard backends + * @{ + */ + /** + * @brief Get a reference to OCL backend. + * + * At the moment, the OCL backend is built atop of OpenCV + * "Transparent API" (T-API), see cv::UMat for details. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ +} // namespace ocl +} // namespace gapi + + +// Represents arguments which are passed to a wrapped OCL function +// FIXME: put into detail? +class GAPI_EXPORTS GOCLContext +{ +public: + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const cv::UMat& inMat(int input); + cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() + + const cv::gapi::own::Scalar& inVal(int input); + cv::gapi::own::Scalar& outValR(int output); // FIXME: Avoid cv::gapi::own::Scalar s = ctx.outValR() + template std::vector& outVecR(int output) // FIXME: the same issue + { + return outVecRef(output).wref(); + } + +protected: + detail::VectorRef& outVecRef(int output); + + std::vector m_args; + std::unordered_map m_results; + + + friend class gimpl::GOCLExecutable; +}; + +class GAPI_EXPORTS GOCLKernel +{ +public: + // This function is kernel's execution entry point (does the processing work) + using F = std::function; + + GOCLKernel(); + explicit GOCLKernel(const F& f); + + void apply(GOCLContext &ctx); + +protected: + F m_f; +}; + +// FIXME: This is an ugly ad-hoc imlpementation. TODO: refactor + +namespace detail +{ +template struct ocl_get_in; +template<> struct ocl_get_in +{ + static cv::UMat get(GOCLContext &ctx, int idx) { return ctx.inMat(idx); } +}; +template<> struct ocl_get_in +{ + static cv::Scalar get(GOCLContext &ctx, int idx) { return to_ocv(ctx.inVal(idx)); } +}; +template struct ocl_get_in > +{ + static const std::vector& get(GOCLContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct ocl_get_in +{ + static T get(GOCLContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +struct tracked_cv_umat{ + //TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ? + //tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {} + tracked_cv_umat(cv::UMat& m) : r{ (m) }, original_data{ nullptr } {} + cv::UMat r; + uchar* original_data; + + operator cv::UMat& (){ return r;} + void validate() const{ + //if (r.getMat(ACCESS_RW).data != original_data) + //{ + // util::throw_error + // (std::logic_error + // ("OpenCV kernel output parameter was reallocated. \n" + // "Incorrect meta data was provided ?")); + //} + + } +}; + +struct scalar_wrapper_ocl +{ + //FIXME reuse CPU (OpenCV) plugin code + scalar_wrapper_ocl(cv::gapi::own::Scalar& s) : m_s{cv::gapi::own::to_ocv(s)}, m_org_s(s) {}; + operator cv::Scalar& () { return m_s; } + void writeBack() const { m_org_s = to_own(m_s); } + + cv::Scalar m_s; + cv::gapi::own::Scalar& m_org_s; +}; + +template +void postprocess_ocl(Outputs&... outs) +{ + struct + { + void operator()(tracked_cv_umat* bm) { bm->validate(); } + void operator()(scalar_wrapper_ocl* sw) { sw->writeBack(); } + void operator()(...) { } + + } validate; + //dummy array to unfold parameter pack + int dummy[] = { 0, (validate(&outs), 0)... }; + cv::util::suppress_unused_warning(dummy); +} + +template struct ocl_get_out; +template<> struct ocl_get_out +{ + static tracked_cv_umat get(GOCLContext &ctx, int idx) + { + auto& r = ctx.outMatR(idx); + return{ r }; + } +}; +template<> struct ocl_get_out +{ + static scalar_wrapper_ocl get(GOCLContext &ctx, int idx) + { + auto& s = ctx.outValR(idx); + return{ s }; + } +}; +template struct ocl_get_out > +{ + static std::vector& get(GOCLContext &ctx, int idx) { return ctx.outVecR(idx); } +}; + +template +struct OCLCallHelper; + +// FIXME: probably can be simplified with std::apply or analogue. +template +struct OCLCallHelper, std::tuple > +{ + template + struct call_and_postprocess + { + template + static void call(Inputs&&... ins, Outputs&&... outs) + { + //not using a std::forward on outs is deliberate in order to + //cause compilation error, by tring to bind rvalue references to lvalue references + Impl::run(std::forward(ins)..., outs...); + + postprocess_ocl(outs...); + } + }; + + template + static void call_impl(GOCLContext &ctx, detail::Seq, detail::Seq) + { + //TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters + //by comparing it's state (data ptr) before and after the call. + //Convert own::Scalar to cv::Scalar before call kernel and run kernel + //convert cv::Scalar to own::Scalar after call kernel and write back results + call_and_postprocess::get(ctx, IIs))...>::call(ocl_get_in::get(ctx, IIs)..., ocl_get_out::get(ctx, OIs)...); + } + + static void call(GOCLContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GOCLKernelImpl: public detail::OCLCallHelper +{ + using P = detail::OCLCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::ocl::backend(); } + static cv::GOCLKernel kernel() { return GOCLKernel(&P::call); } +}; + +#define GAPI_OCL_KERNEL(Name, API) struct Name: public cv::GOCLKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GOCLKERNEL_HPP diff --git a/modules/gapi/include/opencv2/gapi/ocl/imgproc.hpp b/modules/gapi/include/opencv2/gapi/ocl/imgproc.hpp new file mode 100644 index 0000000000..e36520af81 --- /dev/null +++ b/modules/gapi/include/opencv2/gapi/ocl/imgproc.hpp @@ -0,0 +1,30 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_IMGPROC_API_HPP +#define OPENCV_GAPI_OCL_IMGPROC_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace imgproc { +inline namespace ocl { + + GAPI_EXPORTS GKernelPackage kernels(); + +} // inline namespace ocl +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_IMGPROC_API_HPP diff --git a/modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp b/modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp index 5ec4f28c26..54e113a0ec 100644 --- a/modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp +++ b/modules/gapi/perf/gpu/gapi_core_perf_tests_gpu.cpp @@ -7,7 +7,6 @@ #include "../perf_precomp.hpp" #include "../common/gapi_core_perf_tests.hpp" -#include "opencv2/gapi/gpu/core.hpp" #define CORE_GPU cv::gapi::core::gpu::kernels() diff --git a/modules/gapi/perf/gpu/gapi_imgproc_perf_tests_gpu.cpp b/modules/gapi/perf/gpu/gapi_imgproc_perf_tests_gpu.cpp index 0864265e27..1f4df175f7 100644 --- a/modules/gapi/perf/gpu/gapi_imgproc_perf_tests_gpu.cpp +++ b/modules/gapi/perf/gpu/gapi_imgproc_perf_tests_gpu.cpp @@ -7,7 +7,6 @@ #include "../perf_precomp.hpp" #include "../common/gapi_imgproc_perf_tests.hpp" -#include "opencv2/gapi/gpu/imgproc.hpp" #define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels() diff --git a/modules/gapi/perf/perf_precomp.hpp b/modules/gapi/perf/perf_precomp.hpp index abd7cbe66f..4f9466e335 100644 --- a/modules/gapi/perf/perf_precomp.hpp +++ b/modules/gapi/perf/perf_precomp.hpp @@ -17,6 +17,8 @@ #include "opencv2/gapi/core.hpp" #include "opencv2/gapi/cpu/gcpukernel.hpp" #include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/gpu/imgproc.hpp" +#include "opencv2/gapi/gpu/core.hpp" #include "opencv2/gapi/operators.hpp" #include "opencv2/gapi/fluid/core.hpp" diff --git a/modules/gapi/src/backends/gpu/ggpubackend.cpp b/modules/gapi/src/backends/ocl/goclbackend.cpp similarity index 87% rename from modules/gapi/src/backends/gpu/ggpubackend.cpp rename to modules/gapi/src/backends/ocl/goclbackend.cpp index eda6a5fd78..6bc3bdb679 100644 --- a/modules/gapi/src/backends/gpu/ggpubackend.cpp +++ b/modules/gapi/src/backends/ocl/goclbackend.cpp @@ -25,9 +25,9 @@ #include "compiler/gobjref.hpp" #include "compiler/gmodel.hpp" -#include "backends/gpu/ggpubackend.hpp" -#include "backends/gpu/ggpuimgproc.hpp" -#include "backends/gpu/ggpucore.hpp" +#include "backends/ocl/goclbackend.hpp" +#include "backends/ocl/goclimgproc.hpp" +#include "backends/ocl/goclcore.hpp" #include "api/gbackend_priv.hpp" // FIXME: Make it part of Backend SDK! @@ -37,47 +37,47 @@ // Alternatively, is there a way to compose types graphs? // // If not, we need to introduce that! -using GGPUModel = ade::TypedGraph +using GOCLModel = ade::TypedGraph < cv::gimpl::Unit , cv::gimpl::Protocol >; // FIXME: Same issue with Typed and ConstTyped -using GConstGGPUModel = ade::ConstTypedGraph +using GConstGOCLModel = ade::ConstTypedGraph < cv::gimpl::Unit , cv::gimpl::Protocol >; namespace { - class GGPUBackendImpl final: public cv::gapi::GBackend::Priv + class GOCLBackendImpl final: public cv::gapi::GBackend::Priv { virtual void unpackKernel(ade::Graph &graph, const ade::NodeHandle &op_node, const cv::GKernelImpl &impl) override { - GGPUModel gm(graph); - auto gpu_impl = cv::util::any_cast(impl.opaque); - gm.metadata(op_node).set(cv::gimpl::Unit{gpu_impl}); + GOCLModel gm(graph); + auto ocl_impl = cv::util::any_cast(impl.opaque); + gm.metadata(op_node).set(cv::gimpl::Unit{ocl_impl}); } virtual EPtr compile(const ade::Graph &graph, const cv::GCompileArgs &, const std::vector &nodes) const override { - return EPtr{new cv::gimpl::GGPUExecutable(graph, nodes)}; + return EPtr{new cv::gimpl::GOCLExecutable(graph, nodes)}; } }; } -cv::gapi::GBackend cv::gapi::gpu::backend() +cv::gapi::GBackend cv::gapi::ocl::backend() { - static cv::gapi::GBackend this_backend(std::make_shared()); + static cv::gapi::GBackend this_backend(std::make_shared()); return this_backend; } -// GGPUExcecutable implementation ////////////////////////////////////////////// -cv::gimpl::GGPUExecutable::GGPUExecutable(const ade::Graph &g, +// GOCLExcecutable implementation ////////////////////////////////////////////// +cv::gimpl::GOCLExecutable::GOCLExecutable(const ade::Graph &g, const std::vector &nodes) : m_g(g), m_gm(m_g) { @@ -112,7 +112,7 @@ cv::gimpl::GGPUExecutable::GGPUExecutable(const ade::Graph &g, } // FIXME: Document what it does -cv::GArg cv::gimpl::GGPUExecutable::packArg(const GArg &arg) +cv::GArg cv::gimpl::GOCLExecutable::packArg(const GArg &arg) { // No API placeholders allowed at this point // FIXME: this check has to be done somewhere in compilation stage. @@ -143,7 +143,7 @@ cv::GArg cv::gimpl::GGPUExecutable::packArg(const GArg &arg) } } -void cv::gimpl::GGPUExecutable::run(std::vector &&input_objs, +void cv::gimpl::GOCLExecutable::run(std::vector &&input_objs, std::vector &&output_objs) { // Update resources with run-time information - what this Island @@ -172,24 +172,24 @@ void cv::gimpl::GGPUExecutable::run(std::vector &&input_objs, // OpenCV backend execution is not a rocket science at all. // Simply invoke our kernels in the proper order. - GConstGGPUModel gcm(m_g); + GConstGOCLModel gcm(m_g); for (auto &op_info : m_script) { const auto &op = m_gm.metadata(op_info.nh).get(); // Obtain our real execution unit // TODO: Should kernels be copyable? - GGPUKernel k = gcm.metadata(op_info.nh).get().k; + GOCLKernel k = gcm.metadata(op_info.nh).get().k; // Initialize kernel's execution context: // - Input parameters - GGPUContext context; + GOCLContext context; context.m_args.reserve(op.args.size()); using namespace std::placeholders; ade::util::transform(op.args, std::back_inserter(context.m_args), - std::bind(&GGPUExecutable::packArg, this, _1)); + std::bind(&GOCLExecutable::packArg, this, _1)); // - Output parameters. // FIXME: pre-allocate internal Mats, etc, according to the known meta diff --git a/modules/gapi/src/backends/gpu/ggpubackend.hpp b/modules/gapi/src/backends/ocl/goclbackend.hpp similarity index 77% rename from modules/gapi/src/backends/gpu/ggpubackend.hpp rename to modules/gapi/src/backends/ocl/goclbackend.hpp index 1fb128d5f7..3548dff75e 100644 --- a/modules/gapi/src/backends/gpu/ggpubackend.hpp +++ b/modules/gapi/src/backends/ocl/goclbackend.hpp @@ -5,8 +5,8 @@ // Copyright (C) 2018 Intel Corporation -#ifndef OPENCV_GAPI_GGPUBACKEND_HPP -#define OPENCV_GAPI_GGPUBACKEND_HPP +#ifndef OPENCV_GAPI_GOCLBACKEND_HPP +#define OPENCV_GAPI_GOCLBACKEND_HPP #include // map #include // unordered_map @@ -15,7 +15,7 @@ #include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/gproto.hpp" -#include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/ocl/goclkernel.hpp" #include "api/gapi_priv.hpp" @@ -26,11 +26,11 @@ namespace cv { namespace gimpl { struct Unit { - static const char *name() { return "GPUKernel"; } - GGPUKernel k; + static const char *name() { return "OCLKernel"; } + GOCLKernel k; }; -class GGPUExecutable final: public GIslandExecutable +class GOCLExecutable final: public GIslandExecutable { const ade::Graph &m_g; GModel::ConstGraph m_gm; @@ -51,16 +51,16 @@ class GGPUExecutable final: public GIslandExecutable GArg packArg(const GArg &arg); public: - GGPUExecutable(const ade::Graph &graph, + GOCLExecutable(const ade::Graph &graph, const std::vector &nodes); virtual inline bool canReshape() const override { return false; } virtual inline void reshape(ade::Graph&, const GCompileArgs&) override { - // FIXME: GPU plugin is in fact reshapeable (as it was initially, + // FIXME: OCL plugin is in fact reshapeable (as it was initially, // even before outMeta() has been introduced), so this limitation // should be dropped. - util::throw_error(std::logic_error("GGPUExecutable::reshape() should never be called")); + util::throw_error(std::logic_error("GOCLExecutable::reshape() should never be called")); } virtual void run(std::vector &&input_objs, @@ -69,4 +69,4 @@ public: }} -#endif // OPENCV_GAPI_GGPUBACKEND_HPP +#endif // OPENCV_GAPI_GOCLBACKEND_HPP diff --git a/modules/gapi/src/backends/gpu/ggpucore.cpp b/modules/gapi/src/backends/ocl/goclcore.cpp similarity index 67% rename from modules/gapi/src/backends/gpu/ggpucore.cpp rename to modules/gapi/src/backends/ocl/goclcore.cpp index a1ee6a1133..f55f7bb2f9 100644 --- a/modules/gapi/src/backends/gpu/ggpucore.cpp +++ b/modules/gapi/src/backends/ocl/goclcore.cpp @@ -8,10 +8,10 @@ #include "precomp.hpp" #include "opencv2/gapi/core.hpp" -#include "opencv2/gapi/gpu/core.hpp" -#include "backends/gpu/ggpucore.hpp" +#include "opencv2/gapi/ocl/core.hpp" +#include "backends/ocl/goclcore.hpp" -GAPI_GPU_KERNEL(GGPUAdd, cv::gapi::core::GAdd) +GAPI_OCL_KERNEL(GOCLAdd, cv::gapi::core::GAdd) { static void run(const cv::UMat& a, const cv::UMat& b, int dtype, cv::UMat& out) { @@ -19,7 +19,7 @@ GAPI_GPU_KERNEL(GGPUAdd, cv::gapi::core::GAdd) } }; -GAPI_GPU_KERNEL(GGPUAddC, cv::gapi::core::GAddC) +GAPI_OCL_KERNEL(GOCLAddC, cv::gapi::core::GAddC) { static void run(const cv::UMat& a, const cv::Scalar& b, int dtype, cv::UMat& out) { @@ -27,7 +27,7 @@ GAPI_GPU_KERNEL(GGPUAddC, cv::gapi::core::GAddC) } }; -GAPI_GPU_KERNEL(GGPUSub, cv::gapi::core::GSub) +GAPI_OCL_KERNEL(GOCLSub, cv::gapi::core::GSub) { static void run(const cv::UMat& a, const cv::UMat& b, int dtype, cv::UMat& out) { @@ -35,7 +35,7 @@ GAPI_GPU_KERNEL(GGPUSub, cv::gapi::core::GSub) } }; -GAPI_GPU_KERNEL(GGPUSubC, cv::gapi::core::GSubC) +GAPI_OCL_KERNEL(GOCLSubC, cv::gapi::core::GSubC) { static void run(const cv::UMat& a, const cv::Scalar& b, int dtype, cv::UMat& out) { @@ -43,7 +43,7 @@ GAPI_GPU_KERNEL(GGPUSubC, cv::gapi::core::GSubC) } }; -GAPI_GPU_KERNEL(GGPUSubRC, cv::gapi::core::GSubRC) +GAPI_OCL_KERNEL(GOCLSubRC, cv::gapi::core::GSubRC) { static void run(const cv::Scalar& a, const cv::UMat& b, int dtype, cv::UMat& out) { @@ -51,7 +51,7 @@ GAPI_GPU_KERNEL(GGPUSubRC, cv::gapi::core::GSubRC) } }; -GAPI_GPU_KERNEL(GGPUMul, cv::gapi::core::GMul) +GAPI_OCL_KERNEL(GOCLMul, cv::gapi::core::GMul) { static void run(const cv::UMat& a, const cv::UMat& b, double scale, int dtype, cv::UMat& out) { @@ -59,7 +59,7 @@ GAPI_GPU_KERNEL(GGPUMul, cv::gapi::core::GMul) } }; -GAPI_GPU_KERNEL(GGPUMulCOld, cv::gapi::core::GMulCOld) +GAPI_OCL_KERNEL(GOCLMulCOld, cv::gapi::core::GMulCOld) { static void run(const cv::UMat& a, double b, int dtype, cv::UMat& out) { @@ -67,7 +67,7 @@ GAPI_GPU_KERNEL(GGPUMulCOld, cv::gapi::core::GMulCOld) } }; -GAPI_GPU_KERNEL(GGPUMulC, cv::gapi::core::GMulC) +GAPI_OCL_KERNEL(GOCLMulC, cv::gapi::core::GMulC) { static void run(const cv::UMat& a, const cv::Scalar& b, int dtype, cv::UMat& out) { @@ -75,7 +75,7 @@ GAPI_GPU_KERNEL(GGPUMulC, cv::gapi::core::GMulC) } }; -GAPI_GPU_KERNEL(GGPUDiv, cv::gapi::core::GDiv) +GAPI_OCL_KERNEL(GOCLDiv, cv::gapi::core::GDiv) { static void run(const cv::UMat& a, const cv::UMat& b, double scale, int dtype, cv::UMat& out) { @@ -83,7 +83,7 @@ GAPI_GPU_KERNEL(GGPUDiv, cv::gapi::core::GDiv) } }; -GAPI_GPU_KERNEL(GGPUDivC, cv::gapi::core::GDivC) +GAPI_OCL_KERNEL(GOCLDivC, cv::gapi::core::GDivC) { static void run(const cv::UMat& a, const cv::Scalar& b, double scale, int dtype, cv::UMat& out) { @@ -91,7 +91,7 @@ GAPI_GPU_KERNEL(GGPUDivC, cv::gapi::core::GDivC) } }; -GAPI_GPU_KERNEL(GGPUDivRC, cv::gapi::core::GDivRC) +GAPI_OCL_KERNEL(GOCLDivRC, cv::gapi::core::GDivRC) { static void run(const cv::Scalar& a, const cv::UMat& b, double scale, int dtype, cv::UMat& out) { @@ -99,7 +99,7 @@ GAPI_GPU_KERNEL(GGPUDivRC, cv::gapi::core::GDivRC) } }; -GAPI_GPU_KERNEL(GGPUMask, cv::gapi::core::GMask) +GAPI_OCL_KERNEL(GOCLMask, cv::gapi::core::GMask) { static void run(const cv::UMat& in, const cv::UMat& mask, cv::UMat& out) { @@ -109,7 +109,7 @@ GAPI_GPU_KERNEL(GGPUMask, cv::gapi::core::GMask) }; -GAPI_GPU_KERNEL(GGPUMean, cv::gapi::core::GMean) +GAPI_OCL_KERNEL(GOCLMean, cv::gapi::core::GMean) { static void run(const cv::UMat& in, cv::Scalar& out) { @@ -117,7 +117,7 @@ GAPI_GPU_KERNEL(GGPUMean, cv::gapi::core::GMean) } }; -GAPI_GPU_KERNEL(GGPUPolarToCart, cv::gapi::core::GPolarToCart) +GAPI_OCL_KERNEL(GOCLPolarToCart, cv::gapi::core::GPolarToCart) { static void run(const cv::UMat& magn, const cv::UMat& angle, bool angleInDegrees, cv::UMat& outx, cv::UMat& outy) { @@ -125,7 +125,7 @@ GAPI_GPU_KERNEL(GGPUPolarToCart, cv::gapi::core::GPolarToCart) } }; -GAPI_GPU_KERNEL(GGPUCartToPolar, cv::gapi::core::GCartToPolar) +GAPI_OCL_KERNEL(GOCLCartToPolar, cv::gapi::core::GCartToPolar) { static void run(const cv::UMat& x, const cv::UMat& y, bool angleInDegrees, cv::UMat& outmagn, cv::UMat& outangle) { @@ -133,7 +133,7 @@ GAPI_GPU_KERNEL(GGPUCartToPolar, cv::gapi::core::GCartToPolar) } }; -GAPI_GPU_KERNEL(GGPUCmpGT, cv::gapi::core::GCmpGT) +GAPI_OCL_KERNEL(GOCLCmpGT, cv::gapi::core::GCmpGT) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -141,7 +141,7 @@ GAPI_GPU_KERNEL(GGPUCmpGT, cv::gapi::core::GCmpGT) } }; -GAPI_GPU_KERNEL(GGPUCmpGE, cv::gapi::core::GCmpGE) +GAPI_OCL_KERNEL(GOCLCmpGE, cv::gapi::core::GCmpGE) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -149,7 +149,7 @@ GAPI_GPU_KERNEL(GGPUCmpGE, cv::gapi::core::GCmpGE) } }; -GAPI_GPU_KERNEL(GGPUCmpLE, cv::gapi::core::GCmpLE) +GAPI_OCL_KERNEL(GOCLCmpLE, cv::gapi::core::GCmpLE) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -157,7 +157,7 @@ GAPI_GPU_KERNEL(GGPUCmpLE, cv::gapi::core::GCmpLE) } }; -GAPI_GPU_KERNEL(GGPUCmpLT, cv::gapi::core::GCmpLT) +GAPI_OCL_KERNEL(GOCLCmpLT, cv::gapi::core::GCmpLT) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -165,7 +165,7 @@ GAPI_GPU_KERNEL(GGPUCmpLT, cv::gapi::core::GCmpLT) } }; -GAPI_GPU_KERNEL(GGPUCmpEQ, cv::gapi::core::GCmpEQ) +GAPI_OCL_KERNEL(GOCLCmpEQ, cv::gapi::core::GCmpEQ) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -173,7 +173,7 @@ GAPI_GPU_KERNEL(GGPUCmpEQ, cv::gapi::core::GCmpEQ) } }; -GAPI_GPU_KERNEL(GGPUCmpNE, cv::gapi::core::GCmpNE) +GAPI_OCL_KERNEL(GOCLCmpNE, cv::gapi::core::GCmpNE) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -181,7 +181,7 @@ GAPI_GPU_KERNEL(GGPUCmpNE, cv::gapi::core::GCmpNE) } }; -GAPI_GPU_KERNEL(GGPUCmpGTScalar, cv::gapi::core::GCmpGTScalar) +GAPI_OCL_KERNEL(GOCLCmpGTScalar, cv::gapi::core::GCmpGTScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -189,7 +189,7 @@ GAPI_GPU_KERNEL(GGPUCmpGTScalar, cv::gapi::core::GCmpGTScalar) } }; -GAPI_GPU_KERNEL(GGPUCmpGEScalar, cv::gapi::core::GCmpGEScalar) +GAPI_OCL_KERNEL(GOCLCmpGEScalar, cv::gapi::core::GCmpGEScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -197,7 +197,7 @@ GAPI_GPU_KERNEL(GGPUCmpGEScalar, cv::gapi::core::GCmpGEScalar) } }; -GAPI_GPU_KERNEL(GGPUCmpLEScalar, cv::gapi::core::GCmpLEScalar) +GAPI_OCL_KERNEL(GOCLCmpLEScalar, cv::gapi::core::GCmpLEScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -205,7 +205,7 @@ GAPI_GPU_KERNEL(GGPUCmpLEScalar, cv::gapi::core::GCmpLEScalar) } }; -GAPI_GPU_KERNEL(GGPUCmpLTScalar, cv::gapi::core::GCmpLTScalar) +GAPI_OCL_KERNEL(GOCLCmpLTScalar, cv::gapi::core::GCmpLTScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -213,7 +213,7 @@ GAPI_GPU_KERNEL(GGPUCmpLTScalar, cv::gapi::core::GCmpLTScalar) } }; -GAPI_GPU_KERNEL(GGPUCmpEQScalar, cv::gapi::core::GCmpEQScalar) +GAPI_OCL_KERNEL(GOCLCmpEQScalar, cv::gapi::core::GCmpEQScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -221,7 +221,7 @@ GAPI_GPU_KERNEL(GGPUCmpEQScalar, cv::gapi::core::GCmpEQScalar) } }; -GAPI_GPU_KERNEL(GGPUCmpNEScalar, cv::gapi::core::GCmpNEScalar) +GAPI_OCL_KERNEL(GOCLCmpNEScalar, cv::gapi::core::GCmpNEScalar) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -229,7 +229,7 @@ GAPI_GPU_KERNEL(GGPUCmpNEScalar, cv::gapi::core::GCmpNEScalar) } }; -GAPI_GPU_KERNEL(GGPUAnd, cv::gapi::core::GAnd) +GAPI_OCL_KERNEL(GOCLAnd, cv::gapi::core::GAnd) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -237,7 +237,7 @@ GAPI_GPU_KERNEL(GGPUAnd, cv::gapi::core::GAnd) } }; -GAPI_GPU_KERNEL(GGPUAndS, cv::gapi::core::GAndS) +GAPI_OCL_KERNEL(GOCLAndS, cv::gapi::core::GAndS) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -245,7 +245,7 @@ GAPI_GPU_KERNEL(GGPUAndS, cv::gapi::core::GAndS) } }; -GAPI_GPU_KERNEL(GGPUOr, cv::gapi::core::GOr) +GAPI_OCL_KERNEL(GOCLOr, cv::gapi::core::GOr) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -253,7 +253,7 @@ GAPI_GPU_KERNEL(GGPUOr, cv::gapi::core::GOr) } }; -GAPI_GPU_KERNEL(GGPUOrS, cv::gapi::core::GOrS) +GAPI_OCL_KERNEL(GOCLOrS, cv::gapi::core::GOrS) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -261,7 +261,7 @@ GAPI_GPU_KERNEL(GGPUOrS, cv::gapi::core::GOrS) } }; -GAPI_GPU_KERNEL(GGPUXor, cv::gapi::core::GXor) +GAPI_OCL_KERNEL(GOCLXor, cv::gapi::core::GXor) { static void run(const cv::UMat& a, const cv::UMat& b, cv::UMat& out) { @@ -269,7 +269,7 @@ GAPI_GPU_KERNEL(GGPUXor, cv::gapi::core::GXor) } }; -GAPI_GPU_KERNEL(GGPUXorS, cv::gapi::core::GXorS) +GAPI_OCL_KERNEL(GOCLXorS, cv::gapi::core::GXorS) { static void run(const cv::UMat& a, const cv::Scalar& b, cv::UMat& out) { @@ -277,7 +277,7 @@ GAPI_GPU_KERNEL(GGPUXorS, cv::gapi::core::GXorS) } }; -GAPI_GPU_KERNEL(GGPUNot, cv::gapi::core::GNot) +GAPI_OCL_KERNEL(GOCLNot, cv::gapi::core::GNot) { static void run(const cv::UMat& a, cv::UMat& out) { @@ -285,7 +285,7 @@ GAPI_GPU_KERNEL(GGPUNot, cv::gapi::core::GNot) } }; -GAPI_GPU_KERNEL(GGPUSelect, cv::gapi::core::GSelect) +GAPI_OCL_KERNEL(GOCLSelect, cv::gapi::core::GSelect) { static void run(const cv::UMat& src1, const cv::UMat& src2, const cv::UMat& mask, cv::UMat& out) { @@ -295,7 +295,7 @@ GAPI_GPU_KERNEL(GGPUSelect, cv::gapi::core::GSelect) }; ////TODO: doesn't compiled with UMat -//GAPI_GPU_KERNEL(GGPUMin, cv::gapi::core::GMin) +//GAPI_OCL_KERNEL(GOCLMin, cv::gapi::core::GMin) //{ // static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out) // { @@ -304,7 +304,7 @@ GAPI_GPU_KERNEL(GGPUSelect, cv::gapi::core::GSelect) //}; // ////TODO: doesn't compiled with UMat -//GAPI_GPU_KERNEL(GGPUMax, cv::gapi::core::GMax) +//GAPI_OCL_KERNEL(GOCLMax, cv::gapi::core::GMax) //{ // static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out) // { @@ -313,7 +313,7 @@ GAPI_GPU_KERNEL(GGPUSelect, cv::gapi::core::GSelect) //}; -GAPI_GPU_KERNEL(GGPUAbsDiff, cv::gapi::core::GAbsDiff) +GAPI_OCL_KERNEL(GOCLAbsDiff, cv::gapi::core::GAbsDiff) { static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out) { @@ -321,7 +321,7 @@ GAPI_GPU_KERNEL(GGPUAbsDiff, cv::gapi::core::GAbsDiff) } }; -GAPI_GPU_KERNEL(GGPUAbsDiffC, cv::gapi::core::GAbsDiffC) +GAPI_OCL_KERNEL(GOCLAbsDiffC, cv::gapi::core::GAbsDiffC) { static void run(const cv::UMat& in1, const cv::Scalar& in2, cv::UMat& out) { @@ -329,7 +329,7 @@ GAPI_GPU_KERNEL(GGPUAbsDiffC, cv::gapi::core::GAbsDiffC) } }; -GAPI_GPU_KERNEL(GGPUSum, cv::gapi::core::GSum) +GAPI_OCL_KERNEL(GOCLSum, cv::gapi::core::GSum) { static void run(const cv::UMat& in, cv::Scalar& out) { @@ -337,7 +337,7 @@ GAPI_GPU_KERNEL(GGPUSum, cv::gapi::core::GSum) } }; -GAPI_GPU_KERNEL(GGPUAddW, cv::gapi::core::GAddW) +GAPI_OCL_KERNEL(GOCLAddW, cv::gapi::core::GAddW) { static void run(const cv::UMat& in1, double alpha, const cv::UMat& in2, double beta, double gamma, int dtype, cv::UMat& out) { @@ -346,7 +346,7 @@ GAPI_GPU_KERNEL(GGPUAddW, cv::gapi::core::GAddW) }; -GAPI_GPU_KERNEL(GGPUNormL1, cv::gapi::core::GNormL1) +GAPI_OCL_KERNEL(GOCLNormL1, cv::gapi::core::GNormL1) { static void run(const cv::UMat& in, cv::Scalar& out) { @@ -354,7 +354,7 @@ GAPI_GPU_KERNEL(GGPUNormL1, cv::gapi::core::GNormL1) } }; -GAPI_GPU_KERNEL(GGPUNormL2, cv::gapi::core::GNormL2) +GAPI_OCL_KERNEL(GOCLNormL2, cv::gapi::core::GNormL2) { static void run(const cv::UMat& in, cv::Scalar& out) { @@ -362,7 +362,7 @@ GAPI_GPU_KERNEL(GGPUNormL2, cv::gapi::core::GNormL2) } }; -GAPI_GPU_KERNEL(GGPUNormInf, cv::gapi::core::GNormInf) +GAPI_OCL_KERNEL(GOCLNormInf, cv::gapi::core::GNormInf) { static void run(const cv::UMat& in, cv::Scalar& out) { @@ -370,7 +370,7 @@ GAPI_GPU_KERNEL(GGPUNormInf, cv::gapi::core::GNormInf) } }; -GAPI_GPU_KERNEL(GGPUIntegral, cv::gapi::core::GIntegral) +GAPI_OCL_KERNEL(GOCLIntegral, cv::gapi::core::GIntegral) { static void run(const cv::UMat& in, int sdepth, int sqdepth, cv::UMat& out, cv::UMat& outSq) { @@ -378,7 +378,7 @@ GAPI_GPU_KERNEL(GGPUIntegral, cv::gapi::core::GIntegral) } }; -GAPI_GPU_KERNEL(GGPUThreshold, cv::gapi::core::GThreshold) +GAPI_OCL_KERNEL(GOCLThreshold, cv::gapi::core::GThreshold) { static void run(const cv::UMat& in, const cv::Scalar& a, const cv::Scalar& b, int type, cv::UMat& out) { @@ -386,7 +386,7 @@ GAPI_GPU_KERNEL(GGPUThreshold, cv::gapi::core::GThreshold) } }; -GAPI_GPU_KERNEL(GGPUThresholdOT, cv::gapi::core::GThresholdOT) +GAPI_OCL_KERNEL(GOCLThresholdOT, cv::gapi::core::GThresholdOT) { static void run(const cv::UMat& in, const cv::Scalar& b, int type, cv::UMat& out, cv::Scalar& outScalar) { @@ -395,7 +395,7 @@ GAPI_GPU_KERNEL(GGPUThresholdOT, cv::gapi::core::GThresholdOT) }; -GAPI_GPU_KERNEL(GGPUInRange, cv::gapi::core::GInRange) +GAPI_OCL_KERNEL(GOCLInRange, cv::gapi::core::GInRange) { static void run(const cv::UMat& in, const cv::Scalar& low, const cv::Scalar& up, cv::UMat& out) { @@ -403,7 +403,7 @@ GAPI_GPU_KERNEL(GGPUInRange, cv::gapi::core::GInRange) } }; -GAPI_GPU_KERNEL(GGPUSplit3, cv::gapi::core::GSplit3) +GAPI_OCL_KERNEL(GOCLSplit3, cv::gapi::core::GSplit3) { static void run(const cv::UMat& in, cv::UMat &m1, cv::UMat &m2, cv::UMat &m3) { @@ -417,7 +417,7 @@ GAPI_GPU_KERNEL(GGPUSplit3, cv::gapi::core::GSplit3) } }; -GAPI_GPU_KERNEL(GGPUSplit4, cv::gapi::core::GSplit4) +GAPI_OCL_KERNEL(GOCLSplit4, cv::gapi::core::GSplit4) { static void run(const cv::UMat& in, cv::UMat &m1, cv::UMat &m2, cv::UMat &m3, cv::UMat &m4) { @@ -432,7 +432,7 @@ GAPI_GPU_KERNEL(GGPUSplit4, cv::gapi::core::GSplit4) } }; -GAPI_GPU_KERNEL(GGPUMerge3, cv::gapi::core::GMerge3) +GAPI_OCL_KERNEL(GOCLMerge3, cv::gapi::core::GMerge3) { static void run(const cv::UMat& in1, const cv::UMat& in2, const cv::UMat& in3, cv::UMat &out) { @@ -441,7 +441,7 @@ GAPI_GPU_KERNEL(GGPUMerge3, cv::gapi::core::GMerge3) } }; -GAPI_GPU_KERNEL(GGPUMerge4, cv::gapi::core::GMerge4) +GAPI_OCL_KERNEL(GOCLMerge4, cv::gapi::core::GMerge4) { static void run(const cv::UMat& in1, const cv::UMat& in2, const cv::UMat& in3, const cv::UMat& in4, cv::UMat &out) { @@ -450,7 +450,7 @@ GAPI_GPU_KERNEL(GGPUMerge4, cv::gapi::core::GMerge4) } }; -GAPI_GPU_KERNEL(GGPUResize, cv::gapi::core::GResize) +GAPI_OCL_KERNEL(GOCLResize, cv::gapi::core::GResize) { static void run(const cv::UMat& in, cv::Size sz, double fx, double fy, int interp, cv::UMat &out) { @@ -458,7 +458,7 @@ GAPI_GPU_KERNEL(GGPUResize, cv::gapi::core::GResize) } }; -GAPI_GPU_KERNEL(GGPURemap, cv::gapi::core::GRemap) +GAPI_OCL_KERNEL(GOCLRemap, cv::gapi::core::GRemap) { static void run(const cv::UMat& in, const cv::Mat& x, const cv::Mat& y, int a, int b, cv::Scalar s, cv::UMat& out) { @@ -466,7 +466,7 @@ GAPI_GPU_KERNEL(GGPURemap, cv::gapi::core::GRemap) } }; -GAPI_GPU_KERNEL(GGPUFlip, cv::gapi::core::GFlip) +GAPI_OCL_KERNEL(GOCLFlip, cv::gapi::core::GFlip) { static void run(const cv::UMat& in, int code, cv::UMat& out) { @@ -474,7 +474,7 @@ GAPI_GPU_KERNEL(GGPUFlip, cv::gapi::core::GFlip) } }; -GAPI_GPU_KERNEL(GGPUCrop, cv::gapi::core::GCrop) +GAPI_OCL_KERNEL(GOCLCrop, cv::gapi::core::GCrop) { static void run(const cv::UMat& in, cv::Rect rect, cv::UMat& out) { @@ -482,7 +482,7 @@ GAPI_GPU_KERNEL(GGPUCrop, cv::gapi::core::GCrop) } }; -GAPI_GPU_KERNEL(GGPUConcatHor, cv::gapi::core::GConcatHor) +GAPI_OCL_KERNEL(GOCLConcatHor, cv::gapi::core::GConcatHor) { static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out) { @@ -490,7 +490,7 @@ GAPI_GPU_KERNEL(GGPUConcatHor, cv::gapi::core::GConcatHor) } }; -GAPI_GPU_KERNEL(GGPUConcatVert, cv::gapi::core::GConcatVert) +GAPI_OCL_KERNEL(GOCLConcatVert, cv::gapi::core::GConcatVert) { static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out) { @@ -498,7 +498,7 @@ GAPI_GPU_KERNEL(GGPUConcatVert, cv::gapi::core::GConcatVert) } }; -GAPI_GPU_KERNEL(GGPULUT, cv::gapi::core::GLUT) +GAPI_OCL_KERNEL(GOCLLUT, cv::gapi::core::GLUT) { static void run(const cv::UMat& in, const cv::Mat& lut, cv::UMat& out) { @@ -506,7 +506,7 @@ GAPI_GPU_KERNEL(GGPULUT, cv::gapi::core::GLUT) } }; -GAPI_GPU_KERNEL(GGPUConvertTo, cv::gapi::core::GConvertTo) +GAPI_OCL_KERNEL(GOCLConvertTo, cv::gapi::core::GConvertTo) { static void run(const cv::UMat& in, int rtype, double alpha, double beta, cv::UMat& out) { @@ -514,69 +514,69 @@ GAPI_GPU_KERNEL(GGPUConvertTo, cv::gapi::core::GConvertTo) } }; -cv::gapi::GKernelPackage cv::gapi::core::gpu::kernels() +cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels() { static auto pkg = cv::gapi::kernels - < GGPUAdd - , GGPUAddC - , GGPUSub - , GGPUSubC - , GGPUSubRC - , GGPUMul - , GGPUMulC - , GGPUMulCOld - , GGPUDiv - , GGPUDivC - , GGPUDivRC - , GGPUMean - , GGPUMask - , GGPUPolarToCart - , GGPUCartToPolar - , GGPUCmpGT - , GGPUCmpGE - , GGPUCmpLE - , GGPUCmpLT - , GGPUCmpEQ - , GGPUCmpNE - , GGPUCmpGTScalar - , GGPUCmpGEScalar - , GGPUCmpLEScalar - , GGPUCmpLTScalar - , GGPUCmpEQScalar - , GGPUCmpNEScalar - , GGPUAnd - , GGPUAndS - , GGPUOr - , GGPUOrS - , GGPUXor - , GGPUXorS - , GGPUNot - , GGPUSelect - //, GGPUMin - //, GGPUMax - , GGPUAbsDiff - , GGPUAbsDiffC - , GGPUSum - , GGPUAddW - , GGPUNormL1 - , GGPUNormL2 - , GGPUNormInf - , GGPUIntegral - , GGPUThreshold - , GGPUThresholdOT - , GGPUInRange - , GGPUSplit3 - , GGPUSplit4 - , GGPUResize - , GGPUMerge3 - , GGPUMerge4 - , GGPURemap - , GGPUFlip - , GGPUCrop - , GGPUConcatHor - , GGPUConcatVert - , GGPULUT - , GGPUConvertTo + < GOCLAdd + , GOCLAddC + , GOCLSub + , GOCLSubC + , GOCLSubRC + , GOCLMul + , GOCLMulC + , GOCLMulCOld + , GOCLDiv + , GOCLDivC + , GOCLDivRC + , GOCLMean + , GOCLMask + , GOCLPolarToCart + , GOCLCartToPolar + , GOCLCmpGT + , GOCLCmpGE + , GOCLCmpLE + , GOCLCmpLT + , GOCLCmpEQ + , GOCLCmpNE + , GOCLCmpGTScalar + , GOCLCmpGEScalar + , GOCLCmpLEScalar + , GOCLCmpLTScalar + , GOCLCmpEQScalar + , GOCLCmpNEScalar + , GOCLAnd + , GOCLAndS + , GOCLOr + , GOCLOrS + , GOCLXor + , GOCLXorS + , GOCLNot + , GOCLSelect + //, GOCLMin + //, GOCLMax + , GOCLAbsDiff + , GOCLAbsDiffC + , GOCLSum + , GOCLAddW + , GOCLNormL1 + , GOCLNormL2 + , GOCLNormInf + , GOCLIntegral + , GOCLThreshold + , GOCLThresholdOT + , GOCLInRange + , GOCLSplit3 + , GOCLSplit4 + , GOCLResize + , GOCLMerge3 + , GOCLMerge4 + , GOCLRemap + , GOCLFlip + , GOCLCrop + , GOCLConcatHor + , GOCLConcatVert + , GOCLLUT + , GOCLConvertTo >(); return pkg; } diff --git a/modules/gapi/src/backends/gpu/ggpucore.hpp b/modules/gapi/src/backends/ocl/goclcore.hpp similarity index 65% rename from modules/gapi/src/backends/gpu/ggpucore.hpp rename to modules/gapi/src/backends/ocl/goclcore.hpp index 47cbfa6bdd..fb6b78ad12 100644 --- a/modules/gapi/src/backends/gpu/ggpucore.hpp +++ b/modules/gapi/src/backends/ocl/goclcore.hpp @@ -5,20 +5,20 @@ // Copyright (C) 2018 Intel Corporation -#ifndef OPENCV_GAPI_GGPUCORE_HPP -#define OPENCV_GAPI_GGPUCORE_HPP +#ifndef OPENCV_GAPI_GOCLCORE_HPP +#define OPENCV_GAPI_GOCLCORE_HPP #include #include -#include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/ocl/goclkernel.hpp" namespace cv { namespace gimpl { // NB: This is what a "Kernel Package" from the original Wiki doc should be. -void loadGPUCore(std::map &kmap); +void loadOCLCore(std::map &kmap); } } -#endif // OPENCV_GAPI_GGPUCORE_HPP +#endif // OPENCV_GAPI_GOCLCORE_HPP diff --git a/modules/gapi/src/backends/gpu/ggpuimgproc.cpp b/modules/gapi/src/backends/ocl/goclimgproc.cpp similarity index 79% rename from modules/gapi/src/backends/gpu/ggpuimgproc.cpp rename to modules/gapi/src/backends/ocl/goclimgproc.cpp index 9b7aca1a26..6e99d00d95 100644 --- a/modules/gapi/src/backends/gpu/ggpuimgproc.cpp +++ b/modules/gapi/src/backends/ocl/goclimgproc.cpp @@ -8,11 +8,11 @@ #include "precomp.hpp" #include "opencv2/gapi/imgproc.hpp" -#include "opencv2/gapi/gpu/imgproc.hpp" -#include "backends/gpu/ggpuimgproc.hpp" +#include "opencv2/gapi/ocl/imgproc.hpp" +#include "backends/ocl/goclimgproc.hpp" -GAPI_GPU_KERNEL(GGPUSepFilter, cv::gapi::imgproc::GSepFilter) +GAPI_OCL_KERNEL(GOCLSepFilter, cv::gapi::imgproc::GSepFilter) { static void run(const cv::UMat& in, int ddepth, const cv::Mat& kernX, const cv::Mat& kernY, const cv::Point& anchor, const cv::Scalar& delta, int border, const cv::Scalar& bordVal, cv::UMat &out) @@ -31,7 +31,7 @@ GAPI_GPU_KERNEL(GGPUSepFilter, cv::gapi::imgproc::GSepFilter) } }; -GAPI_GPU_KERNEL(GGPUBoxFilter, cv::gapi::imgproc::GBoxFilter) +GAPI_OCL_KERNEL(GOCLBoxFilter, cv::gapi::imgproc::GBoxFilter) { static void run(const cv::UMat& in, int ddepth, const cv::Size& ksize, const cv::Point& anchor, bool normalize, int borderType, const cv::Scalar& bordVal, cv::UMat &out) { @@ -49,7 +49,7 @@ GAPI_GPU_KERNEL(GGPUBoxFilter, cv::gapi::imgproc::GBoxFilter) } }; -GAPI_GPU_KERNEL(GGPUBlur, cv::gapi::imgproc::GBlur) +GAPI_OCL_KERNEL(GOCLBlur, cv::gapi::imgproc::GBlur) { static void run(const cv::UMat& in, const cv::Size& ksize, const cv::Point& anchor, int borderType, const cv::Scalar& bordVal, cv::UMat &out) { @@ -68,7 +68,7 @@ GAPI_GPU_KERNEL(GGPUBlur, cv::gapi::imgproc::GBlur) }; -GAPI_GPU_KERNEL(GGPUFilter2D, cv::gapi::imgproc::GFilter2D) +GAPI_OCL_KERNEL(GOCLFilter2D, cv::gapi::imgproc::GFilter2D) { static void run(const cv::UMat& in, int ddepth, const cv::Mat& k, const cv::Point& anchor, const cv::Scalar& delta, int border, const cv::Scalar& bordVal, cv::UMat &out) @@ -87,7 +87,7 @@ GAPI_GPU_KERNEL(GGPUFilter2D, cv::gapi::imgproc::GFilter2D) } }; -GAPI_GPU_KERNEL(GGPUGaussBlur, cv::gapi::imgproc::GGaussBlur) +GAPI_OCL_KERNEL(GOCLGaussBlur, cv::gapi::imgproc::GGaussBlur) { static void run(const cv::UMat& in, const cv::Size& ksize, double sigmaX, double sigmaY, int borderType, const cv::Scalar& bordVal, cv::UMat &out) { @@ -105,7 +105,7 @@ GAPI_GPU_KERNEL(GGPUGaussBlur, cv::gapi::imgproc::GGaussBlur) } }; -GAPI_GPU_KERNEL(GGPUMedianBlur, cv::gapi::imgproc::GMedianBlur) +GAPI_OCL_KERNEL(GOCLMedianBlur, cv::gapi::imgproc::GMedianBlur) { static void run(const cv::UMat& in, int ksize, cv::UMat &out) { @@ -113,7 +113,7 @@ GAPI_GPU_KERNEL(GGPUMedianBlur, cv::gapi::imgproc::GMedianBlur) } }; -GAPI_GPU_KERNEL(GGPUErode, cv::gapi::imgproc::GErode) +GAPI_OCL_KERNEL(GOCLErode, cv::gapi::imgproc::GErode) { static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out) { @@ -121,7 +121,7 @@ GAPI_GPU_KERNEL(GGPUErode, cv::gapi::imgproc::GErode) } }; -GAPI_GPU_KERNEL(GGPUDilate, cv::gapi::imgproc::GDilate) +GAPI_OCL_KERNEL(GOCLDilate, cv::gapi::imgproc::GDilate) { static void run(const cv::UMat& in, const cv::Mat& kernel, const cv::Point& anchor, int iterations, int borderType, const cv::Scalar& borderValue, cv::UMat &out) { @@ -129,7 +129,7 @@ GAPI_GPU_KERNEL(GGPUDilate, cv::gapi::imgproc::GDilate) } }; -GAPI_GPU_KERNEL(GGPUSobel, cv::gapi::imgproc::GSobel) +GAPI_OCL_KERNEL(GOCLSobel, cv::gapi::imgproc::GSobel) { static void run(const cv::UMat& in, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType, const cv::Scalar& bordVal, cv::UMat &out) @@ -147,7 +147,7 @@ GAPI_GPU_KERNEL(GGPUSobel, cv::gapi::imgproc::GSobel) } }; -GAPI_GPU_KERNEL(GGPUEqualizeHist, cv::gapi::imgproc::GEqHist) +GAPI_OCL_KERNEL(GOCLEqualizeHist, cv::gapi::imgproc::GEqHist) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -155,7 +155,7 @@ GAPI_GPU_KERNEL(GGPUEqualizeHist, cv::gapi::imgproc::GEqHist) } }; -GAPI_GPU_KERNEL(GGPUCanny, cv::gapi::imgproc::GCanny) +GAPI_OCL_KERNEL(GOCLCanny, cv::gapi::imgproc::GCanny) { static void run(const cv::UMat& in, double thr1, double thr2, int apSize, bool l2gradient, cv::UMat &out) { @@ -163,7 +163,7 @@ GAPI_GPU_KERNEL(GGPUCanny, cv::gapi::imgproc::GCanny) } }; -GAPI_GPU_KERNEL(GGPURGB2YUV, cv::gapi::imgproc::GRGB2YUV) +GAPI_OCL_KERNEL(GOCLRGB2YUV, cv::gapi::imgproc::GRGB2YUV) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -171,7 +171,7 @@ GAPI_GPU_KERNEL(GGPURGB2YUV, cv::gapi::imgproc::GRGB2YUV) } }; -GAPI_GPU_KERNEL(GGPUYUV2RGB, cv::gapi::imgproc::GYUV2RGB) +GAPI_OCL_KERNEL(GOCLYUV2RGB, cv::gapi::imgproc::GYUV2RGB) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -179,7 +179,7 @@ GAPI_GPU_KERNEL(GGPUYUV2RGB, cv::gapi::imgproc::GYUV2RGB) } }; -GAPI_GPU_KERNEL(GGPURGB2Lab, cv::gapi::imgproc::GRGB2Lab) +GAPI_OCL_KERNEL(GOCLRGB2Lab, cv::gapi::imgproc::GRGB2Lab) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -187,7 +187,7 @@ GAPI_GPU_KERNEL(GGPURGB2Lab, cv::gapi::imgproc::GRGB2Lab) } }; -GAPI_GPU_KERNEL(GGPUBGR2LUV, cv::gapi::imgproc::GBGR2LUV) +GAPI_OCL_KERNEL(GOCLBGR2LUV, cv::gapi::imgproc::GBGR2LUV) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -195,7 +195,7 @@ GAPI_GPU_KERNEL(GGPUBGR2LUV, cv::gapi::imgproc::GBGR2LUV) } }; -GAPI_GPU_KERNEL(GGPUBGR2YUV, cv::gapi::imgproc::GBGR2YUV) +GAPI_OCL_KERNEL(GOCLBGR2YUV, cv::gapi::imgproc::GBGR2YUV) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -203,7 +203,7 @@ GAPI_GPU_KERNEL(GGPUBGR2YUV, cv::gapi::imgproc::GBGR2YUV) } }; -GAPI_GPU_KERNEL(GGPULUV2BGR, cv::gapi::imgproc::GLUV2BGR) +GAPI_OCL_KERNEL(GOCLLUV2BGR, cv::gapi::imgproc::GLUV2BGR) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -211,7 +211,7 @@ GAPI_GPU_KERNEL(GGPULUV2BGR, cv::gapi::imgproc::GLUV2BGR) } }; -GAPI_GPU_KERNEL(GGPUYUV2BGR, cv::gapi::imgproc::GYUV2BGR) +GAPI_OCL_KERNEL(GOCLYUV2BGR, cv::gapi::imgproc::GYUV2BGR) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -219,7 +219,7 @@ GAPI_GPU_KERNEL(GGPUYUV2BGR, cv::gapi::imgproc::GYUV2BGR) } }; -GAPI_GPU_KERNEL(GGPURGB2Gray, cv::gapi::imgproc::GRGB2Gray) +GAPI_OCL_KERNEL(GOCLRGB2Gray, cv::gapi::imgproc::GRGB2Gray) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -227,7 +227,7 @@ GAPI_GPU_KERNEL(GGPURGB2Gray, cv::gapi::imgproc::GRGB2Gray) } }; -GAPI_GPU_KERNEL(GGPUBGR2Gray, cv::gapi::imgproc::GBGR2Gray) +GAPI_OCL_KERNEL(GOCLBGR2Gray, cv::gapi::imgproc::GBGR2Gray) { static void run(const cv::UMat& in, cv::UMat &out) { @@ -235,7 +235,7 @@ GAPI_GPU_KERNEL(GGPUBGR2Gray, cv::gapi::imgproc::GBGR2Gray) } }; -GAPI_GPU_KERNEL(GGPURGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom) +GAPI_OCL_KERNEL(GOCLRGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom) { //TODO: avoid copy static void run(const cv::UMat& in, float rY, float bY, float gY, cv::UMat &out) @@ -248,30 +248,30 @@ GAPI_GPU_KERNEL(GGPURGB2GrayCustom, cv::gapi::imgproc::GRGB2GrayCustom) }; -cv::gapi::GKernelPackage cv::gapi::imgproc::gpu::kernels() +cv::gapi::GKernelPackage cv::gapi::imgproc::ocl::kernels() { static auto pkg = cv::gapi::kernels - < GGPUFilter2D - , GGPUSepFilter - , GGPUBoxFilter - , GGPUBlur - , GGPUGaussBlur - , GGPUMedianBlur - , GGPUErode - , GGPUDilate - , GGPUSobel - , GGPUCanny - , GGPUEqualizeHist - , GGPURGB2YUV - , GGPUYUV2RGB - , GGPURGB2Lab - , GGPUBGR2LUV - , GGPUBGR2YUV - , GGPUYUV2BGR - , GGPULUV2BGR - , GGPUBGR2Gray - , GGPURGB2Gray - , GGPURGB2GrayCustom + < GOCLFilter2D + , GOCLSepFilter + , GOCLBoxFilter + , GOCLBlur + , GOCLGaussBlur + , GOCLMedianBlur + , GOCLErode + , GOCLDilate + , GOCLSobel + , GOCLCanny + , GOCLEqualizeHist + , GOCLRGB2YUV + , GOCLYUV2RGB + , GOCLRGB2Lab + , GOCLBGR2LUV + , GOCLBGR2YUV + , GOCLYUV2BGR + , GOCLLUV2BGR + , GOCLBGR2Gray + , GOCLRGB2Gray + , GOCLRGB2GrayCustom >(); return pkg; } diff --git a/modules/gapi/src/backends/gpu/ggpuimgproc.hpp b/modules/gapi/src/backends/ocl/goclimgproc.hpp similarity index 64% rename from modules/gapi/src/backends/gpu/ggpuimgproc.hpp rename to modules/gapi/src/backends/ocl/goclimgproc.hpp index cd2e324e61..7bb18f0a76 100644 --- a/modules/gapi/src/backends/gpu/ggpuimgproc.hpp +++ b/modules/gapi/src/backends/ocl/goclimgproc.hpp @@ -5,19 +5,19 @@ // Copyright (C) 2018 Intel Corporation -#ifndef OPENCV_GAPI_GGPUIMGPROC_HPP -#define OPENCV_GAPI_GGPUIMGPROC_HPP +#ifndef OPENCV_GAPI_GOCLIMGPROC_HPP +#define OPENCV_GAPI_GOCLIMGPROC_HPP #include #include -#include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/ocl/goclkernel.hpp" namespace cv { namespace gimpl { // NB: This is what a "Kernel Package" from the origianl Wiki doc should be. -void loadGPUImgProc(std::map &kmap); +void loadOCLImgProc(std::map &kmap); }} -#endif // OPENCV_GAPI_GGPUIMGPROC_HPP +#endif // OPENCV_GAPI_GOCLIMGPROC_HPP diff --git a/modules/gapi/src/backends/gpu/ggpukernel.cpp b/modules/gapi/src/backends/ocl/goclkernel.cpp similarity index 58% rename from modules/gapi/src/backends/gpu/ggpukernel.cpp rename to modules/gapi/src/backends/ocl/goclkernel.cpp index 87e2aa97e9..d01aae8373 100644 --- a/modules/gapi/src/backends/gpu/ggpukernel.cpp +++ b/modules/gapi/src/backends/ocl/goclkernel.cpp @@ -7,43 +7,43 @@ #include -#include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/ocl/goclkernel.hpp" -const cv::UMat& cv::GGPUContext::inMat(int input) +const cv::UMat& cv::GOCLContext::inMat(int input) { return (inArg(input)); } -cv::UMat& cv::GGPUContext::outMatR(int output) +cv::UMat& cv::GOCLContext::outMatR(int output) { return (*(util::get(m_results.at(output)))); } -const cv::gapi::own::Scalar& cv::GGPUContext::inVal(int input) +const cv::gapi::own::Scalar& cv::GOCLContext::inVal(int input) { return inArg(input); } -cv::gapi::own::Scalar& cv::GGPUContext::outValR(int output) +cv::gapi::own::Scalar& cv::GOCLContext::outValR(int output) { return *util::get(m_results.at(output)); } -cv::detail::VectorRef& cv::GGPUContext::outVecRef(int output) +cv::detail::VectorRef& cv::GOCLContext::outVecRef(int output) { return util::get(m_results.at(output)); } -cv::GGPUKernel::GGPUKernel() +cv::GOCLKernel::GOCLKernel() { } -cv::GGPUKernel::GGPUKernel(const GGPUKernel::F &f) +cv::GOCLKernel::GOCLKernel(const GOCLKernel::F &f) : m_f(f) { } -void cv::GGPUKernel::apply(GGPUContext &ctx) +void cv::GOCLKernel::apply(GOCLContext &ctx) { CV_Assert(m_f); m_f(ctx); diff --git a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp index 98333151ff..5ee3f650af 100644 --- a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp +++ b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp @@ -7,7 +7,6 @@ #include "../test_precomp.hpp" #include "../common/gapi_core_tests.hpp" -#include "opencv2/gapi/gpu/core.hpp" #define CORE_GPU cv::gapi::core::gpu::kernels() diff --git a/modules/gapi/test/gpu/gapi_imgproc_tests_gpu.cpp b/modules/gapi/test/gpu/gapi_imgproc_tests_gpu.cpp index 47b6aefdec..92e23e8ba8 100644 --- a/modules/gapi/test/gpu/gapi_imgproc_tests_gpu.cpp +++ b/modules/gapi/test/gpu/gapi_imgproc_tests_gpu.cpp @@ -8,7 +8,6 @@ #include "../test_precomp.hpp" #include "../common/gapi_imgproc_tests.hpp" -#include "opencv2/gapi/gpu/imgproc.hpp" #define IMGPROC_GPU cv::gapi::imgproc::gpu::kernels() diff --git a/modules/gapi/test/gpu/gapi_operators_tests_gpu.cpp b/modules/gapi/test/gpu/gapi_operators_tests_gpu.cpp index 5a116bd35e..73b1c78f34 100644 --- a/modules/gapi/test/gpu/gapi_operators_tests_gpu.cpp +++ b/modules/gapi/test/gpu/gapi_operators_tests_gpu.cpp @@ -7,7 +7,6 @@ #include "../test_precomp.hpp" #include "../common/gapi_operators_tests.hpp" -#include "opencv2/gapi/gpu/core.hpp" #define CORE_GPU cv::gapi::core::gpu::kernels() diff --git a/modules/gapi/test/test_precomp.hpp b/modules/gapi/test/test_precomp.hpp index bcab803ba1..9fb0e4d4f1 100644 --- a/modules/gapi/test/test_precomp.hpp +++ b/modules/gapi/test/test_precomp.hpp @@ -19,6 +19,8 @@ #include "opencv2/gapi/core.hpp" #include "opencv2/gapi/cpu/gcpukernel.hpp" #include "opencv2/gapi/gpu/ggpukernel.hpp" +#include "opencv2/gapi/gpu/imgproc.hpp" +#include "opencv2/gapi/gpu/core.hpp" #include "opencv2/gapi/gcompoundkernel.hpp" #include "opencv2/gapi/operators.hpp" #include "opencv2/gapi/fluid/imgproc.hpp"