1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2023-09-11 13:22:22 +03:00
148 changed files with 2384 additions and 1876 deletions
+3
View File
@@ -190,6 +190,9 @@ set(gapi_srcs
src/backends/ov/bindings_ov.cpp
src/backends/python/gpythonbackend.cpp
# Queue Streaming source
src/streaming/queue_source.cpp
# OpenVPL Streaming source
src/streaming/onevpl/source.cpp
src/streaming/onevpl/source_priv.cpp
+3 -3
View File
@@ -1,7 +1,7 @@
set(ade_src_dir "${OpenCV_BINARY_DIR}/3rdparty/ade")
set(ade_filename "v0.1.2a.zip")
set(ade_subdir "ade-0.1.2a")
set(ade_md5 "fa4b3e25167319cb0fa9432ef8281945")
set(ade_filename "v0.1.2b.zip")
set(ade_subdir "ade-0.1.2b")
set(ade_md5 "4f93a0844dfc463c617d83b09011819a")
ocv_download(FILENAME ${ade_filename}
HASH ${ade_md5}
URL
@@ -141,8 +141,10 @@ namespace detail
template<typename U> struct GTypeOf<std::vector<U> > { using type = cv::GArray<U>; };
template<typename U> struct GTypeOf { using type = cv::GOpaque<U>;};
template<> struct GTypeOf<cv::MediaFrame> { using type = cv::GFrame; };
// FIXME: This is not quite correct since IStreamSource may produce not only Mat but also Scalar
// and vector data. TODO: Extend the type dispatching on these types too.
// FIXME: This is not quite correct since IStreamSource may
// produce not only Mat but also MediaFrame, Scalar and vector
// data. TODO: Extend the type dispatching on these types too.
template<> struct GTypeOf<cv::gapi::wip::IStreamSource::Ptr> { using type = cv::GMat;};
template<class T> using g_type_of_t = typename GTypeOf<T>::type;
@@ -0,0 +1,67 @@
// 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) 2023 Intel Corporation
#ifndef OPENCV_GAPI_STREAMING_QUEUE_SOURCE_HPP
#define OPENCV_GAPI_STREAMING_QUEUE_SOURCE_HPP
#include <memory> // shared_ptr
#include <type_traits> // is_base_of
#include <opencv2/gapi/garg.hpp> // GRunArgs
#include <opencv2/gapi/gmetaarg.hpp> // GMetaArg + all descr_of
#include <opencv2/gapi/streaming/source.hpp> // IStreamSource
namespace cv {
namespace gapi {
namespace wip {
struct Data; // fwd-declare to avoid circular? header dependencies
class GAPI_EXPORTS QueueSourceBase: public cv::gapi::wip::IStreamSource {
class Priv;
std::shared_ptr<Priv> m_priv;
// FIXME: Need to understand how it works with IStreamSource's shared_from_this
// Can we avoid having too many shared_ptrs here?
public:
explicit QueueSourceBase(const cv::GMetaArg &m);
void push(Data &&data);
virtual bool pull(Data &data) override;
virtual void halt() override;
virtual GMetaArg descr_of() const override;
virtual ~QueueSourceBase() = default;
};
/**
* @brief Queued streaming pipeline source.
*
*/
template<class T>
class QueueSource final: public QueueSourceBase
{
public:
using Meta = decltype(cv::descr_of(T{}));
explicit QueueSource(Meta m) : QueueSourceBase(GMetaArg{m}) {
}
void push(T t) {
QueueSourceBase::push(Data{t});
}
};
class GAPI_EXPORTS QueueInput {
std::vector<std::shared_ptr<QueueSourceBase> > m_sources;
public:
explicit QueueInput(const cv::GMetaArgs &args);
void push(cv::GRunArgs &&ins);
operator cv::GRunArgs();
};
} // namespace wip
} // namespace gapi
} // namespace cv
#endif // OPENCV_GAPI_STREAMING_SOURCE_HPP
@@ -16,7 +16,7 @@
namespace cv {
namespace gapi {
namespace wip {
struct Data; // "forward-declaration" of GRunArg
struct Data; // forward-declaration of Data to avoid circular dependencies
/**
* @brief Abstract streaming pipeline source.
@@ -43,6 +43,11 @@ public:
Ptr ptr() { return shared_from_this(); }
virtual bool pull(Data &data) = 0;
virtual GMetaArg descr_of() const = 0;
virtual void halt() {
// Do nothing by default to maintain compatibility with the existing sources...
// In fact needs to be decorated atop of the child classes to maintain the behavior
// FIXME: Make it mandatory in OpenCV 5.0
};
virtual ~IStreamSource() = default;
};
@@ -38,8 +38,8 @@ try:
return
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
@@ -73,8 +73,8 @@ try:
return
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
@@ -112,8 +112,8 @@ try:
return
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
rois = [(10, 15, 62, 62), (23, 50, 62, 62), (14, 100, 62, 62), (80, 50, 62, 62)]
@@ -161,8 +161,8 @@ try:
return
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
rois = [(10, 15, 62, 62), (23, 50, 62, 62), (14, 100, 62, 62), (80, 50, 62, 62)]
@@ -211,8 +211,8 @@ try:
return
root_path = '/omz_intel_models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
img_path = self.find_file('gpu/lbpcascade/er.png', [os.environ.get('OPENCV_TEST_DATA_PATH')])
device_id = 'CPU'
img = cv.resize(cv.imread(img_path), (544, 320))
@@ -270,8 +270,8 @@ try:
return
root_path = '/omz_intel_models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
weights_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
img_path = self.find_file('gpu/lbpcascade/er.png', [os.environ.get('OPENCV_TEST_DATA_PATH')])
device_id = 'CPU'
img = cv.resize(cv.imread(img_path), (544, 320))
@@ -86,8 +86,8 @@ try:
skip_if_openvino_not_available()
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
@@ -119,8 +119,8 @@ try:
skip_if_openvino_not_available()
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
@@ -148,8 +148,8 @@ try:
skip_if_openvino_not_available()
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path1 = self.find_file('cv/face/david1.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
@@ -190,8 +190,8 @@ try:
skip_if_openvino_not_available()
root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')])
model_path = self.find_file(root_path + '.xml', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
bin_path = self.find_file(root_path + '.bin', [os.environ.get('OPENCV_DNN_TEST_DATA_PATH')], required=False)
device_id = 'CPU'
img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
-6
View File
@@ -36,7 +36,6 @@ cv::gapi::GBackend::Priv::compile(const ade::Graph&,
{
// ...and this method is here for the same reason!
GAPI_Error("InternalError");
return {};
}
std::unique_ptr<cv::gimpl::GIslandExecutable>
@@ -224,7 +223,6 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, HandleRMat hand
default:
util::throw_error(std::logic_error("Unsupported GShape type"));
break;
}
}
@@ -256,7 +254,6 @@ void resetInternalData(Mag& mag, const Data &d)
default:
util::throw_error(std::logic_error("Unsupported GShape type"));
break;
}
}
@@ -284,7 +281,6 @@ cv::GRunArg getArg(const Mag& mag, const RcDesc &ref)
mag.meta<cv::MediaFrame>().at(ref.id));
default:
util::throw_error(std::logic_error("Unsupported GShape type"));
break;
}
}
@@ -327,7 +323,6 @@ cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc, bool is_umat)
default:
util::throw_error(std::logic_error("Unsupported GShape type"));
break;
}
}
@@ -359,7 +354,6 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg)
default:
util::throw_error(std::logic_error("Unsupported GShape type"));
break;
}
}
@@ -192,6 +192,7 @@ class GIslandEmitter
public:
// Obtain next value from the emitter
virtual bool pull(GRunArg &) = 0;
virtual void halt() = 0;
virtual ~GIslandEmitter() = default;
};
@@ -41,6 +41,10 @@ using namespace cv::gimpl::stream;
class VideoEmitter final: public cv::gimpl::GIslandEmitter {
cv::gapi::wip::IStreamSource::Ptr src;
virtual void halt() override {
src->halt();
}
virtual bool pull(cv::GRunArg &arg) override {
// FIXME: probably we can maintain a pool of (then) pre-allocated
// buffers to avoid runtime allocations.
@@ -62,6 +66,10 @@ public:
class ConstEmitter final: public cv::gimpl::GIslandEmitter {
cv::GRunArg m_arg;
virtual void halt() override {
// Not used here, but in fact can be used.
}
virtual bool pull(cv::GRunArg &arg) override {
arg = const_cast<const cv::GRunArg&>(m_arg); // FIXME: variant workaround
return true;
@@ -1918,6 +1926,11 @@ void cv::gimpl::GStreamingExecutor::stop()
for (auto &q : m_emitter_queues) {
q.push(stream::Cmd{stream::Stop{}});
}
// Also kindly ask emitter object to halt to break the blocking src->pull()
// loop
for (auto &nh : m_emitters) {
m_gim.metadata(nh).get<Emitter>().object->halt();
}
// Pull messages from the final queue to ensure completion
Cmd cmd;
@@ -0,0 +1,98 @@
// 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) 2023 Intel Corporation
#include <chrono>
#include <atomic>
#include <ade/util/zip_range.hpp>
#include <opencv2/gapi/streaming/queue_source.hpp>
#include <opencv2/gapi/streaming/meta.hpp>
#include "executor/conc_queue.hpp"
namespace cv {
namespace gapi {
namespace wip {
class QueueSourceBase::Priv {
public:
explicit Priv(const cv::GMetaArg &meta) {
m = meta;
halted = false;
}
cv::GMetaArg m;
cv::gapi::own::concurrent_bounded_queue<cv::GRunArg> q;
int64_t c = 0;
std::atomic<bool> halted;
};
QueueSourceBase::QueueSourceBase(const cv::GMetaArg &m)
: m_priv(new Priv(m)) {
}
void QueueSourceBase::push(Data &&data) {
// Tag data with seq_id/ts
const auto now = std::chrono::system_clock::now();
const auto dur = std::chrono::duration_cast<std::chrono::microseconds>
(now.time_since_epoch());
data.meta[cv::gapi::streaming::meta_tag::timestamp] = int64_t{dur.count()};
data.meta[cv::gapi::streaming::meta_tag::seq_id] = int64_t{m_priv->c++};
m_priv->q.push(data);
}
bool QueueSourceBase::pull(Data &data) {
m_priv->q.pop(data);
if (m_priv->halted) {
return false;
}
return true;
}
void QueueSourceBase::halt() {
m_priv->halted.store(true);
m_priv->q.push(cv::GRunArg{});
}
cv::GMetaArg QueueSourceBase::descr_of() const {
return m_priv->m;
}
QueueInput::QueueInput(const cv::GMetaArgs &args) {
for (auto &&m : args) {
m_sources.emplace_back(new cv::gapi::wip::QueueSourceBase(m));
}
}
void QueueInput::push(cv::GRunArgs &&args) {
GAPI_Assert(m_sources.size() == args.size());
for (auto && it : ade::util::zip(ade::util::toRange(m_sources),
ade::util::toRange(args)))
{
auto &src = std::get<0>(it);
auto &obj = std::get<1>(it);
Data d;
d = obj;
src->push(std::move(d));
}
}
QueueInput::operator cv::GRunArgs () {
cv::GRunArgs args;
for (auto &&s : m_sources) {
args.push_back(s->ptr());
}
return args;
}
} // wip
} // gapi
} // cv
+54 -54
View File
@@ -187,8 +187,8 @@ std::string compileAgeGenderBlob(const std::string& device) {
cv::gapi::ie::detail::ParamDesc params;
const std::string model_name = "age-gender-recognition-retail-0013";
const std::string output = model_name + ".blob";
params.model_path = findDataFile(SUBDIR + model_name + ".xml");
params.weights_path = findDataFile(SUBDIR + model_name + ".bin");
params.model_path = findDataFile(SUBDIR + model_name + ".xml", false);
params.weights_path = findDataFile(SUBDIR + model_name + ".bin", false);
params.device_id = device;
compileBlob(params, output, IE::Precision::U8);
return output;
@@ -205,8 +205,8 @@ TEST(TestAgeGenderIE, InferBasicTensor)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -256,8 +256,8 @@ TEST(TestAgeGenderIE, InferBasicImage)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// FIXME: Ideally it should be an image from disk
@@ -334,8 +334,8 @@ struct InferWithReshape: public ::testing::Test {
reshape_dims = {1, 3, 70, 70};
initDLDTDataPath();
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
@@ -432,8 +432,8 @@ struct ROIList: public ::testing::Test {
void SetUp() {
initDLDTDataPath();
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// FIXME: it must be cv::imread(findDataFile("../dnn/grace_hopper_227.png", false));
@@ -505,8 +505,8 @@ struct ROIListNV12: public ::testing::Test {
void SetUp() {
initDLDTDataPath();
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -585,8 +585,8 @@ struct SingleROI: public ::testing::Test {
void SetUp() {
initDLDTDataPath();
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// FIXME: it must be cv::imread(findDataFile("../dnn/grace_hopper_227.png", false));
@@ -644,8 +644,8 @@ struct SingleROINV12: public ::testing::Test {
void SetUp() {
initDLDTDataPath();
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -809,8 +809,8 @@ TEST(TestAgeGenderIE, GenericInfer)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Mat in_mat(cv::Size(320, 240), CV_8UC3);
@@ -859,8 +859,8 @@ TEST(TestAgeGenderIE, InvalidConfigGeneric)
{
initDLDTDataPath();
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
std::string device_id = "CPU";
// Configure & run G-API
@@ -885,8 +885,8 @@ TEST(TestAgeGenderIE, CPUConfigGeneric)
{
initDLDTDataPath();
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
std::string device_id = "CPU";
// Configure & run G-API
@@ -912,8 +912,8 @@ TEST(TestAgeGenderIE, InvalidConfig)
{
initDLDTDataPath();
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
std::string device_id = "CPU";
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
@@ -937,8 +937,8 @@ TEST(TestAgeGenderIE, CPUConfig)
{
initDLDTDataPath();
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
std::string device_id = "CPU";
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
@@ -1017,8 +1017,8 @@ TEST(TestAgeGenderIE, MediaInputNV12)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -1082,8 +1082,8 @@ TEST(TestAgeGenderIE, MediaInputBGR)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -1134,8 +1134,8 @@ TEST(InferROI, MediaInputBGR)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -1196,8 +1196,8 @@ TEST(InferROI, MediaInputNV12)
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Size sz{320, 240};
@@ -1587,8 +1587,8 @@ TEST(Infer, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -1654,8 +1654,8 @@ TEST(InferROI, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -1732,8 +1732,8 @@ TEST(InferList, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -1821,8 +1821,8 @@ TEST(Infer2, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -1911,8 +1911,8 @@ TEST(InferEmptyList, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -1965,8 +1965,8 @@ TEST(Infer2EmptyList, TestStreamingInfer)
std::string filepath = findDataFile("cv/video/768x576.avi");
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -2294,8 +2294,8 @@ struct LimitedSourceInfer: public ::testing::Test {
GStreamingCompiled compileStreaming(int nireq) {
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
auto pp = cv::gapi::ie::Params<AgeGender> {
@@ -2348,8 +2348,8 @@ TEST(TestAgeGenderIE, InferWithBatch)
constexpr int batch_size = 4;
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
cv::Mat in_mat({batch_size, 3, 62, 62}, CV_8U);
@@ -3091,8 +3091,8 @@ struct AgeGenderInferTest: public ::testing::Test {
void SetUp() {
initDLDTDataPath();
m_params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
m_params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
m_params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
m_params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
m_params.device_id = "CPU";
m_plugin = cv::gimpl::ie::wrap::getPlugin(m_params);
@@ -3191,8 +3191,8 @@ TEST(TestAgeGenderIE, InferTensorWithPreproc) {
initDLDTDataPath();
cv::gapi::ie::detail::ParamDesc params;
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
params.model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
params.weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
params.device_id = "CPU";
// Load IE network, initialize input data using that.
@@ -255,8 +255,8 @@ private:
struct BaseAgeGenderOV: public ::testing::Test {
BaseAgeGenderOV() {
initDLDTDataPath();
xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml", false);
bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin", false);
device = "CPU";
blob_path = "age-gender-recognition-retail-0013.blob";
}
@@ -0,0 +1,127 @@
// 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) 2023 Intel Corporation
#include "../test_precomp.hpp"
#include <opencv2/gapi/gstreaming.hpp>
#include <opencv2/gapi/streaming/queue_source.hpp>
#include <opencv2/gapi/streaming/cap.hpp>
namespace opencv_test
{
TEST(GAPI_Streaming_Queue_Source, SmokeTest) {
// This is more like an example on G-API Queue Source
cv::GMat in;
cv::GMat out = in + 1;
cv::GStreamingCompiled comp = cv::GComputation(in, out).compileStreaming();
// Queue source needs to know format information to maintain contracts
auto src = std::make_shared<cv::gapi::wip::QueueSource<cv::Mat> >
(cv::GMatDesc{CV_8U, 1, cv::Size{128, 128}});
comp.setSource(cv::gin(src->ptr()));
comp.start();
// It is perfectly legal to start a pipeline at this point - the source was passed.
// Now we can push data through the source and get the pipeline results.
cv::Mat eye = cv::Mat::eye(cv::Size{128, 128}, CV_8UC1);
src->push(eye); // Push I (identity matrix)
src->push(eye*2); // Push I*2
// Now its time to pop. The data could be already processed at this point.
// Note the queue source queues are unbounded to avoid deadlocks
cv::Mat result;
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(eye + 1, result, NORM_INF));
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(eye*2 + 1, result, NORM_INF));
}
TEST(GAPI_Streaming_Queue_Source, Mixed) {
// Mixing a regular "live" source (which runs on its own) with a
// manually controlled queue source may make a little sense, but
// is perfectly legal and possible.
cv::GMat in1;
cv::GMat in2;
cv::GMat out = in2 - in1;
cv::GStreamingCompiled comp = cv::GComputation(in1, in2, out).compileStreaming();
// Queue source needs to know format information to maintain contracts
auto src1 = std::make_shared<cv::gapi::wip::QueueSource<cv::Mat> >
(cv::GMatDesc{CV_8U, 3, cv::Size{768, 576}});
std::shared_ptr<cv::gapi::wip::IStreamSource> src2;
auto path = findDataFile("cv/video/768x576.avi");
try {
src2 = cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(path);
} catch(...) {
throw SkipTestException("Video file can not be opened");
}
comp.setSource(cv::gin(src1->ptr(), src2)); // FIXME: quite inconsistent
comp.start();
cv::Mat eye = cv::Mat::eye(cv::Size{768, 576}, CV_8UC3);
src1->push(eye); // Push I (identity matrix)
src1->push(eye); // Push I (again)
cv::Mat ref, result;
cv::VideoCapture cap(path);
cap >> ref;
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(ref - eye, result, NORM_INF));
cap >> ref;
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(ref - eye, result, NORM_INF));
}
TEST(GAPI_Streaming_Queue_Input, SmokeTest) {
// Queue Input: a tiny wrapper atop of multiple queue sources.
// Allows users to pass all input data at once.
cv::GMat in1;
cv::GScalar in2;
cv::GMat out = in1 + in2;
cv::GStreamingCompiled comp = cv::GComputation(cv::GIn(in1, in2), cv::GOut(out))
.compileStreaming();
// FIXME: This API is too raw
cv::gapi::wip::QueueInput input({
cv::GMetaArg{ cv::GMatDesc{CV_8U, 1, cv::Size{64,64} } },
cv::GMetaArg{ cv::empty_scalar_desc() }
});
comp.setSource(input); // Implicit conversion allows it to be passed as-is.
comp.start();
// Push data via queue input
cv::Mat eye = cv::Mat::eye(cv::Size{64, 64}, CV_8UC1);
input.push(cv::gin(eye, cv::Scalar(1)));
input.push(cv::gin(eye, cv::Scalar(2)));
input.push(cv::gin(eye, cv::Scalar(3)));
// Pop data and validate
cv::Mat result;
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(eye+1, result, NORM_INF));
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(eye+2, result, NORM_INF));
ASSERT_TRUE(comp.pull(cv::gout(result)));
EXPECT_EQ(0, cvtest::norm(eye+3, result, NORM_INF));
}
} // namespace opencv_test