forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencv#18793 from dmatveev:dm/in_graph_metadata
G-API: Introduce runtime in-graph metadata * G-API: In-graph metadata -- initial implementation * G-API: Finish the in-graph metadata implementation for Streaming * G-API: Fix standalone build & warnings for in-graph metadata * G-API: In-graph meta -- fixed review comments * G-API: Fix issues with desync causing failing tests
- Loading branch information
Showing
16 changed files
with
681 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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) 2020 Intel Corporation | ||
|
||
|
||
#ifndef OPENCV_GAPI_GSTREAMING_META_HPP | ||
#define OPENCV_GAPI_GSTREAMING_META_HPP | ||
|
||
#include <opencv2/gapi/gopaque.hpp> | ||
#include <opencv2/gapi/gcall.hpp> | ||
#include <opencv2/gapi/gkernel.hpp> | ||
#include <opencv2/gapi/gtype_traits.hpp> | ||
|
||
namespace cv { | ||
namespace gapi { | ||
namespace streaming { | ||
|
||
// FIXME: the name is debatable | ||
namespace meta_tag { | ||
static constexpr const char * timestamp = "org.opencv.gapi.meta.timestamp"; | ||
static constexpr const char * seq_id = "org.opencv.gapi.meta.seq_id"; | ||
} // namespace meta_tag | ||
|
||
namespace detail { | ||
struct GMeta { | ||
static const char *id() { | ||
return "org.opencv.streaming.meta"; | ||
} | ||
// A universal yield for meta(), same as in GDesync | ||
template<typename... R, int... IIs> | ||
static std::tuple<R...> yield(cv::GCall &call, cv::detail::Seq<IIs...>) { | ||
return std::make_tuple(cv::detail::Yield<R>::yield(call, IIs)...); | ||
} | ||
// Also a universal outMeta stub here | ||
static GMetaArgs getOutMeta(const GMetaArgs &args, const GArgs &) { | ||
return args; | ||
} | ||
}; | ||
} // namespace detail | ||
|
||
template<typename T, typename G> | ||
cv::GOpaque<T> meta(G g, const std::string &tag) { | ||
using O = cv::GOpaque<T>; | ||
cv::GKernel k{ | ||
detail::GMeta::id() // kernel id | ||
, tag // kernel tag. Use meta tag here | ||
, &detail::GMeta::getOutMeta // outMeta callback | ||
, {cv::detail::GTypeTraits<O>::shape} // output Shape | ||
, {cv::detail::GTypeTraits<G>::op_kind} // input data kinds | ||
, {cv::detail::GObtainCtor<O>::get()} // output template ctors | ||
}; | ||
cv::GCall call(std::move(k)); | ||
call.pass(g); | ||
return std::get<0>(detail::GMeta::yield<O>(call, cv::detail::MkSeq<1>::type())); | ||
} | ||
|
||
template<typename G> | ||
cv::GOpaque<int64_t> timestamp(G g) { | ||
return meta<int64_t>(g, meta_tag::timestamp); | ||
} | ||
|
||
template<typename G> | ||
cv::GOpaque<int64_t> seq_id(G g) { | ||
return meta<int64_t>(g, meta_tag::seq_id); | ||
} | ||
|
||
template<typename G> | ||
cv::GOpaque<int64_t> seqNo(G g) { | ||
// Old name, compatibility only | ||
return seq_id(g); | ||
} | ||
|
||
} // namespace streaming | ||
} // namespace gapi | ||
} // namespace cv | ||
|
||
#endif // OPENCV_GAPI_GSTREAMING_META_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.