G-API: "deownification" corrections
authorAnton Potapov <anton.potapov@intel.com>
Tue, 12 May 2020 11:06:50 +0000 (14:06 +0300)
committerAnton Potapov <anton.potapov@intel.com>
Tue, 12 May 2020 11:28:32 +0000 (14:28 +0300)
- moved "standalone" aliases of cv types to "opencv_includes.hpp" to
keep responsibility principle aplied
- introduced correct aliasing for "descr_of(Mat)" function for
standalone case
 - added missing include in `gapi/own/mat.hpp`

modules/gapi/include/opencv2/gapi/gmat.hpp
modules/gapi/include/opencv2/gapi/opencv_includes.hpp
modules/gapi/include/opencv2/gapi/own/cvdefs.hpp
modules/gapi/include/opencv2/gapi/own/mat.hpp
modules/gapi/src/api/gmat.cpp
modules/gapi/src/api/gscalar.cpp

index 91f6332..5430f14 100644 (file)
@@ -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
index 5acf280..5f25fe4 100644 (file)
 #  include <opencv2/core/base.hpp>
 #else   // Without OpenCV
 #  include <opencv2/gapi/own/cvdefs.hpp>
+#  include <opencv2/gapi/own/types.hpp>  // cv::gapi::own::Rect/Size/Point
+#  include <opencv2/gapi/own/scalar.hpp> // cv::gapi::own::Scalar
+#  include <opencv2/gapi/own/mat.hpp>
+// 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
index 008cdd6..9ec0f89 100644 (file)
@@ -9,9 +9,6 @@
 #define OPENCV_GAPI_CV_DEFS_HPP
 
 #if defined(GAPI_STANDALONE)
-#include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Rect/Size/Point
-#include <opencv2/gapi/own/scalar.hpp> // 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 )
index a5f5b5e..15fb9a3 100644 (file)
@@ -17,6 +17,7 @@
 #include <memory>                   //std::shared_ptr
 #include <cstring>                  //std::memcpy
 #include <numeric>                  //std::accumulate
+#include <vector>
 #include <opencv2/gapi/util/throw.hpp>
 
 namespace cv { namespace gapi { namespace own {
index 527dbb3..de33c39 100644 (file)
@@ -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)
 {
index accc242..bd3e463 100644 (file)
@@ -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();