From: Anatoliy Talamanov Date: Tue, 9 Feb 2021 13:55:16 +0000 (+0300) Subject: Merge pull request #19319 from TolyaTalamanov:at/introduce-gopaque-garray-for-python X-Git-Tag: accepted/tizen/unified/20220125.121719~1^2~213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c527b3cefd1ef67a6cd9c583d4a9fe21e3d67564;p=platform%2Fupstream%2Fopencv.git Merge pull request #19319 from TolyaTalamanov:at/introduce-gopaque-garray-for-python [G-API] Introduce GOpaque and GArray for python * Introduce GOpaque and GArray for python * Fix ctor * Avoid code duplication by using macros * gapi: move Python-specific files to misc/python * Fix windows build Co-authored-by: Alexander Alekhin --- diff --git a/modules/gapi/misc/python/python_bridge.hpp b/modules/gapi/misc/python/python_bridge.hpp new file mode 100644 index 0000000..cf5daa6 --- /dev/null +++ b/modules/gapi/misc/python/python_bridge.hpp @@ -0,0 +1,167 @@ +// 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(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::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(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, G2) \ + +namespace cv { +namespace gapi { + +// NB: cv.gapi.CV_BOOL in python +enum ArgType { + CV_BOOL, + CV_INT, + CV_DOUBLE, + CV_FLOAT, + CV_STRING, + CV_POINT, + CV_POINT2F, + CV_SIZE, + CV_RECT, + CV_SCALAR, + CV_MAT, + CV_GMAT, +}; + +} // namespace gapi + +namespace detail { + +template