• Pinaev Danil's avatar
    Merge pull request #16031 from aDanPin:dm/streaming_auto_meta · 5e3a7ac8
    Pinaev Danil authored
    G-API-NG/Streaming: don't require explicit metadata in compileStreaming()
    
    * First probably working version
    Hardcode gose to setSource() :)
    
    * Pre final version of move metadata declaration from compileStreaming() to setSource().
    
    * G-API-NG/Streaming: recovered the existing Streaming functionality
    
    - The auto-meta test is disabling since it crashes.
    - Restored .gitignore
    
    * G-API-NG/Streaming: Made the meta-less compileStreaming() work
    
    - Works fine even with OpenCV backend;
    - Fluid doesn't support such kind of compilation so far - to be fixed
    
    * G-API-NG/Streaming: Fix Fluid to support meta-less compilation
    
    - Introduced a notion of metadata-sensitive passes and slightly
      refactored GCompiler and GFluidBackend to support that
    - Fixed a TwoVideoSourcesFail test on streaming
    
    * Add three smoke streaming tests to gapi_streaming_tests.
    All three teste run pipeline with two different input sets
    1) SmokeTest_Two_Const_Mats test run pipeline with two const Mats
    2) SmokeTest_One_Video_One_Const_Scalar test run pipleline with Mat(video source) and const Scalar
    3) SmokeTest_One_Video_One_Const_Vector test run pipeline with Mat(video source) and const Vector
     # Please enter the commit message for your changes. Lines starting
    
    * style fix
    
    * Some review stuff
    
    * Some review stuff
    5e3a7ac8
gstreaming.cpp 3.45 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) 2019 Intel Corporation


#include "precomp.hpp"

#if !defined(GAPI_STANDALONE)

#include <ade/graph.hpp>

#include <opencv2/gapi/gproto.hpp> // can_describe
#include <opencv2/gapi/gcompiled.hpp>

#include "compiler/gstreaming_priv.hpp"
#include "backends/common/gbackend.hpp"

// GStreamingCompiled private implementation ///////////////////////////////////
void cv::GStreamingCompiled::Priv::setup(const GMetaArgs &_metaArgs,
                                         const GMetaArgs &_outMetas,
                                         std::unique_ptr<cv::gimpl::GStreamingExecutor> &&_pE)
{
    m_metas    = _metaArgs;
    m_outMetas = _outMetas;
    m_exec     = std::move(_pE);
}

void cv::GStreamingCompiled::Priv::setup(std::unique_ptr<cv::gimpl::GStreamingExecutor> &&_pE)
{
    m_exec = std::move(_pE);
}

bool cv::GStreamingCompiled::Priv::isEmpty() const
{
    return !m_exec;
}

const cv::GMetaArgs& cv::GStreamingCompiled::Priv::metas() const
{
    return m_metas;
}

const cv::GMetaArgs& cv::GStreamingCompiled::Priv::outMetas() const
{
    return m_outMetas;
}

// FIXME: What is the reason in having Priv here if Priv actually dispatches
// everything to the underlying executable?? May be this executable may become
// the G*Compiled's priv?
void cv::GStreamingCompiled::Priv::setSource(cv::GRunArgs &&args)
{
    if (!m_metas.empty() && !can_describe(m_metas, args))
    {
        util::throw_error(std::logic_error("This object was compiled "
                                           "for different metadata!"));
    }
    GAPI_Assert(m_exec != nullptr);
    m_exec->setSource(std::move(args));
}

void cv::GStreamingCompiled::Priv::start()
{
    m_exec->start();
}

bool cv::GStreamingCompiled::Priv::pull(cv::GRunArgsP &&outs)
{
    return m_exec->pull(std::move(outs));
}

bool cv::GStreamingCompiled::Priv::try_pull(cv::GRunArgsP &&outs)
{
    return m_exec->try_pull(std::move(outs));
}

void cv::GStreamingCompiled::Priv::stop()
{
    m_exec->stop();
}

bool cv::GStreamingCompiled::Priv::running() const
{
    return m_exec->running();
}

// GStreamingCompiled public implementation ////////////////////////////////////
cv::GStreamingCompiled::GStreamingCompiled()
    : m_priv(new Priv())
{
}

void cv::GStreamingCompiled::setSource(GRunArgs &&ins)
{
    // FIXME: verify these input parameters according to the graph input meta
    m_priv->setSource(std::move(ins));
}

void cv::GStreamingCompiled::setSource(const cv::gapi::wip::IStreamSource::Ptr &s)
{
    setSource(cv::gin(s));
}

void cv::GStreamingCompiled::start()
{
    m_priv->start();
}

bool cv::GStreamingCompiled::pull(cv::GRunArgsP &&outs)
{
    return m_priv->pull(std::move(outs));
}

bool cv::GStreamingCompiled::try_pull(cv::GRunArgsP &&outs)
{
    return m_priv->try_pull(std::move(outs));
}

void cv::GStreamingCompiled::stop()
{
    m_priv->stop();
}

bool cv::GStreamingCompiled::running() const
{
    return m_priv->running();
}

cv::GStreamingCompiled::operator bool() const
{
    return !m_priv->isEmpty();
}

const cv::GMetaArgs& cv::GStreamingCompiled::metas() const
{
    return m_priv->metas();
}

const cv::GMetaArgs& cv::GStreamingCompiled::outMetas() const
{
    return m_priv->outMetas();
}

cv::GStreamingCompiled::Priv& cv::GStreamingCompiled::priv()
{
    return *m_priv;
}

#endif // GAPI_STANDALONE