Merge pull request #21688 from sivanov-work:vpp_ie_integration
G-API: VPP preprocessing GIEBackend integration * Add ROI in VPP prepro * Apply comments * Integration to IE * Removed extra invocations * Fix no-vpl compilation * Fix compilations * Apply comments * Use thin wrapper for device & ctx * Implement Device/Context constructor functions * Apply samples comment * Fix compilation * Fix compilation * Fix build * Separate Device&Context from selector, apply other comments * Fix typo * Intercept OV exception with pretty print outpull/21809/head
parent
7b582b71ba
commit
f3945fbddb
18 changed files with 716 additions and 136 deletions
@ -0,0 +1,72 @@ |
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#ifndef GAPI_STREAMING_ONEVPL_ACCEL_TYPES_HPP |
||||
#define GAPI_STREAMING_ONEVPL_ACCEL_TYPES_HPP |
||||
|
||||
#include <limits> |
||||
#include <string> |
||||
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS |
||||
|
||||
namespace cv { |
||||
namespace gapi { |
||||
namespace wip { |
||||
namespace onevpl { |
||||
|
||||
enum class AccelType: uint8_t { |
||||
HOST, |
||||
DX11, |
||||
|
||||
LAST_VALUE = std::numeric_limits<uint8_t>::max() |
||||
}; |
||||
|
||||
GAPI_EXPORTS const char* to_cstring(AccelType type); |
||||
|
||||
struct IDeviceSelector; |
||||
struct GAPI_EXPORTS Device { |
||||
friend struct IDeviceSelector; |
||||
using Ptr = void*; |
||||
|
||||
~Device(); |
||||
const std::string& get_name() const; |
||||
Ptr get_ptr() const; |
||||
AccelType get_type() const; |
||||
private: |
||||
Device(Ptr device_ptr, const std::string& device_name, |
||||
AccelType device_type); |
||||
|
||||
std::string name; |
||||
Ptr ptr; |
||||
AccelType type; |
||||
}; |
||||
|
||||
struct GAPI_EXPORTS Context { |
||||
friend struct IDeviceSelector; |
||||
using Ptr = void*; |
||||
|
||||
~Context(); |
||||
Ptr get_ptr() const; |
||||
AccelType get_type() const; |
||||
private: |
||||
Context(Ptr ctx_ptr, AccelType ctx_type); |
||||
Ptr ptr; |
||||
AccelType type; |
||||
}; |
||||
|
||||
GAPI_EXPORTS Device create_host_device(); |
||||
GAPI_EXPORTS Context create_host_context(); |
||||
|
||||
GAPI_EXPORTS Device create_dx11_device(Device::Ptr device_ptr, |
||||
const std::string& device_name); |
||||
GAPI_EXPORTS Context create_dx11_context(Context::Ptr ctx_ptr); |
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // GAPI_STREAMING_ONEVPL_ACCEL_TYPES_HPP
|
@ -0,0 +1,83 @@ |
||||
// 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) 2022 Intel Corporation
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp> |
||||
#include "streaming/onevpl/engine/preproc_engine_interface.hpp" |
||||
#include "streaming/onevpl/engine/preproc/preproc_dispatcher.hpp" |
||||
|
||||
#ifdef HAVE_ONEVPL |
||||
#include "streaming/onevpl/onevpl_export.hpp" |
||||
#include "streaming/onevpl/engine/preproc/preproc_engine.hpp" |
||||
|
||||
#include "streaming/onevpl/accelerators/accel_policy_dx11.hpp" |
||||
#include "streaming/onevpl/accelerators/accel_policy_cpu.hpp" |
||||
#include "streaming/onevpl/accelerators/surface/surface.hpp" |
||||
#include "streaming/onevpl/cfg_param_device_selector.hpp" |
||||
#include "streaming/onevpl/cfg_params_parser.hpp" |
||||
|
||||
#endif //HAVE_ONEVPL
|
||||
|
||||
#include "logger.hpp" |
||||
|
||||
namespace cv { |
||||
namespace gapi { |
||||
namespace wip { |
||||
|
||||
template<typename SpecificPreprocEngine, typename ...PreprocEngineArgs > |
||||
std::unique_ptr<SpecificPreprocEngine> |
||||
IPreprocEngine::create_preproc_engine_impl(const PreprocEngineArgs& ...) { |
||||
GAPI_Assert(false && "Unsupported "); |
||||
} |
||||
|
||||
template <> |
||||
std::unique_ptr<onevpl::VPPPreprocDispatcher> |
||||
IPreprocEngine::create_preproc_engine_impl(const onevpl::Device &device, |
||||
const onevpl::Context &context) { |
||||
using namespace onevpl; |
||||
cv::util::suppress_unused_warning(device); |
||||
cv::util::suppress_unused_warning(context); |
||||
std::unique_ptr<VPPPreprocDispatcher> dispatcher(new VPPPreprocDispatcher); |
||||
#ifdef HAVE_ONEVPL |
||||
if (device.get_type() == onevpl::AccelType::DX11) { |
||||
bool gpu_pp_is_created = false; |
||||
#ifdef HAVE_DIRECTX |
||||
#ifdef HAVE_D3D11 |
||||
GAPI_LOG_INFO(nullptr, "Creating DX11 VPP preprocessing engine"); |
||||
// create GPU VPP preproc engine
|
||||
dispatcher->insert_worker<VPPPreprocEngine>( |
||||
std::unique_ptr<VPLAccelerationPolicy>{ |
||||
new VPLDX11AccelerationPolicy( |
||||
std::make_shared<CfgParamDeviceSelector>( |
||||
device, context, CfgParams{})) |
||||
}); |
||||
GAPI_LOG_INFO(nullptr, "DX11 VPP preprocessing engine created"); |
||||
gpu_pp_is_created = true; |
||||
#endif |
||||
#endif |
||||
GAPI_Assert(gpu_pp_is_created && "VPP preproc for GPU is requested, but it is avaiable only for DX11 at now"); |
||||
} else { |
||||
GAPI_LOG_INFO(nullptr, "Creating CPU VPP preprocessing engine"); |
||||
dispatcher->insert_worker<VPPPreprocEngine>( |
||||
std::unique_ptr<VPLAccelerationPolicy>{ |
||||
new VPLCPUAccelerationPolicy( |
||||
std::make_shared<CfgParamDeviceSelector>(CfgParams{}))}); |
||||
GAPI_LOG_INFO(nullptr, "CPU VPP preprocessing engine created"); |
||||
} |
||||
#endif // HAVE_ONEVPL
|
||||
return dispatcher; |
||||
} |
||||
|
||||
|
||||
// Force instantiation
|
||||
template |
||||
std::unique_ptr<onevpl::VPPPreprocDispatcher> |
||||
IPreprocEngine::create_preproc_engine_impl<onevpl::VPPPreprocDispatcher, |
||||
const onevpl::Device &,const onevpl::Context &> |
||||
(const onevpl::Device &device, |
||||
const onevpl::Context &ctx); |
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
Loading…
Reference in new issue