Add stateful kernel to python G-API
This commit is contained in:
@@ -31,17 +31,26 @@ struct GPythonContext
|
||||
const cv::GArgs &ins;
|
||||
const cv::GMetaArgs &in_metas;
|
||||
const cv::GTypesInfo &out_info;
|
||||
|
||||
bool m_isStateful;
|
||||
|
||||
GArg m_state;
|
||||
};
|
||||
|
||||
using Impl = std::function<cv::GRunArgs(const GPythonContext&)>;
|
||||
using Setup = std::function<cv::GArg(const GMetaArgs&, const GArgs&)>;
|
||||
|
||||
class GAPI_EXPORTS GPythonKernel
|
||||
{
|
||||
public:
|
||||
GPythonKernel() = default;
|
||||
GPythonKernel(Impl run);
|
||||
GPythonKernel(Impl run, Setup setup);
|
||||
|
||||
cv::GRunArgs operator()(const GPythonContext& ctx);
|
||||
|
||||
bool m_isStateful = false;
|
||||
Setup m_setup = nullptr;
|
||||
|
||||
private:
|
||||
Impl m_run;
|
||||
};
|
||||
@@ -51,7 +60,8 @@ class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor
|
||||
public:
|
||||
using Meta = cv::GKernel::M;
|
||||
|
||||
GPythonFunctor(const char* id, const Meta &meta, const Impl& impl);
|
||||
GPythonFunctor(const char* id, const Meta& meta, const Impl& impl,
|
||||
const Setup& setup = nullptr);
|
||||
|
||||
GKernelImpl impl() const override;
|
||||
gapi::GBackend backend() const override;
|
||||
|
||||
Reference in New Issue
Block a user