mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #20546 from sivanov-work:initial_vpl_source
G-API: oneVPL (simplification) source base commit * oneVPL source initial * Fix compilation * Fix compilation path * Fix NO VPL compile * Fix unused vars * Fix unused vars in example * Simplify oneVPL search: no custom path & download * Fix standalone GAPI * Apply comments
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// 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/onevpl_source.hpp>
|
||||
|
||||
#include "streaming/onevpl/onevpl_source_priv.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
OneVPLSource::OneVPLSource(const std::string& filePath) :
|
||||
OneVPLSource(std::unique_ptr<Priv>(new OneVPLSource::Priv(filePath))) {
|
||||
|
||||
if (filePath.empty()) {
|
||||
util::throw_error(std::logic_error("Cannot create 'OneVPLSource' on empty source file name"));
|
||||
}
|
||||
}
|
||||
#else
|
||||
OneVPLSource::OneVPLSource(const std::string&) {
|
||||
GAPI_Assert(false && "Unsupported: G-API compiled without `WITH_GAPI_ONEVPL=ON`");
|
||||
}
|
||||
#endif
|
||||
|
||||
OneVPLSource::OneVPLSource(std::unique_ptr<Priv>&& impl) :
|
||||
IStreamSource(),
|
||||
m_priv(std::move(impl)) {
|
||||
}
|
||||
|
||||
OneVPLSource::~OneVPLSource() {
|
||||
}
|
||||
|
||||
bool OneVPLSource::pull(cv::gapi::wip::Data& data)
|
||||
{
|
||||
return m_priv->pull(data);
|
||||
}
|
||||
|
||||
GMetaArg OneVPLSource::descr_of() const
|
||||
{
|
||||
return m_priv->descr_of();
|
||||
}
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
@@ -0,0 +1,63 @@
|
||||
// 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 <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#include "streaming/onevpl/onevpl_source_priv.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#ifndef HAVE_ONEVPL
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
bool OneVPLSource::Priv::pull(cv::gapi::wip::Data&) {
|
||||
return true;
|
||||
}
|
||||
GMetaArg OneVPLSource::Priv::descr_of() const {
|
||||
return {};
|
||||
}
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#else // HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
OneVPLSource::Priv::Priv() :
|
||||
mfx_handle(MFXLoad())
|
||||
{
|
||||
GAPI_LOG_INFO(nullptr, "Initialized MFX handle: " << mfx_handle);
|
||||
description_is_valid = false;
|
||||
}
|
||||
|
||||
OneVPLSource::Priv::Priv(const std::string&) :
|
||||
OneVPLSource::Priv()
|
||||
{
|
||||
}
|
||||
|
||||
OneVPLSource::Priv::~Priv()
|
||||
{
|
||||
GAPI_LOG_INFO(nullptr, "Unload MFX handle: " << mfx_handle);
|
||||
MFXUnload(mfx_handle);
|
||||
}
|
||||
|
||||
bool OneVPLSource::Priv::pull(cv::gapi::wip::Data&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GMetaArg OneVPLSource::Priv::descr_of() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // HAVE_ONEVPL
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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_PRIV_HPP
|
||||
#define OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_PRIV_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/streaming/meta.hpp>
|
||||
#include <opencv2/gapi/streaming/onevpl/onevpl_source.hpp>
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
#if (MFX_VERSION >= 2000)
|
||||
#include <vpl/mfxdispatcher.h>
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#include <vpl/mfx.h>
|
||||
|
||||
#include <vpl/mfxvideo.h>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
|
||||
struct OneVPLSource::Priv
|
||||
{
|
||||
explicit Priv(const std::string& file_path);
|
||||
~Priv();
|
||||
|
||||
bool pull(cv::gapi::wip::Data& data);
|
||||
GMetaArg descr_of() const;
|
||||
private:
|
||||
Priv();
|
||||
mfxLoader mfx_handle;
|
||||
bool description_is_valid;
|
||||
};
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#else // HAVE_ONEVPL
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
struct OneVPLSource::Priv final
|
||||
{
|
||||
bool pull(cv::gapi::wip::Data&);
|
||||
GMetaArg descr_of() const;
|
||||
};
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
#endif // HAVE_ONEVPL
|
||||
#endif // OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_PRIV_HPP
|
||||
Reference in New Issue
Block a user