mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #22037 from xiong-jie-y:py_gapi_add_state_kernel
Add stateful kernel to python G-API
This commit is contained in:
@@ -31,19 +31,22 @@ struct GPythonContext
|
||||
const cv::GArgs &ins;
|
||||
const cv::GMetaArgs &in_metas;
|
||||
const cv::GTypesInfo &out_info;
|
||||
|
||||
cv::optional<cv::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);
|
||||
private:
|
||||
Impl m_run;
|
||||
Impl run;
|
||||
Setup setup = nullptr;
|
||||
bool is_stateful = false;
|
||||
};
|
||||
|
||||
class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor
|
||||
@@ -51,7 +54,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