Merge pull request #19009 from TolyaTalamanov:at/media-frame-copy
[G-API] GStreamingBackend * Snapshot * Implement StreamingBackend * Refactoring * Refactoring 2 * Clean up * Add missing functionality to support MediaFrame as output * Partially address review comments * Fix build * Implement reshape for gstreamingbackend and add a test on it * Address more comments * Add format.hpp to gapi.hpp * Fix debug build * Address review comments Co-authored-by: Smirnov Alexey <alexey.smirnov@intel.com>
This commit is contained in:
committed by
GitHub
parent
9f01b97e14
commit
8ed0fc6f0c
@@ -33,8 +33,9 @@
|
||||
#include <opencv2/gapi/gkernel.hpp>
|
||||
#include <opencv2/gapi/operators.hpp>
|
||||
|
||||
// Include this file here to avoid cyclic dependency between
|
||||
// Include these files here to avoid cyclic dependency between
|
||||
// Desync & GKernel & GComputation & GStreamingCompiled.
|
||||
#include <opencv2/gapi/streaming/desync.hpp>
|
||||
#include <opencv2/gapi/streaming/format.hpp>
|
||||
|
||||
#endif // OPENCV_GAPI_HPP
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
|
||||
const cv::Scalar& inVal(int input);
|
||||
cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR()
|
||||
cv::MediaFrame& outFrame(int output);
|
||||
template<typename T> std::vector<T>& outVecR(int output) // FIXME: the same issue
|
||||
{
|
||||
return outVecRef(output).wref<T>();
|
||||
@@ -258,6 +259,13 @@ template<> struct get_out<cv::GScalar>
|
||||
return ctx.outValR(idx);
|
||||
}
|
||||
};
|
||||
template<> struct get_out<cv::GFrame>
|
||||
{
|
||||
static cv::MediaFrame& get(GCPUContext &ctx, int idx)
|
||||
{
|
||||
return ctx.outFrame(idx);
|
||||
}
|
||||
};
|
||||
template<typename U> struct get_out<cv::GArray<U>>
|
||||
{
|
||||
static std::vector<U>& get(GCPUContext &ctx, int idx)
|
||||
|
||||
@@ -210,6 +210,7 @@ using GRunArgP = util::variant<
|
||||
cv::Mat*,
|
||||
cv::RMat*,
|
||||
cv::Scalar*,
|
||||
cv::MediaFrame*,
|
||||
cv::detail::VectorRef,
|
||||
cv::detail::OpaqueRef
|
||||
>;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <opencv2/gapi/garg.hpp> // GArg
|
||||
#include <opencv2/gapi/gmat.hpp> // GMat
|
||||
#include <opencv2/gapi/gscalar.hpp> // GScalar
|
||||
#include <opencv2/gapi/gframe.hpp> // GFrame
|
||||
#include <opencv2/gapi/garray.hpp> // GArray<T>
|
||||
#include <opencv2/gapi/gopaque.hpp> // GOpaque<T>
|
||||
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
GMat yield (int output = 0);
|
||||
GMatP yieldP (int output = 0);
|
||||
GScalar yieldScalar(int output = 0);
|
||||
GFrame yieldFrame (int output = 0);
|
||||
|
||||
template<class T> GArray<T> yieldArray(int output = 0)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,9 @@ struct GAPI_EXPORTS GFrameDesc
|
||||
static inline GFrameDesc empty_gframe_desc() { return GFrameDesc{}; }
|
||||
/** @} */
|
||||
|
||||
class MediaFrame;
|
||||
GAPI_EXPORTS GFrameDesc descr_of(const MediaFrame &frame);
|
||||
|
||||
GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GFrameDesc &desc);
|
||||
|
||||
} // namespace cv
|
||||
|
||||
@@ -90,6 +90,10 @@ namespace detail
|
||||
{
|
||||
static inline cv::GOpaque<U> yield(cv::GCall &call, int i) { return call.yieldOpaque<U>(i); }
|
||||
};
|
||||
template<> struct Yield<GFrame>
|
||||
{
|
||||
static inline cv::GFrame yield(cv::GCall &call, int i) { return call.yieldFrame(i); }
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Helper classes which brings outputMeta() marshalling to kernel
|
||||
@@ -239,8 +243,6 @@ public:
|
||||
using InArgs = std::tuple<Args...>;
|
||||
using OutArgs = std::tuple<R>;
|
||||
|
||||
static_assert(!cv::detail::contains<GFrame, OutArgs>::value, "Values of GFrame type can't be used as operation outputs");
|
||||
|
||||
static R on(Args... args)
|
||||
{
|
||||
cv::GCall call(GKernel{ K::id()
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_GSTREAMING_FORMAT_HPP
|
||||
#define OPENCV_GAPI_GSTREAMING_FORMAT_HPP
|
||||
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace streaming {
|
||||
|
||||
cv::gapi::GKernelPackage kernels();
|
||||
cv::gapi::GBackend backend();
|
||||
|
||||
// FIXME: Make a generic kernel
|
||||
G_API_OP(GCopy, <GFrame(GFrame)>, "org.opencv.streaming.copy")
|
||||
{
|
||||
static GFrameDesc outMeta(const GFrameDesc& in) { return in; }
|
||||
};
|
||||
|
||||
G_API_OP(GBGR, <GMat(GFrame)>, "org.opencv.streaming.BGR")
|
||||
{
|
||||
static GMatDesc outMeta(const GFrameDesc& in) { return GMatDesc{CV_8U, 3, in.size}; }
|
||||
};
|
||||
|
||||
/** @brief Gets copy from the input frame
|
||||
|
||||
@note Function textual ID is "org.opencv.streaming.copy"
|
||||
|
||||
@param in Input frame
|
||||
@return Copy of the input frame
|
||||
*/
|
||||
GAPI_EXPORTS cv::GFrame copy(const cv::GFrame& in);
|
||||
|
||||
/** @brief Gets bgr plane from input frame
|
||||
|
||||
@note Function textual ID is "org.opencv.streaming.BGR"
|
||||
|
||||
@param in Input frame
|
||||
@return Image in BGR format
|
||||
*/
|
||||
GAPI_EXPORTS cv::GMat BGR (const cv::GFrame& in);
|
||||
|
||||
} // namespace streaming
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GSTREAMING_FORMAT_HPP
|
||||
Reference in New Issue
Block a user