mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00

* G-API-NG/API: Introduced inference API and IE-based backend - Very quick-n-dirty implementation - OpenCV's own DNN module is not used - No tests so far * G-API-NG/IE: Refined IE backend, added more tests * G-API-NG/IE: Fixed various CI warnings & build issues + tests - Added tests on multi-dimensional own::Mat - Added tests on GMatDesc with dimensions - Documentation on infer.hpp - Fixed more warnings + added a ROI list test - Fix descr_of clash for vector<Mat> & standalone mode - Fix build issue with gcc-4.8x - Addressed review comments * G-API-NG/IE: Addressed review comments - Pass `false` to findDataFile() - Add deprecation warning suppression macros for IE
110 lines
3.0 KiB
C++
110 lines
3.0 KiB
C++
// 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) 2018 Intel Corporation
|
|
|
|
|
|
#ifndef OPENCV_GAPI_GBACKEND_HPP
|
|
#define OPENCV_GAPI_GBACKEND_HPP
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
#include <ade/node.hpp>
|
|
|
|
#include "opencv2/gapi/garg.hpp"
|
|
#include "opencv2/gapi/own/mat.hpp"
|
|
|
|
#include "opencv2/gapi/util/optional.hpp"
|
|
#include "opencv2/gapi/own/scalar.hpp"
|
|
|
|
#include "compiler/gmodel.hpp"
|
|
|
|
namespace cv {
|
|
namespace gimpl {
|
|
|
|
// Forward declarations
|
|
struct Data;
|
|
struct RcDesc;
|
|
|
|
namespace magazine {
|
|
template<typename... Ts> struct Class
|
|
{
|
|
template<typename T> using MapT = std::unordered_map<int, T>;
|
|
template<typename T> MapT<T>& slot()
|
|
{
|
|
return std::get<ade::util::type_list_index<T, Ts...>::value>(slots);
|
|
}
|
|
template<typename T> const MapT<T>& slot() const
|
|
{
|
|
return std::get<ade::util::type_list_index<T, Ts...>::value>(slots);
|
|
}
|
|
private:
|
|
std::tuple<MapT<Ts>...> slots;
|
|
};
|
|
|
|
} // namespace magazine
|
|
#if !defined(GAPI_STANDALONE)
|
|
using Mag = magazine::Class<cv::gapi::own::Mat, cv::UMat, cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
|
#else
|
|
using Mag = magazine::Class<cv::gapi::own::Mat, cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
|
#endif
|
|
|
|
namespace magazine
|
|
{
|
|
void GAPI_EXPORTS bindInArg (Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat = false);
|
|
void GAPI_EXPORTS bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat = false);
|
|
|
|
void resetInternalData(Mag& mag, const Data &d);
|
|
cv::GRunArg getArg (const Mag& mag, const RcDesc &ref);
|
|
cv::GRunArgP getObjPtr ( Mag& mag, const RcDesc &rc, bool is_umat = false);
|
|
void writeBack (const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat = false);
|
|
} // namespace magazine
|
|
|
|
namespace detail
|
|
{
|
|
template<typename... Ts> struct magazine
|
|
{
|
|
template<typename T> using MapT = std::unordered_map<int, T>;
|
|
template<typename T> MapT<T>& slot()
|
|
{
|
|
return std::get<util::type_list_index<T, Ts...>::value>(slots);
|
|
}
|
|
template<typename T> const MapT<T>& slot() const
|
|
{
|
|
return std::get<util::type_list_index<T, Ts...>::value>(slots);
|
|
}
|
|
private:
|
|
std::tuple<MapT<Ts>...> slots;
|
|
};
|
|
} // namespace detail
|
|
|
|
struct GRuntimeArgs
|
|
{
|
|
GRunArgs inObjs;
|
|
GRunArgsP outObjs;
|
|
};
|
|
|
|
template<typename T>
|
|
inline cv::util::optional<T> getCompileArg(const cv::GCompileArgs &args)
|
|
{
|
|
for (auto &compile_arg : args)
|
|
{
|
|
if (compile_arg.tag == cv::detail::CompileArgTag<T>::tag())
|
|
{
|
|
return cv::util::optional<T>(compile_arg.get<T>());
|
|
}
|
|
}
|
|
return cv::util::optional<T>();
|
|
}
|
|
|
|
void createMat(const cv::GMatDesc& desc, cv::gapi::own::Mat& mat);
|
|
#if !defined(GAPI_STANDALONE)
|
|
void createMat(const cv::GMatDesc& desc, cv::Mat& mat);
|
|
#endif
|
|
|
|
}} // cv::gimpl
|
|
|
|
#endif // OPENCV_GAPI_GBACKEND_HPP
|