点阵完成,加入opencv
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
// 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,
|
||||
VAAPI,
|
||||
|
||||
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);
|
||||
|
||||
GAPI_EXPORTS Device create_vaapi_device(Device::Ptr device_ptr,
|
||||
const std::string& device_name);
|
||||
GAPI_EXPORTS Context create_vaapi_context(Context::Ptr ctx_ptr);
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // GAPI_STREAMING_ONEVPL_ACCEL_TYPES_HPP
|
||||
@@ -0,0 +1,209 @@
|
||||
// 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
|
||||
|
||||
#ifndef OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP
|
||||
#define OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/gapi/util/variant.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
/**
|
||||
* @brief Public class is using for creation of onevpl::GSource instances.
|
||||
*
|
||||
* Class members available through methods @ref CfgParam::get_name() and @ref CfgParam::get_value() are used by
|
||||
* onevpl::GSource inner logic to create or find oneVPL particular implementation
|
||||
* (software/hardware, specific API version and etc.).
|
||||
*
|
||||
* @note Because oneVPL may provide several implementations which are satisfying with multiple (or single one) @ref CfgParam
|
||||
* criteria therefore it is possible to configure `preferred` parameters. This kind of CfgParams are created
|
||||
* using `is_major = false` argument in @ref CfgParam::create method and are not used by creating oneVPL particular implementations.
|
||||
* Instead they fill out a "score table" to select preferable implementation from available list. Implementation are satisfying
|
||||
* with most of these optional params would be chosen.
|
||||
* If no one optional CfgParam params were present then first of available oneVPL implementation would be applied.
|
||||
* Please get on https://spec.oneapi.io/versions/latest/elements/oneVPL/source/API_ref/VPL_disp_api_func.html?highlight=mfxcreateconfig#mfxsetconfigfilterproperty
|
||||
* for using OneVPL configuration. In this schema `mfxU8 *name` represents @ref CfgParam::get_name() and
|
||||
* `mfxVariant value` is @ref CfgParam::get_value()
|
||||
*/
|
||||
struct GAPI_EXPORTS CfgParam {
|
||||
using name_t = std::string;
|
||||
using value_t = cv::util::variant<uint8_t, int8_t,
|
||||
uint16_t, int16_t,
|
||||
uint32_t, int32_t,
|
||||
uint64_t, int64_t,
|
||||
float_t,
|
||||
double_t,
|
||||
void*,
|
||||
std::string>;
|
||||
/**
|
||||
* @brief frames_pool_size_name
|
||||
*
|
||||
* Special configuration parameter name for onevp::GSource:
|
||||
*
|
||||
* @note frames_pool_size_name allows to allocate surfaces pool appropriate size to keep
|
||||
* decoded frames in accelerator memory ready before
|
||||
* they would be consumed by onevp::GSource::pull operation. If you see
|
||||
* a lot of WARNING about lack of free surface then it's time to increase
|
||||
* frames_pool_size_name but be aware of accelerator free memory volume.
|
||||
* If not set then MFX implementation use
|
||||
* mfxFrameAllocRequest::NumFrameSuggested behavior
|
||||
*
|
||||
*/
|
||||
static constexpr const char *frames_pool_size_name() { return "frames_pool_size"; }
|
||||
static CfgParam create_frames_pool_size(size_t value);
|
||||
|
||||
/**
|
||||
* @brief acceleration_mode_name
|
||||
*
|
||||
* Special configuration parameter names for onevp::GSource:
|
||||
*
|
||||
* @note acceleration_mode_name allows to activate hardware acceleration &
|
||||
* device memory management.
|
||||
* Supported values:
|
||||
* - MFX_ACCEL_MODE_VIA_D3D11 Will activate DX11 acceleration and will produces
|
||||
* MediaFrames with data allocated in DX11 device memory
|
||||
*
|
||||
* If not set then MFX implementation will use default acceleration behavior:
|
||||
* all decoding operation uses default GPU resources but MediaFrame produces
|
||||
* data allocated by using host RAM
|
||||
*
|
||||
*/
|
||||
static constexpr const char *acceleration_mode_name() { return "mfxImplDescription.AccelerationMode"; }
|
||||
static CfgParam create_acceleration_mode(uint32_t value);
|
||||
static CfgParam create_acceleration_mode(const char* value);
|
||||
|
||||
/**
|
||||
* @brief decoder_id_name
|
||||
*
|
||||
* Special configuration parameter names for onevp::GSource:
|
||||
*
|
||||
* @note decoder_id_name allows to specify VPL decoder type which MUST present
|
||||
* in case of RAW video input data and MUST NOT present as CfgParam if video
|
||||
* stream incapsulated into container(*.mp4, *.mkv and so on). In latter case
|
||||
* onevp::GSource will determine it automatically
|
||||
* Supported values:
|
||||
* - MFX_CODEC_AVC
|
||||
* - MFX_CODEC_HEVC
|
||||
* - MFX_CODEC_MPEG2
|
||||
* - MFX_CODEC_VC1
|
||||
* - MFX_CODEC_CAPTURE
|
||||
* - MFX_CODEC_VP9
|
||||
* - MFX_CODEC_AV1
|
||||
*
|
||||
*/
|
||||
static constexpr const char *decoder_id_name() { return "mfxImplDescription.mfxDecoderDescription.decoder.CodecID"; }
|
||||
static CfgParam create_decoder_id(uint32_t value);
|
||||
static CfgParam create_decoder_id(const char* value);
|
||||
|
||||
static constexpr const char *implementation_name() { return "mfxImplDescription.Impl"; }
|
||||
static CfgParam create_implementation(uint32_t value);
|
||||
static CfgParam create_implementation(const char* value);
|
||||
|
||||
|
||||
static constexpr const char *vpp_frames_pool_size_name() { return "vpp_frames_pool_size"; }
|
||||
static CfgParam create_vpp_frames_pool_size(size_t value);
|
||||
|
||||
static constexpr const char *vpp_in_width_name() { return "vpp.In.Width"; }
|
||||
static CfgParam create_vpp_in_width(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_in_height_name() { return "vpp.In.Height"; }
|
||||
static CfgParam create_vpp_in_height(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_in_crop_x_name() { return "vpp.In.CropX"; }
|
||||
static CfgParam create_vpp_in_crop_x(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_in_crop_y_name() { return "vpp.In.CropY"; }
|
||||
static CfgParam create_vpp_in_crop_y(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_in_crop_w_name() { return "vpp.In.CropW"; }
|
||||
static CfgParam create_vpp_in_crop_w(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_in_crop_h_name() { return "vpp.In.CropH"; }
|
||||
static CfgParam create_vpp_in_crop_h(uint16_t value);
|
||||
|
||||
|
||||
static constexpr const char *vpp_out_fourcc_name() { return "vpp.Out.FourCC"; }
|
||||
static CfgParam create_vpp_out_fourcc(uint32_t value);
|
||||
|
||||
static constexpr const char *vpp_out_chroma_format_name() { return "vpp.Out.ChromaFormat"; }
|
||||
static CfgParam create_vpp_out_chroma_format(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_width_name() { return "vpp.Out.Width"; }
|
||||
static CfgParam create_vpp_out_width(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_height_name() { return "vpp.Out.Height"; }
|
||||
static CfgParam create_vpp_out_height(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_crop_x_name() { return "vpp.Out.CropX"; }
|
||||
static CfgParam create_vpp_out_crop_x(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_crop_y_name() { return "vpp.Out.CropY"; }
|
||||
static CfgParam create_vpp_out_crop_y(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_crop_w_name() { return "vpp.Out.CropW"; }
|
||||
static CfgParam create_vpp_out_crop_w(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_crop_h_name() { return "vpp.Out.CropH"; }
|
||||
static CfgParam create_vpp_out_crop_h(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_pic_struct_name() { return "vpp.Out.PicStruct"; }
|
||||
static CfgParam create_vpp_out_pic_struct(uint16_t value);
|
||||
|
||||
static constexpr const char *vpp_out_framerate_n_name() { return "vpp.Out.FrameRateExtN"; }
|
||||
static CfgParam create_vpp_out_framerate_n(uint32_t value);
|
||||
|
||||
static constexpr const char *vpp_out_framerate_d_name() { return "vpp.Out.FrameRateExtD"; }
|
||||
static CfgParam create_vpp_out_framerate_d(uint32_t value);
|
||||
|
||||
/**
|
||||
* Create generic onevp::GSource configuration parameter.
|
||||
*
|
||||
*@param name name of parameter.
|
||||
*@param value value of parameter.
|
||||
*@param is_major TRUE if parameter MUST be provided by OneVPL inner implementation, FALSE for optional (for resolve multiple available implementations).
|
||||
*
|
||||
*/
|
||||
template<typename ValueType>
|
||||
static CfgParam create(const std::string& name, ValueType&& value, bool is_major = true) {
|
||||
CfgParam param(name, CfgParam::value_t(std::forward<ValueType>(value)), is_major);
|
||||
return param;
|
||||
}
|
||||
|
||||
struct Priv;
|
||||
|
||||
const name_t& get_name() const;
|
||||
const value_t& get_value() const;
|
||||
bool is_major() const;
|
||||
std::string to_string() const;
|
||||
|
||||
bool operator==(const CfgParam& rhs) const;
|
||||
bool operator< (const CfgParam& rhs) const;
|
||||
bool operator!=(const CfgParam& rhs) const;
|
||||
|
||||
CfgParam& operator=(const CfgParam& src);
|
||||
CfgParam& operator=(CfgParam&& src);
|
||||
CfgParam(const CfgParam& src);
|
||||
CfgParam(CfgParam&& src);
|
||||
~CfgParam();
|
||||
private:
|
||||
CfgParam(const std::string& param_name, value_t&& param_value, bool is_major_param);
|
||||
std::shared_ptr<Priv> m_priv;
|
||||
};
|
||||
|
||||
} //namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP
|
||||
@@ -0,0 +1,105 @@
|
||||
// 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
|
||||
|
||||
#ifndef GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP
|
||||
#define GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
struct GAPI_EXPORTS DataProviderException : public std::exception {
|
||||
DataProviderException(const std::string& descr);
|
||||
DataProviderException(std::string&& descr);
|
||||
|
||||
virtual ~DataProviderException() = default;
|
||||
virtual const char* what() const noexcept override;
|
||||
private:
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
struct GAPI_EXPORTS DataProviderSystemErrorException final : public DataProviderException {
|
||||
DataProviderSystemErrorException(int error_code, const std::string& description = std::string());
|
||||
~DataProviderSystemErrorException() = default;
|
||||
};
|
||||
|
||||
struct GAPI_EXPORTS DataProviderUnsupportedException final : public DataProviderException {
|
||||
DataProviderUnsupportedException(const std::string& description);
|
||||
~DataProviderUnsupportedException() = default;
|
||||
};
|
||||
|
||||
struct GAPI_EXPORTS DataProviderImplementationException : public DataProviderException {
|
||||
DataProviderImplementationException(const std::string& description);
|
||||
~DataProviderImplementationException() = default;
|
||||
};
|
||||
/**
|
||||
* @brief Public interface allows to customize extraction of video stream data
|
||||
* used by onevpl::GSource instead of reading stream from file (by default).
|
||||
*
|
||||
* Interface implementation constructor MUST provide consistency and creates fully operable object.
|
||||
* If error happened implementation MUST throw `DataProviderException` kind exceptions
|
||||
*
|
||||
* @note Interface implementation MUST manage stream and other constructed resources by itself to avoid any kind of leak.
|
||||
* For simple interface implementation example please see `StreamDataProvider` in `tests/streaming/gapi_streaming_tests.cpp`
|
||||
*/
|
||||
struct GAPI_EXPORTS IDataProvider {
|
||||
using Ptr = std::shared_ptr<IDataProvider>;
|
||||
using mfx_codec_id_type = uint32_t;
|
||||
|
||||
/**
|
||||
* NB: here is supposed to be forward declaration of mfxBitstream
|
||||
* But according to current oneVPL implementation it is impossible to forward
|
||||
* declare untagged struct mfxBitstream.
|
||||
*
|
||||
* IDataProvider makes sense only for HAVE_VPL is ON and to keep IDataProvider
|
||||
* interface API/ABI compliant between core library and user application layer
|
||||
* let's introduce wrapper mfx_bitstream which inherits mfxBitstream in private
|
||||
* G-API code section and declare forward for wrapper mfx_bitstream here
|
||||
*/
|
||||
struct mfx_bitstream;
|
||||
|
||||
virtual ~IDataProvider() = default;
|
||||
|
||||
/**
|
||||
* The function is used by onevpl::GSource to extract codec id from data
|
||||
*
|
||||
*/
|
||||
virtual mfx_codec_id_type get_mfx_codec_id() const = 0;
|
||||
|
||||
/**
|
||||
* The function is used by onevpl::GSource to extract binary data stream from @ref IDataProvider
|
||||
* implementation.
|
||||
*
|
||||
* It MUST throw `DataProviderException` kind exceptions in fail cases.
|
||||
* It MUST return MFX_ERR_MORE_DATA in EOF which considered as not-fail case.
|
||||
*
|
||||
* @param in_out_bitsream the input-output reference on MFX bitstream buffer which MUST be empty at the first request
|
||||
* to allow implementation to allocate it by itself and to return back. Subsequent invocation of `fetch_bitstream_data`
|
||||
* MUST use the previously used in_out_bitsream to avoid skipping rest of frames which haven't been consumed
|
||||
* @return true for fetched data, false on EOF and throws exception on error
|
||||
*/
|
||||
virtual bool fetch_bitstream_data(std::shared_ptr<mfx_bitstream> &in_out_bitsream) = 0;
|
||||
|
||||
/**
|
||||
* The function is used by onevpl::GSource to check more binary data availability.
|
||||
*
|
||||
* It MUST return TRUE in case of EOF and NO_THROW exceptions.
|
||||
*
|
||||
* @return boolean value which detects end of stream
|
||||
*/
|
||||
virtual bool empty() const = 0;
|
||||
};
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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 OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
#define OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
|
||||
/**
|
||||
* @brief Provides default device selector based on config.
|
||||
*/
|
||||
GAPI_EXPORTS std::shared_ptr<IDeviceSelector> getDefaultDeviceSelector(const std::vector<CfgParam>& cfg_params);
|
||||
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_STREAMING_ONEVPL_UTILS_HPP
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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
|
||||
|
||||
#ifndef GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
|
||||
#define GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/accel_types.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
struct GAPI_EXPORTS IDeviceSelector {
|
||||
using Ptr = std::shared_ptr<IDeviceSelector>;
|
||||
|
||||
struct GAPI_EXPORTS Score {
|
||||
friend struct IDeviceSelector;
|
||||
using Type = int16_t;
|
||||
static constexpr Type MaxActivePriority = std::numeric_limits<Type>::max();
|
||||
static constexpr Type MinActivePriority = 0;
|
||||
static constexpr Type MaxPassivePriority = MinActivePriority - 1;
|
||||
static constexpr Type MinPassivePriority = std::numeric_limits<Type>::min();
|
||||
|
||||
Score(Type val);
|
||||
~Score();
|
||||
|
||||
operator Type () const;
|
||||
Type get() const;
|
||||
friend bool operator< (Score lhs, Score rhs) {
|
||||
return lhs.get() < rhs.get();
|
||||
}
|
||||
private:
|
||||
Type value;
|
||||
};
|
||||
|
||||
using DeviceScoreTable = std::map<Score, Device>;
|
||||
using DeviceContexts = std::vector<Context>;
|
||||
|
||||
virtual ~IDeviceSelector();
|
||||
virtual DeviceScoreTable select_devices() const = 0;
|
||||
virtual DeviceContexts select_context() = 0;
|
||||
protected:
|
||||
template<typename Entity, typename ...Args>
|
||||
static Entity create(Args &&...args) {
|
||||
return Entity(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
} // namespace onevpl
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP
|
||||
@@ -0,0 +1,94 @@
|
||||
// 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
|
||||
|
||||
#ifndef OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP
|
||||
#define OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP
|
||||
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/streaming/meta.hpp>
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/cfg_params.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/device_selector_interface.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
namespace onevpl {
|
||||
using CfgParams = std::vector<CfgParam>;
|
||||
|
||||
/**
|
||||
* @brief G-API streaming source based on OneVPL implementation.
|
||||
*
|
||||
* This class implements IStreamSource interface.
|
||||
* Its constructor takes source file path (in usual way) or @ref onevpl::IDataProvider
|
||||
* interface implementation (for not file-based sources). It also allows to pass-through
|
||||
* oneVPL configuration parameters by using several @ref onevpl::CfgParam.
|
||||
*
|
||||
* @note stream sources are passed to G-API via shared pointers, so
|
||||
* please gapi::make_onevpl_src<> to create objects and ptr() to pass a
|
||||
* GSource to cv::gin().
|
||||
*/
|
||||
class GAPI_EXPORTS GSource : public IStreamSource
|
||||
{
|
||||
public:
|
||||
struct Priv;
|
||||
|
||||
GSource(const std::string& filePath,
|
||||
const CfgParams& cfg_params = CfgParams{});
|
||||
|
||||
GSource(const std::string& filePath,
|
||||
const CfgParams& cfg_params,
|
||||
const std::string& device_id,
|
||||
void* accel_device_ptr,
|
||||
void* accel_ctx_ptr);
|
||||
|
||||
GSource(const std::string& filePath,
|
||||
const CfgParams& cfg_params,
|
||||
const Device &device, const Context &ctx);
|
||||
|
||||
GSource(const std::string& filePath,
|
||||
const CfgParams& cfg_params,
|
||||
std::shared_ptr<IDeviceSelector> selector);
|
||||
|
||||
|
||||
GSource(std::shared_ptr<IDataProvider> source,
|
||||
const CfgParams& cfg_params = CfgParams{});
|
||||
|
||||
GSource(std::shared_ptr<IDataProvider> source,
|
||||
const CfgParams& cfg_params,
|
||||
const std::string& device_id,
|
||||
void* accel_device_ptr,
|
||||
void* accel_ctx_ptr);
|
||||
|
||||
GSource(std::shared_ptr<IDataProvider> source,
|
||||
const CfgParams& cfg_params,
|
||||
std::shared_ptr<IDeviceSelector> selector);
|
||||
|
||||
~GSource() override;
|
||||
|
||||
bool pull(cv::gapi::wip::Data& data) override;
|
||||
GMetaArg descr_of() const override;
|
||||
|
||||
private:
|
||||
explicit GSource(std::unique_ptr<Priv>&& impl);
|
||||
std::unique_ptr<Priv> m_priv;
|
||||
};
|
||||
} // namespace onevpl
|
||||
|
||||
using GVPLSource = onevpl::GSource;
|
||||
|
||||
template<class... Args>
|
||||
GAPI_EXPORTS_W cv::Ptr<IStreamSource> inline make_onevpl_src(Args&&... args)
|
||||
{
|
||||
return make_src<onevpl::GSource>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP
|
||||
Reference in New Issue
Block a user