Download modules/gapi/misc/python/python_bridge.hpp from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 11.2 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/gapi/misc/python/python_bridge.hpp
- Command line
-
hf download hf://tgollogly/test/modules/gapi/misc/python/python_bridge.hpp
-
curl -L -o python_bridge.hpp https://huggingface.co/tgollogly/test/resolve/main/modules/gapi/misc/python/python_bridge.hpp
11.2 kB
| // 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 | |
| using cv::gapi::wip::draw::Prim; | |
| namespace cv { | |
| namespace gapi { | |
| // NB: cv.gapi.CV_BOOL in python | |
| enum ArgType { | |
| CV_BOOL, | |
| CV_INT, | |
| CV_INT64, | |
| CV_UINT64, | |
| CV_DOUBLE, | |
| CV_FLOAT, | |
| CV_STRING, | |
| CV_POINT, | |
| CV_POINT2F, | |
| CV_POINT3F, | |
| CV_SIZE, | |
| CV_RECT, | |
| CV_SCALAR, | |
| CV_MAT, | |
| CV_GMAT, | |
| CV_DRAW_PRIM, | |
| CV_ANY, | |
| }; | |
| GAPI_EXPORTS_W inline cv::GInferOutputs infer(const String& name, const cv::GInferInputs& inputs) | |
| { | |
| return infer<Generic>(name, inputs); | |
| } | |
| GAPI_EXPORTS_W inline GInferOutputs infer(const std::string& name, | |
| const cv::GOpaque<cv::Rect>& roi, | |
| const GInferInputs& inputs) | |
| { | |
| return infer<Generic>(name, roi, inputs); | |
| } | |
| GAPI_EXPORTS_W inline GInferListOutputs infer(const std::string& name, | |
| const cv::GArray<cv::Rect>& rois, | |
| const GInferInputs& inputs) | |
| { | |
| return infer<Generic>(name, rois, inputs); | |
| } | |
| GAPI_EXPORTS_W inline GInferListOutputs infer2(const std::string& name, | |
| const cv::GMat in, | |
| const GInferListInputs& inputs) | |
| { | |
| return infer2<Generic>(name, in, inputs); | |
| } | |
| } // namespace gapi | |
| namespace detail { | |
| template <template <typename> class Wrapper, typename T> | |
| struct WrapType { using type = Wrapper<T>; }; | |
| template <template <typename> class T, typename... Types> | |
| using MakeVariantType = cv::util::variant<typename WrapType<T, Types>::type...>; | |
| template<typename T> struct ArgTypeTraits; | |
| GARRAY_TYPE_LIST_G(DEFINE_TYPE_TRAITS, DEFINE_TYPE_TRAITS) | |
| } // namespace detail | |
| class GAPI_EXPORTS_W_SIMPLE GOpaqueT | |
| { | |
| public: | |
| GOpaqueT() = default; | |
| using Storage = cv::detail::MakeVariantType<cv::GOpaque, GOPAQUE_TYPE_LIST_G(ID_, ID)>; | |
| template<typename T> | |
| GOpaqueT(cv::GOpaque<T> arg) : m_type(cv::detail::ArgTypeTraits<T>::type), m_arg(arg) { } | |
| GAPI_WRAP GOpaqueT(gapi::ArgType type) : m_type(type) | |
| { | |
| SWITCH(type, GOPAQUE_TYPE_LIST_G, HC) | |
| } | |
| cv::detail::GOpaqueU strip() { | |
| SWITCH(m_arg.index(), GOPAQUE_TYPE_LIST_G, HC) | |
| GAPI_Error("InternalError"); | |
| } | |
| GAPI_WRAP gapi::ArgType type() { return m_type; } | |
| const Storage& arg() const { return m_arg; } | |
| private: | |
| gapi::ArgType m_type; | |
| Storage m_arg; | |
| }; | |
| class GAPI_EXPORTS_W_SIMPLE GArrayT | |
| { | |
| public: | |
| GArrayT() = default; | |
| using Storage = cv::detail::MakeVariantType<cv::GArray, GARRAY_TYPE_LIST_G(ID_, ID)>; | |
| template<typename T> | |
| GArrayT(cv::GArray<T> arg) : m_type(cv::detail::ArgTypeTraits<T>::type), m_arg(arg) { } | |
| GAPI_WRAP GArrayT(gapi::ArgType type) : m_type(type) | |
| { | |
| SWITCH(type, GARRAY_TYPE_LIST_G, HC) | |
| } | |
| cv::detail::GArrayU strip() { | |
| SWITCH(m_arg.index(), GARRAY_TYPE_LIST_G, HC) | |
| GAPI_Error("InternalError"); | |
| } | |
| GAPI_WRAP gapi::ArgType type() { return m_type; } | |
| const Storage& arg() const { return m_arg; } | |
| private: | |
| gapi::ArgType m_type; | |
| Storage m_arg; | |
| }; | |
| namespace gapi { | |
| namespace wip { | |
| class GAPI_EXPORTS_W_SIMPLE GOutputs | |
| { | |
| public: | |
| GOutputs() = default; | |
| GOutputs(const std::string& id, cv::GKernel::M outMeta, cv::GArgs &&ins); | |
| GAPI_WRAP cv::GMat getGMat(); | |
| GAPI_WRAP cv::GScalar getGScalar(); | |
| GAPI_WRAP cv::GArrayT getGArray(cv::gapi::ArgType type); | |
| GAPI_WRAP cv::GOpaqueT getGOpaque(cv::gapi::ArgType type); | |
| private: | |
| class Priv; | |
| std::shared_ptr<Priv> m_priv; | |
| }; | |
| GOutputs op(const std::string& id, cv::GKernel::M outMeta, cv::GArgs&& args); | |
| template <typename... T> | |
| GOutputs op(const std::string& id, cv::GKernel::M outMeta, T&&... args) | |
| { | |
| return op(id, outMeta, cv::GArgs{cv::GArg(std::forward<T>(args))... }); | |
| } | |
| } // namespace wip | |
| } // namespace gapi | |
| } // namespace cv | |
| cv::gapi::wip::GOutputs cv::gapi::wip::op(const std::string& id, | |
| cv::GKernel::M outMeta, | |
| cv::GArgs&& args) | |
| { | |
| cv::gapi::wip::GOutputs outputs{id, outMeta, std::move(args)}; | |
| return outputs; | |
| } | |
| class cv::gapi::wip::GOutputs::Priv | |
| { | |
| public: | |
| Priv(const std::string& id, cv::GKernel::M outMeta, cv::GArgs &&ins); | |
| cv::GMat getGMat(); | |
| cv::GScalar getGScalar(); | |
| cv::GArrayT getGArray(cv::gapi::ArgType); | |
| cv::GOpaqueT getGOpaque(cv::gapi::ArgType); | |
| private: | |
| int output = 0; | |
| std::unique_ptr<cv::GCall> m_call; | |
| }; | |
| cv::gapi::wip::GOutputs::Priv::Priv(const std::string& id, cv::GKernel::M outMeta, cv::GArgs &&args) | |
| { | |
| cv::GKinds kinds; | |
| kinds.reserve(args.size()); | |
| std::transform(args.begin(), args.end(), std::back_inserter(kinds), | |
| [](const cv::GArg& arg) { return arg.opaque_kind; }); | |
| m_call.reset(new cv::GCall{cv::GKernel{id, {}, outMeta, {}, std::move(kinds), {}, {}}}); | |
| m_call->setArgs(std::move(args)); | |
| } | |
| cv::GMat cv::gapi::wip::GOutputs::Priv::getGMat() | |
| { | |
| m_call->kernel().outShapes.push_back(cv::GShape::GMAT); | |
| m_call->kernel().outKinds.push_back(cv::detail::OpaqueKind::CV_UNKNOWN); | |
| // ...so _empty_ constructor is passed here. | |
| m_call->kernel().outCtors.emplace_back(cv::util::monostate{}); | |
| return m_call->yield(output++); | |
| } | |
| cv::GScalar cv::gapi::wip::GOutputs::Priv::getGScalar() | |
| { | |
| m_call->kernel().outShapes.push_back(cv::GShape::GSCALAR); | |
| m_call->kernel().outKinds.push_back(cv::detail::OpaqueKind::CV_UNKNOWN); | |
| // ...so _empty_ constructor is passed here. | |
| m_call->kernel().outCtors.emplace_back(cv::util::monostate{}); | |
| return m_call->yieldScalar(output++); | |
| } | |
| cv::GArrayT cv::gapi::wip::GOutputs::Priv::getGArray(cv::gapi::ArgType type) | |
| { | |
| m_call->kernel().outShapes.push_back(cv::GShape::GARRAY); | |
| SWITCH(type, GARRAY_TYPE_LIST_G, HC) | |
| } | |
| cv::GOpaqueT cv::gapi::wip::GOutputs::Priv::getGOpaque(cv::gapi::ArgType type) | |
| { | |
| m_call->kernel().outShapes.push_back(cv::GShape::GOPAQUE); | |
| SWITCH(type, GOPAQUE_TYPE_LIST_G, HC) | |
| } | |
| cv::gapi::wip::GOutputs::GOutputs(const std::string& id, | |
| cv::GKernel::M outMeta, | |
| cv::GArgs &&ins) : | |
| m_priv(new cv::gapi::wip::GOutputs::Priv(id, outMeta, std::move(ins))) | |
| { | |
| } | |
| cv::GMat cv::gapi::wip::GOutputs::getGMat() | |
| { | |
| return m_priv->getGMat(); | |
| } | |
| cv::GScalar cv::gapi::wip::GOutputs::getGScalar() | |
| { | |
| return m_priv->getGScalar(); | |
| } | |
| cv::GArrayT cv::gapi::wip::GOutputs::getGArray(cv::gapi::ArgType type) | |
| { | |
| return m_priv->getGArray(type); | |
| } | |
| cv::GOpaqueT cv::gapi::wip::GOutputs::getGOpaque(cv::gapi::ArgType type) | |
| { | |
| return m_priv->getGOpaque(type); | |
| } | |