diff --git a/modules/gapi/include/opencv2/gapi/gmat.hpp b/modules/gapi/include/opencv2/gapi/gmat.hpp index 91f6332a10..5430f14581 100644 --- a/modules/gapi/include/opencv2/gapi/gmat.hpp +++ b/modules/gapi/include/opencv2/gapi/gmat.hpp @@ -209,15 +209,20 @@ static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; } GAPI_EXPORTS GMatDesc descr_of(const cv::UMat &mat); #endif // !defined(GAPI_STANDALONE) -GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat); -/** @} */ - -// FIXME: WHY??? WHY it is under different namespace? +//Fwd declarations namespace gapi { namespace own { class Mat; GAPI_EXPORTS GMatDesc descr_of(const Mat &mat); }}//gapi::own +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat); +#else +using gapi::own::descr_of; +#endif + +/** @} */ + GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc); } // namespace cv diff --git a/modules/gapi/include/opencv2/gapi/opencv_includes.hpp b/modules/gapi/include/opencv2/gapi/opencv_includes.hpp index 5acf28023d..5f25fe4af7 100644 --- a/modules/gapi/include/opencv2/gapi/opencv_includes.hpp +++ b/modules/gapi/include/opencv2/gapi/opencv_includes.hpp @@ -16,6 +16,17 @@ # include #else // Without OpenCV # include +# include // cv::gapi::own::Rect/Size/Point +# include // cv::gapi::own::Scalar +# include +// replacement of cv's structures: +namespace cv { + using Rect = gapi::own::Rect; + using Size = gapi::own::Size; + using Point = gapi::own::Point; + using Scalar = gapi::own::Scalar; + using Mat = gapi::own::Mat; +} // namespace cv #endif // !defined(GAPI_STANDALONE) #endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP diff --git a/modules/gapi/include/opencv2/gapi/own/cvdefs.hpp b/modules/gapi/include/opencv2/gapi/own/cvdefs.hpp index 008cdd6f7a..9ec0f89ed8 100644 --- a/modules/gapi/include/opencv2/gapi/own/cvdefs.hpp +++ b/modules/gapi/include/opencv2/gapi/own/cvdefs.hpp @@ -9,9 +9,6 @@ #define OPENCV_GAPI_CV_DEFS_HPP #if defined(GAPI_STANDALONE) -#include // cv::gapi::own::Rect/Size/Point -#include // cv::gapi::own::Scalar - // Simulate OpenCV definitions taken from various // OpenCV interface headers if G-API is built in a // standalone mode. @@ -139,15 +136,6 @@ enum InterpolationFlags{ INTER_LINEAR_EXACT = 5, INTER_MAX = 7, }; -// replacement of cv's structures: -namespace gapi { namespace own { -class Mat; -}} // namespace gapi::own -using Rect = gapi::own::Rect; -using Size = gapi::own::Size; -using Point = gapi::own::Point; -using Scalar = gapi::own::Scalar; -using Mat = gapi::own::Mat; } // namespace cv static inline int cvFloor( double value ) diff --git a/modules/gapi/include/opencv2/gapi/own/mat.hpp b/modules/gapi/include/opencv2/gapi/own/mat.hpp index a5f5b5e3bd..15fb9a3762 100644 --- a/modules/gapi/include/opencv2/gapi/own/mat.hpp +++ b/modules/gapi/include/opencv2/gapi/own/mat.hpp @@ -17,6 +17,7 @@ #include //std::shared_ptr #include //std::memcpy #include //std::accumulate +#include #include namespace cv { namespace gapi { namespace own { diff --git a/modules/gapi/src/api/gmat.cpp b/modules/gapi/src/api/gmat.cpp index 527dbb3f70..de33c39b0d 100644 --- a/modules/gapi/src/api/gmat.cpp +++ b/modules/gapi/src/api/gmat.cpp @@ -48,9 +48,9 @@ namespace{ } } +#if !defined(GAPI_STANDALONE) cv::GMatDesc cv::descr_of(const cv::Mat &mat) { -#if !defined(GAPI_STANDALONE) const auto mat_dims = mat.size.dims(); if (mat_dims == 2) @@ -62,12 +62,8 @@ cv::GMatDesc cv::descr_of(const cv::Mat &mat) dims[i] = mat.size[i]; } return GMatDesc{mat.depth(), std::move(dims)}; -#else - return (mat.dims.empty()) - ? GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}} - : GMatDesc{mat.depth(), mat.dims}; -#endif } +#endif cv::GMatDesc cv::gapi::own::descr_of(const Mat &mat) { diff --git a/modules/gapi/src/api/gscalar.cpp b/modules/gapi/src/api/gscalar.cpp index accc242368..bd3e46364a 100644 --- a/modules/gapi/src/api/gscalar.cpp +++ b/modules/gapi/src/api/gscalar.cpp @@ -46,6 +46,8 @@ const cv::GOrigin& cv::GScalar::priv() const return *m_priv; } +//N.B. if we ever need more complicated logic for desc_of(cv::(gapi::own::)Scalar) +//dispatching should be done in the same way as for cv::(gapi::own)::Mat cv::GScalarDesc cv::descr_of(const cv::Scalar &) { return empty_scalar_desc();