|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPENCV_GAPI_PYTHON_API_HPP
|
|
|
#define OPENCV_GAPI_PYTHON_API_HPP
|
|
|
|
|
|
#include <opencv2/gapi/gkernel.hpp>
|
|
|
#include <opencv2/gapi/own/exports.hpp>
|
|
|
|
|
|
namespace cv {
|
|
|
namespace gapi {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace python {
|
|
|
|
|
|
GAPI_EXPORTS cv::gapi::GBackend backend();
|
|
|
|
|
|
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, Setup setup);
|
|
|
|
|
|
Impl run;
|
|
|
Setup setup = nullptr;
|
|
|
bool is_stateful = false;
|
|
|
};
|
|
|
|
|
|
class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor
|
|
|
{
|
|
|
public:
|
|
|
using Meta = cv::GKernel::M;
|
|
|
|
|
|
GPythonFunctor(const char* id, const Meta& meta, const Impl& impl,
|
|
|
const Setup& setup = nullptr);
|
|
|
|
|
|
GKernelImpl impl() const override;
|
|
|
gapi::GBackend backend() const override;
|
|
|
|
|
|
private:
|
|
|
GKernelImpl impl_;
|
|
|
};
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|