// 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-2019 Intel Corporation #include "precomp.hpp" #include // hash #include // accumulate #include #include #include #include cv::gapi::GNetPackage::GNetPackage(std::initializer_list ii) : networks(ii) { } std::vector cv::gapi::GNetPackage::backends() const { std::unordered_set unique_set; for (const auto &nn : networks) unique_set.insert(nn.backend); return std::vector(unique_set.begin(), unique_set.end()); } // FIXME: Inference API is currently only available in full mode #if !defined(GAPI_STANDALONE) cv::GInferInputs::GInferInputs() : in_blobs(std::make_shared()) { } cv::GMat& cv::GInferInputs::operator[](const std::string& name) { return (*in_blobs)[name]; } const cv::GInferInputs::Map& cv::GInferInputs::getBlobs() const { return *in_blobs; } void cv::GInferInputs::setInput(const std::string& name, const cv::GMat& value) { in_blobs->emplace(name, value); } struct cv::GInferOutputs::Priv { Priv(std::shared_ptr); std::shared_ptr call; InOutInfo* info = nullptr; std::unordered_map out_blobs; }; cv::GInferOutputs::Priv::Priv(std::shared_ptr c) : call(std::move(c)), info(cv::util::any_cast(&call->params())) { } cv::GInferOutputs::GInferOutputs(std::shared_ptr call) : m_priv(std::make_shared(std::move(call))) { } cv::GMat cv::GInferOutputs::at(const std::string& name) { auto it = m_priv->out_blobs.find(name); if (it == m_priv->out_blobs.end()) { // FIXME: Avoid modifying GKernel // Expect output to be always GMat m_priv->call->kernel().outShapes.push_back(cv::GShape::GMAT); // ...so _empty_ constructor is passed here. m_priv->call->kernel().outCtors.emplace_back(cv::util::monostate{}); int out_idx = static_cast(m_priv->out_blobs.size()); it = m_priv->out_blobs.emplace(name, m_priv->call->yield(out_idx)).first; m_priv->info->out_names.push_back(name); } return it->second; } #endif // GAPI_STANDALONE