G-API: Integrated cv::MediaFrame as I/O type + CPU backend
This commit is contained in:
@@ -164,7 +164,7 @@ template<> struct get_in<cv::GMatP>
|
||||
};
|
||||
template<> struct get_in<cv::GFrame>
|
||||
{
|
||||
static cv::Mat get(GCPUContext &ctx, int idx) { return get_in<cv::GMat>::get(ctx, idx); }
|
||||
static cv::MediaFrame get(GCPUContext &ctx, int idx) { return ctx.inArg<cv::MediaFrame>(idx); }
|
||||
};
|
||||
template<> struct get_in<cv::GScalar>
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
#include <opencv2/gapi/media.hpp>
|
||||
|
||||
#include <opencv2/gapi/util/any.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
@@ -21,6 +22,7 @@
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/gframe.hpp>
|
||||
#include <opencv2/gapi/gtype_traits.hpp>
|
||||
#include <opencv2/gapi/gmetaarg.hpp>
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
@@ -100,7 +102,8 @@ using GRunArg = util::variant<
|
||||
cv::Mat,
|
||||
cv::Scalar,
|
||||
cv::detail::VectorRef,
|
||||
cv::detail::OpaqueRef
|
||||
cv::detail::OpaqueRef,
|
||||
cv::MediaFrame
|
||||
>;
|
||||
using GRunArgs = std::vector<GRunArg>;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
};
|
||||
/** @} */
|
||||
|
||||
enum class MediaFormat
|
||||
enum class MediaFormat: int
|
||||
{
|
||||
BGR = 0,
|
||||
NV12,
|
||||
@@ -56,6 +56,8 @@ struct GAPI_EXPORTS GFrameDesc
|
||||
{
|
||||
MediaFormat fmt;
|
||||
cv::Size size;
|
||||
|
||||
bool operator== (const GFrameDesc &) const;
|
||||
};
|
||||
static inline GFrameDesc empty_gframe_desc() { return GFrameDesc{}; }
|
||||
/** @} */
|
||||
|
||||
@@ -95,11 +95,12 @@ namespace detail
|
||||
template<typename T> struct MetaType;
|
||||
template<> struct MetaType<cv::GMat> { using type = GMatDesc; };
|
||||
template<> struct MetaType<cv::GMatP> { using type = GMatDesc; };
|
||||
template<> struct MetaType<cv::GFrame> { using type = GMatDesc; };
|
||||
template<> struct MetaType<cv::GFrame> { using type = GFrameDesc; };
|
||||
template<> struct MetaType<cv::GScalar> { using type = GScalarDesc; };
|
||||
template<typename U> struct MetaType<cv::GArray<U> > { using type = GArrayDesc; };
|
||||
template<typename U> struct MetaType<cv::GOpaque<U> > { using type = GOpaqueDesc; };
|
||||
template<typename T> struct MetaType { using type = T; }; // opaque args passed as-is
|
||||
// FIXME: Move it to type traits?
|
||||
|
||||
// 2. Hacky test based on MetaType to check if we operate on G-* type or not
|
||||
template<typename T> using is_nongapi_type = std::is_same<T, typename MetaType<T>::type>;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/garray.hpp>
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/gframe.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -38,6 +39,7 @@ using GMetaArg = util::variant
|
||||
, GScalarDesc
|
||||
, GArrayDesc
|
||||
, GOpaqueDesc
|
||||
, GFrameDesc
|
||||
>;
|
||||
GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <opencv2/gapi/gopaque.hpp>
|
||||
#include <opencv2/gapi/gframe.hpp>
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/gapi/media.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
|
||||
namespace cv
|
||||
@@ -67,7 +68,7 @@ namespace detail
|
||||
template<> struct GTypeTraits<cv::GFrame>
|
||||
{
|
||||
static constexpr const ArgKind kind = ArgKind::GFRAME;
|
||||
static constexpr const GShape shape = GShape::GMAT;
|
||||
static constexpr const GShape shape = GShape::GFRAME;
|
||||
static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN;
|
||||
};
|
||||
template<> struct GTypeTraits<cv::GScalar>
|
||||
@@ -125,6 +126,7 @@ namespace detail
|
||||
template<> struct GTypeOf<cv::Scalar> { using type = cv::GScalar; };
|
||||
template<typename U> struct GTypeOf<std::vector<U> > { using type = cv::GArray<U>; };
|
||||
template<typename U> struct GTypeOf { using type = cv::GOpaque<U>;};
|
||||
template<> struct GTypeOf<cv::MediaFrame> { using type = cv::GFrame; };
|
||||
// FIXME: This is not quite correct since IStreamSource may produce not only Mat but also Scalar
|
||||
// and vector data. TODO: Extend the type dispatching on these types too.
|
||||
template<> struct GTypeOf<cv::gapi::wip::IStreamSource::Ptr> { using type = cv::GMat;};
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
explicit MediaFrame(AdapterPtr &&);
|
||||
template<class T, class... Args> static cv::MediaFrame Create(Args&&...);
|
||||
|
||||
View access(Access);
|
||||
View access(Access) const;
|
||||
cv::GFrameDesc desc() const;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user