// 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) 2021 Intel Corporation #ifndef OPENCV_GAPI_PYTHON_BRIDGE_HPP #define OPENCV_GAPI_PYTHON_BRIDGE_HPP #include #include #include #define ID(T, E) T #define ID_(T, E) ID(T, E), #define WRAP_ARGS(T, E, G) \ G(T, E) #define SWITCH(type, LIST_G, HC) \ switch(type) { \ LIST_G(HC, HC) \ default: \ GAPI_Assert(false && "Unsupported type"); \ } #define GARRAY_TYPE_LIST_G(G, G2) \ WRAP_ARGS(bool , cv::gapi::ArgType::CV_BOOL, G) \ WRAP_ARGS(int , cv::gapi::ArgType::CV_INT, G) \ WRAP_ARGS(int64_t , cv::gapi::ArgType::CV_INT64, G) \ WRAP_ARGS(double , cv::gapi::ArgType::CV_DOUBLE, G) \ WRAP_ARGS(float , cv::gapi::ArgType::CV_FLOAT, G) \ WRAP_ARGS(std::string , cv::gapi::ArgType::CV_STRING, G) \ WRAP_ARGS(cv::Point , cv::gapi::ArgType::CV_POINT, G) \ WRAP_ARGS(cv::Point2f , cv::gapi::ArgType::CV_POINT2F, G) \ WRAP_ARGS(cv::Size , cv::gapi::ArgType::CV_SIZE, G) \ WRAP_ARGS(cv::Rect , cv::gapi::ArgType::CV_RECT, G) \ WRAP_ARGS(cv::Scalar , cv::gapi::ArgType::CV_SCALAR, G) \ WRAP_ARGS(cv::Mat , cv::gapi::ArgType::CV_MAT, G) \ WRAP_ARGS(cv::GArg , cv::gapi::ArgType::CV_ANY, G) \ WRAP_ARGS(cv::GMat , cv::gapi::ArgType::CV_GMAT, G2) \ #define GOPAQUE_TYPE_LIST_G(G, G2) \ WRAP_ARGS(bool , cv::gapi::ArgType::CV_BOOL, G) \ WRAP_ARGS(int , cv::gapi::ArgType::CV_INT, G) \ WRAP_ARGS(int64_t , cv::gapi::ArgType::CV_INT64, G) \ WRAP_ARGS(double , cv::gapi::ArgType::CV_DOUBLE, G) \ WRAP_ARGS(float , cv::gapi::ArgType::CV_FLOAT, G) \ WRAP_ARGS(std::string , cv::gapi::ArgType::CV_STRING, G) \ WRAP_ARGS(cv::Point , cv::gapi::ArgType::CV_POINT, G) \ WRAP_ARGS(cv::Point2f , cv::gapi::ArgType::CV_POINT2F, G) \ WRAP_ARGS(cv::Size , cv::gapi::ArgType::CV_SIZE, G) \ WRAP_ARGS(cv::GArg , cv::gapi::ArgType::CV_ANY, G) \ WRAP_ARGS(cv::Rect , cv::gapi::ArgType::CV_RECT, G2) \ namespace cv { namespace gapi { // NB: cv.gapi.CV_BOOL in python enum ArgType { CV_BOOL, CV_INT, CV_INT64, CV_DOUBLE, CV_FLOAT, CV_STRING, CV_POINT, CV_POINT2F, CV_SIZE, CV_RECT, CV_SCALAR, CV_MAT, CV_GMAT, CV_ANY, }; GAPI_EXPORTS_W inline cv::GInferOutputs infer(const String& name, const cv::GInferInputs& inputs) { return infer(name, inputs); } GAPI_EXPORTS_W inline GInferOutputs infer(const std::string& name, const cv::GOpaque& roi, const GInferInputs& inputs) { return infer(name, roi, inputs); } GAPI_EXPORTS_W inline GInferListOutputs infer(const std::string& name, const cv::GArray& rois, const GInferInputs& inputs) { return infer(name, rois, inputs); } GAPI_EXPORTS_W inline GInferListOutputs infer2(const std::string& name, const cv::GMat in, const GInferListInputs& inputs) { return infer2(name, in, inputs); } } // namespace gapi namespace detail { template