From aed799370d9b17e7c277406b6679c1d84cdb27c6 Mon Sep 17 00:00:00 2001 From: Anton Potapov Date: Tue, 12 Jan 2021 12:12:03 +0300 Subject: [PATCH] [G-API] Adding GMat operators to the standalone mode --- modules/gapi/cmake/standalone.cmake | 2 ++ modules/gapi/include/opencv2/gapi/core.hpp | 11 +++++++++-- modules/gapi/include/opencv2/gapi/own/mat.hpp | 2 ++ modules/gapi/src/api/kernels_core.cpp | 4 ++++ modules/gapi/src/api/operators.cpp | 1 - 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/gapi/cmake/standalone.cmake b/modules/gapi/cmake/standalone.cmake index d08eda1be5eb..3a5a47e25ab0 100644 --- a/modules/gapi/cmake/standalone.cmake +++ b/modules/gapi/cmake/standalone.cmake @@ -15,6 +15,8 @@ file(GLOB FLUID_includes "${FLUID_ROOT}/include/opencv2/*.hpp" "${FLUID_ROOT}/include/opencv2/gapi/own/*.hpp" "${FLUID_ROOT}/include/opencv2/gapi/fluid/*.hpp") file(GLOB FLUID_sources "${FLUID_ROOT}/src/api/g*.cpp" + "${FLUID_ROOT}/src/api/kernels_core.cpp" + "${FLUID_ROOT}/src/api/operators.cpp" "${FLUID_ROOT}/src/api/rmat.cpp" "${FLUID_ROOT}/src/api/media.cpp" "${FLUID_ROOT}/src/compiler/*.cpp" diff --git a/modules/gapi/include/opencv2/gapi/core.hpp b/modules/gapi/include/opencv2/gapi/core.hpp index a01a8902b6fd..bd7b478fd700 100644 --- a/modules/gapi/include/opencv2/gapi/core.hpp +++ b/modules/gapi/include/opencv2/gapi/core.hpp @@ -12,8 +12,6 @@ #include // std::tuple -#include - #include #include #include @@ -505,6 +503,8 @@ namespace core { } }; + +#if !defined(GAPI_STANDALONE) G_TYPED_KERNEL( GKMeansND, ,GMat,GMat>(GMat,int,GMat,TermCriteria,int,KmeansFlags)>, @@ -575,6 +575,8 @@ namespace core { return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc()); } }; + +#endif //!defined(GAPI_STANDALONE) } // namespace core namespace streaming { @@ -1392,6 +1394,7 @@ CV_64F. */ GAPI_EXPORTS std::tuple integral(const GMat& src, int sdepth = -1, int sqdepth = -1); +#if !defined(GAPI_STANDALONE) /** @brief Applies a fixed-level threshold to each matrix element. The function applies fixed-level thresholding to a single- or multiple-channel matrix. @@ -1441,6 +1444,8 @@ Input and output matrices must be CV_8UC1. @sa threshold */ +#endif //!defined(GAPI_STANDALONE) + GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp); //! @} gapi_matrixop @@ -1848,6 +1853,7 @@ GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, i int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar()); //! @} gapi_transform +#if !defined(GAPI_STANDALONE) /** @brief Finds centers of clusters and groups input samples around the clusters. The function kmeans implements a k-means algorithm that finds the centers of K clusters @@ -1941,6 +1947,7 @@ Gets dimensions from rectangle. */ GAPI_EXPORTS GOpaque size(const GOpaque& r); } //namespace streaming +#endif //!defined(GAPI_STANDALONE) } //namespace gapi } //namespace cv diff --git a/modules/gapi/include/opencv2/gapi/own/mat.hpp b/modules/gapi/include/opencv2/gapi/own/mat.hpp index ce9c0bf36238..ed51e5a6af64 100644 --- a/modules/gapi/include/opencv2/gapi/own/mat.hpp +++ b/modules/gapi/include/opencv2/gapi/own/mat.hpp @@ -209,6 +209,8 @@ namespace cv { namespace gapi { namespace own { */ int depth() const {return CV_MAT_DEPTH(flags);} + Size size() const { return Size{rows, cols};} + /** @brief Returns the number of matrix channels. The method returns the number of matrix channels. diff --git a/modules/gapi/src/api/kernels_core.cpp b/modules/gapi/src/api/kernels_core.cpp index 8ff992a0aa23..0de9fa10566e 100644 --- a/modules/gapi/src/api/kernels_core.cpp +++ b/modules/gapi/src/api/kernels_core.cpp @@ -264,6 +264,7 @@ std::tuple integral(const GMat& src, int sdepth, int sqdepth) return core::GIntegral::on(src, sdepth, sqdepth); } +#if !defined(GAPI_STANDALONE) GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type) { GAPI_Assert(type != cv::THRESH_TRIANGLE && type != cv::THRESH_OTSU); @@ -275,6 +276,7 @@ std::tuple threshold(const GMat& src, const GScalar& maxval, int GAPI_Assert(type == cv::THRESH_TRIANGLE || type == cv::THRESH_OTSU); return core::GThresholdOT::on(src, maxval, type); } +#endif //!defined(GAPI_STANDALONE) GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp) { @@ -383,6 +385,7 @@ GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags, return core::GWarpAffine::on(src, M, dsize, flags, borderMode, borderValue); } +#if !defined(GAPI_STANDALONE) std::tuple,GMat,GMat> kmeans(const GMat& data, const int K, const GMat& bestLabels, const TermCriteria& criteria, const int attempts, const KmeansFlags flags) @@ -426,6 +429,7 @@ GOpaque streaming::size(const GOpaque& r) { return streaming::GSizeR::on(r); } +#endif //!defined(GAPI_STANDALONE) } //namespace gapi } //namespace cv diff --git a/modules/gapi/src/api/operators.cpp b/modules/gapi/src/api/operators.cpp index 44bf3250761e..676b4d9439be 100644 --- a/modules/gapi/src/api/operators.cpp +++ b/modules/gapi/src/api/operators.cpp @@ -7,7 +7,6 @@ #include "precomp.hpp" -#include #include #include #include