File size: 4,612 Bytes
be94e5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 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) 2021 Intel Corporation
#include <opencv2/gapi/streaming/onevpl/source.hpp>
#include "streaming/onevpl/source_priv.hpp"
#include "streaming/onevpl/data_provider_dispatcher.hpp"
#include "streaming/onevpl/cfg_param_device_selector.hpp"
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
#ifdef HAVE_ONEVPL
GSource::GSource(const std::string& filePath, const CfgParams& cfg_params) :
GSource(filePath, cfg_params, std::make_shared<CfgParamDeviceSelector>(cfg_params)) {
if (filePath.empty()) {
util::throw_error(std::logic_error("Cannot create 'GSource' on empty source file name"));
}
}
GSource::GSource(const std::string& filePath,
const CfgParams& cfg_params,
const std::string& device_id,
void* accel_device_ptr,
void* accel_ctx_ptr) :
GSource(filePath, cfg_params,
std::make_shared<CfgParamDeviceSelector>(accel_device_ptr, device_id,
accel_ctx_ptr, cfg_params)) {
}
GSource::GSource(const std::string& filePath,
const CfgParams& cfg_params,
const Device &device, const Context &ctx) :
GSource(filePath, update_param_with_accel_type(CfgParams{cfg_params}, device.get_type()),
std::make_shared<CfgParamDeviceSelector>(device, ctx, cfg_params)) {
}
GSource::GSource(const std::string& filePath,
const CfgParams& cfg_params,
std::shared_ptr<IDeviceSelector> selector) :
GSource(DataProviderDispatcher::create(filePath, cfg_params), cfg_params, selector) {
if (filePath.empty()) {
util::throw_error(std::logic_error("Cannot create 'GSource' on empty source file name"));
}
}
GSource::GSource(std::shared_ptr<IDataProvider> source, const CfgParams& cfg_params) :
GSource(source, cfg_params,
std::make_shared<CfgParamDeviceSelector>(cfg_params)) {
}
GSource::GSource(std::shared_ptr<IDataProvider> source,
const CfgParams& cfg_params,
const std::string& device_id,
void* accel_device_ptr,
void* accel_ctx_ptr) :
GSource(source, cfg_params,
std::make_shared<CfgParamDeviceSelector>(accel_device_ptr, device_id,
accel_ctx_ptr, cfg_params)) {
}
// common delegating parameters c-tor
GSource::GSource(std::shared_ptr<IDataProvider> source,
const CfgParams& cfg_params,
std::shared_ptr<IDeviceSelector> selector) :
GSource(std::unique_ptr<Priv>(new GSource::Priv(source, cfg_params, selector))) {
}
#else
GSource::GSource(const std::string&, const CfgParams&) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(const std::string&, const CfgParams&, const std::string&,
void*, void*) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(const std::string&, const CfgParams&, const Device &, const Context &) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(const std::string&, const CfgParams&, std::shared_ptr<IDeviceSelector>) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(std::shared_ptr<IDataProvider>, const CfgParams&) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(std::shared_ptr<IDataProvider>, const CfgParams&,
const std::string&, void*, void*) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
GSource::GSource(std::shared_ptr<IDataProvider>, const CfgParams&, std::shared_ptr<IDeviceSelector>) {
GAPI_Error("Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
}
#endif
// final delegating c-tor
GSource::GSource(std::unique_ptr<Priv>&& impl) :
IStreamSource(),
m_priv(std::move(impl)) {
}
GSource::~GSource() = default;
bool GSource::pull(cv::gapi::wip::Data& data)
{
return m_priv->pull(data);
}
GMetaArg GSource::descr_of() const
{
return m_priv->descr_of();
}
} // namespace onevpl
} // namespace wip
} // namespace gapi
} // namespace cv
|