1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #18762 from TolyaTalamanov:at/support-garray

[G-API] Wrap GArray

* Wrap GArray for output

* Collect in/out info in graph

* Add imgproc tests

* Add cv::Point2f

* Update test_gapi_imgproc.py

* Fix comments to review
This commit is contained in:
Anatoliy Talamanov
2020-11-27 20:39:46 +03:00
committed by GitHub
parent 2155296a13
commit 7521f207b1
20 changed files with 400 additions and 104 deletions
@@ -368,6 +368,8 @@ private:
detail::GArrayU m_ref;
};
using GArrayP2f = GArray<cv::Point2f>;
/** @} */
} // namespace cv
@@ -49,6 +49,7 @@ namespace detail
CV_UINT64, // uint64_t user G-API data
CV_STRING, // std::string user G-API data
CV_POINT, // cv::Point user G-API data
CV_POINT2F, // cv::Point2f user G-API data
CV_SIZE, // cv::Size user G-API data
CV_RECT, // cv::Rect user G-API data
CV_SCALAR, // cv::Scalar user G-API data
@@ -68,15 +69,16 @@ namespace detail
template<> struct GOpaqueTraits<cv::Size> { static constexpr const OpaqueKind kind = OpaqueKind::CV_SIZE; };
template<> struct GOpaqueTraits<cv::Scalar> { static constexpr const OpaqueKind kind = OpaqueKind::CV_SCALAR; };
template<> struct GOpaqueTraits<cv::Point> { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT; };
template<> struct GOpaqueTraits<cv::Point2f> { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT2F; };
template<> struct GOpaqueTraits<cv::Mat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
template<> struct GOpaqueTraits<cv::Rect> { static constexpr const OpaqueKind kind = OpaqueKind::CV_RECT; };
template<> struct GOpaqueTraits<cv::GMat> { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; };
template<> struct GOpaqueTraits<cv::gapi::wip::draw::Prim>
{ static constexpr const OpaqueKind kind = OpaqueKind::CV_DRAW_PRIM; };
using GOpaqueTraitsArrayTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Scalar, cv::Point,
using GOpaqueTraitsArrayTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Scalar, cv::Point, cv::Point2f,
cv::Mat, cv::Rect, cv::gapi::wip::draw::Prim>;
// GOpaque is not supporting cv::Mat and cv::Scalar since there are GScalar and GMat types
using GOpaqueTraitsOpaqueTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Point, cv::Rect,
using GOpaqueTraitsOpaqueTypes = std::tuple<int, double, float, uint64_t, bool, std::string, cv::Size, cv::Point, cv::Point2f, cv::Rect,
cv::gapi::wip::draw::Prim>;
} // namespace detail
+10 -3
View File
@@ -26,9 +26,16 @@
namespace cv {
using GShapes = std::vector<GShape>;
using GKinds = std::vector<cv::detail::OpaqueKind>;
using GCtors = std::vector<detail::HostCtor>;
struct GTypeInfo
{
GShape shape;
cv::detail::OpaqueKind kind;
};
using GShapes = std::vector<GShape>;
using GKinds = std::vector<cv::detail::OpaqueKind>;
using GCtors = std::vector<detail::HostCtor>;
using GTypesInfo = std::vector<GTypeInfo>;
// GKernel describes kernel API to the system
// FIXME: add attributes of a kernel, (e.g. number and types
@@ -1035,7 +1035,7 @@ or #cornerMinEigenVal.
@return vector of detected corners.
*/
GAPI_EXPORTS GArray<Point2f> goodFeaturesToTrack(const GMat &image,
GAPI_EXPORTS_W GArray<Point2f> goodFeaturesToTrack(const GMat &image,
int maxCorners,
double qualityLevel,
double minDistance,
@@ -1350,7 +1350,7 @@ Resulting gray color value computed as
@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
@sa RGB2YUV
*/
GAPI_EXPORTS GMat RGB2Gray(const GMat& src);
GAPI_EXPORTS_W GMat RGB2Gray(const GMat& src);
/** @overload
Resulting gray color value computed as
@@ -21,11 +21,12 @@
# 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;
using Rect = gapi::own::Rect;
using Size = gapi::own::Size;
using Point = gapi::own::Point;
using Point2f = gapi::own::Point2f;
using Scalar = gapi::own::Scalar;
using Mat = gapi::own::Mat;
} // namespace cv
#endif // !defined(GAPI_STANDALONE)
@@ -28,6 +28,16 @@ public:
int y = 0;
};
class Point2f
{
public:
Point2f() = default;
Point2f(float _x, float _y) : x(_x), y(_y) {};
float x = 0.f;
float y = 0.f;
};
class Rect
{
public:
@@ -121,6 +121,9 @@ GAPI_EXPORTS std::unique_ptr<IIStream> getInStream(const std::vector<char> &p);
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point &pt);
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point &pt);
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point2f &pt);
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point2f &pt);
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Size &sz);
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Size &sz);