Skip to content

Commit 244511e

Browse files
Merge pull request opencv#19205 from TolyaTalamanov:at/remove-streamingbackend-export
[G-API] Fix streaming kernels in standalone * Move streaming kernels from public header * Add streaming backend to standalone
1 parent 656b20a commit 244511e

File tree

5 files changed

+69
-65
lines changed

5 files changed

+69
-65
lines changed

modules/gapi/cmake/standalone.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ file(GLOB FLUID_sources "${FLUID_ROOT}/src/api/g*.cpp"
2121
"${FLUID_ROOT}/src/compiler/passes/*.cpp"
2222
"${FLUID_ROOT}/src/executor/*.cpp"
2323
"${FLUID_ROOT}/src/backends/fluid/*.cpp"
24+
"${FLUID_ROOT}/src/backends/streaming/*.cpp"
2425
"${FLUID_ROOT}/src/backends/common/*.cpp")
2526

2627
add_library(${FLUID_TARGET} STATIC ${FLUID_includes} ${FLUID_sources})

modules/gapi/src/backends/streaming/gstreamingbackend.cpp

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
//
55
// Copyright (C) 2020 Intel Corporation
66

7+
#if !defined(GAPI_STANDALONE)
78
#include <opencv2/imgproc.hpp>
9+
#endif // !defined(GAPI_STANDALONE)
10+
811
#include <opencv2/gapi/util/throw.hpp> // throw_error
912
#include <opencv2/gapi/streaming/format.hpp> // kernels
1013

@@ -32,7 +35,6 @@ using ConstStreamingGraph = ade::ConstTypedGraph
3235
, StreamingCreateFunction
3336
>;
3437

35-
3638
class GStreamingIntrinExecutable final: public cv::gimpl::GIslandExecutable
3739
{
3840
virtual void run(std::vector<InObj> &&,
@@ -135,18 +137,30 @@ cv::gapi::GBackend cv::gapi::streaming::backend()
135137
return this_backend;
136138
}
137139

138-
cv::gapi::GKernelPackage cv::gapi::streaming::kernels()
140+
struct Copy: public cv::detail::KernelTag
139141
{
140-
return cv::gapi::kernels<cv::gimpl::BGR>();
141-
}
142+
using API = cv::gimpl::streaming::GCopy;
142143

143-
cv::gapi::GKernelPackage cv::gimpl::streaming::kernels()
144-
{
145-
return cv::gapi::kernels<cv::gimpl::Copy>();
146-
}
144+
static cv::gapi::GBackend backend() { return cv::gapi::streaming::backend(); }
145+
146+
class Actor final: public cv::gapi::streaming::IActor
147+
{
148+
public:
149+
explicit Actor(const cv::GCompileArgs&) {}
150+
virtual void run(cv::gimpl::GIslandExecutable::IInput &in,
151+
cv::gimpl::GIslandExecutable::IOutput &out) override;
152+
};
147153

148-
void cv::gimpl::Copy::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
149-
cv::gimpl::GIslandExecutable::IOutput &out)
154+
static cv::gapi::streaming::IActor::Ptr create(const cv::GCompileArgs& args)
155+
{
156+
return cv::gapi::streaming::IActor::Ptr(new Actor(args));
157+
}
158+
159+
static cv::gapi::streaming::GStreamingKernel kernel() { return {&create}; };
160+
};
161+
162+
void Copy::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
163+
cv::gimpl::GIslandExecutable::IOutput &out)
150164
{
151165
const auto in_msg = in.get();
152166
if (cv::util::holds_alternative<cv::gimpl::EndOfStream>(in_msg))
@@ -176,8 +190,34 @@ void cv::gimpl::Copy::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
176190
out.post(std::move(out_arg));
177191
}
178192

179-
void cv::gimpl::BGR::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
180-
cv::gimpl::GIslandExecutable::IOutput &out)
193+
cv::gapi::GKernelPackage cv::gimpl::streaming::kernels()
194+
{
195+
return cv::gapi::kernels<Copy>();
196+
}
197+
198+
#if !defined(GAPI_STANDALONE)
199+
200+
struct GOCVBGR: public cv::detail::KernelTag
201+
{
202+
using API = cv::gapi::streaming::GBGR;
203+
static cv::gapi::GBackend backend() { return cv::gapi::streaming::backend(); }
204+
205+
class Actor final: public cv::gapi::streaming::IActor {
206+
public:
207+
explicit Actor(const cv::GCompileArgs&) {}
208+
virtual void run(cv::gimpl::GIslandExecutable::IInput &in,
209+
cv::gimpl::GIslandExecutable::IOutput&out) override;
210+
};
211+
212+
static cv::gapi::streaming::IActor::Ptr create(const cv::GCompileArgs& args)
213+
{
214+
return cv::gapi::streaming::IActor::Ptr(new Actor(args));
215+
}
216+
static cv::gapi::streaming::GStreamingKernel kernel() { return {&create}; };
217+
};
218+
219+
void GOCVBGR::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
220+
cv::gimpl::GIslandExecutable::IOutput &out)
181221
{
182222
const auto in_msg = in.get();
183223
if (cv::util::holds_alternative<cv::gimpl::EndOfStream>(in_msg))
@@ -216,6 +256,21 @@ void cv::gimpl::BGR::Actor::run(cv::gimpl::GIslandExecutable::IInput &in,
216256
out.post(std::move(out_arg));
217257
}
218258

259+
cv::gapi::GKernelPackage cv::gapi::streaming::kernels()
260+
{
261+
return cv::gapi::kernels<GOCVBGR>();
262+
}
263+
264+
#else
265+
266+
cv::gapi::GKernelPackage cv::gapi::streaming::kernels()
267+
{
268+
// Still provide this symbol to avoid linking issues
269+
util::throw_error(std::runtime_error("cv::gapi::streaming::kernels() isn't supported in standalone"));
270+
}
271+
272+
#endif // !defined(GAPI_STANDALONE)
273+
219274
cv::GMat cv::gapi::copy(const cv::GMat& in) {
220275
return cv::gimpl::streaming::GCopy::on<cv::GMat>(in);
221276
}

modules/gapi/src/backends/streaming/gstreamingbackend.hpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212
#include "gstreamingkernel.hpp"
1313

1414
namespace cv {
15-
namespace gapi {
16-
namespace streaming {
17-
18-
cv::gapi::GBackend backend();
19-
20-
}} // namespace gapi::streaming
21-
2215
namespace gimpl {
2316
namespace streaming {
2417

@@ -39,48 +32,6 @@ struct GCopy final : public cv::detail::NoTag
3932
};
4033

4134
} // namespace streaming
42-
43-
struct Copy: public cv::detail::KernelTag
44-
{
45-
using API = streaming::GCopy;
46-
47-
static gapi::GBackend backend() { return cv::gapi::streaming::backend(); }
48-
49-
class Actor final: public cv::gapi::streaming::IActor
50-
{
51-
public:
52-
explicit Actor(const cv::GCompileArgs&) {}
53-
virtual void run(cv::gimpl::GIslandExecutable::IInput &in,
54-
cv::gimpl::GIslandExecutable::IOutput &out) override;
55-
};
56-
57-
static cv::gapi::streaming::IActor::Ptr create(const cv::GCompileArgs& args)
58-
{
59-
return cv::gapi::streaming::IActor::Ptr(new Actor(args));
60-
}
61-
62-
static cv::gapi::streaming::GStreamingKernel kernel() { return {&create}; };
63-
};
64-
65-
struct BGR: public cv::detail::KernelTag
66-
{
67-
using API = cv::gapi::streaming::GBGR;
68-
static gapi::GBackend backend() { return cv::gapi::streaming::backend(); }
69-
70-
class Actor final: public cv::gapi::streaming::IActor {
71-
public:
72-
explicit Actor(const cv::GCompileArgs&) {}
73-
virtual void run(cv::gimpl::GIslandExecutable::IInput &in,
74-
cv::gimpl::GIslandExecutable::IOutput&out) override;
75-
};
76-
77-
static cv::gapi::streaming::IActor::Ptr create(const cv::GCompileArgs& args)
78-
{
79-
return cv::gapi::streaming::IActor::Ptr(new Actor(args));
80-
}
81-
static cv::gapi::streaming::GStreamingKernel kernel() { return {&create}; };
82-
};
83-
8435
} // namespace gimpl
8536
} // namespace cv
8637

modules/gapi/src/compiler/gcompiler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@
3636
#include "executor/gstreamingexecutor.hpp"
3737
#include "backends/common/gbackend.hpp"
3838
#include "backends/common/gmetabackend.hpp"
39-
#include "backends/streaming/gstreamingbackend.hpp"
39+
#include "backends/streaming/gstreamingbackend.hpp" // cv::gimpl::streaming::kernels()
4040

4141
// <FIXME:>
4242
#if !defined(GAPI_STANDALONE)
4343
#include <opencv2/gapi/cpu/core.hpp> // Also directly refer to Core,
4444
#include <opencv2/gapi/cpu/imgproc.hpp> // ...Imgproc
4545
#include <opencv2/gapi/cpu/video.hpp> // ...and Video kernel implementations
4646
#include <opencv2/gapi/render/render.hpp> // render::ocv::backend()
47-
#include <opencv2/gapi/streaming/format.hpp> // streaming::kernels()
4847
#endif // !defined(GAPI_STANDALONE)
4948
// </FIXME:>
5049

modules/gapi/src/executor/gstreamingexecutor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,12 +1005,10 @@ cv::gimpl::GStreamingExecutor::GStreamingExecutor(std::unique_ptr<ade::Graph> &&
10051005
// In the current implementation, such islands
10061006
// _must_ start with copy
10071007
GAPI_Assert(isl->in_ops().size() == 1u);
1008-
#if !defined(GAPI_STANDALONE)
10091008
GAPI_Assert(GModel::Graph(*m_orig_graph)
10101009
.metadata(*isl->in_ops().begin())
10111010
.get<cv::gimpl::Op>()
10121011
.k.name == cv::gimpl::streaming::GCopy::id());
1013-
#endif // GAPI_STANDALONE
10141012
for (auto out_nh : nh->outNodes()) {
10151013
for (auto out_eh : out_nh->outEdges()) {
10161014
qgr.metadata(out_eh).set(DesyncSpecialCase{});

0 commit comments

Comments
 (0)