Merge pull request #20832 from TolyaTalamanov:at/python-gstreamer-source

G-API: Wrap GStreamerSource

* Wrap GStreamerSource into python

* Fixed test skipping when can't make Gst-src

* Wrapped GStreamerPipeline class, added dummy test for it

* Fix no_gst testing

* Changed wrap for GStreamerPipeline::getStreamingSource() : now python-specific in-class method GStreamerPipeline::get_streaming_source()

* Added accuracy tests vs OCV:VideoCapture(Gstreamer)

* Add skipping when can't use VideoCapture(GSTREAMER);
Add better handling of GStreamer backend unavailable;
Changed video to avoid terminations

* Applying comments

* back to a separate get_streaming_source function, with comment

Co-authored-by: OrestChura <orest.chura@intel.com>
This commit is contained in:
Anatoliy Talamanov
2022-01-26 17:01:13 +03:00
committed by GitHub
parent 9238316cf1
commit 2b79a6ff8f
6 changed files with 220 additions and 4 deletions
@@ -19,12 +19,12 @@ namespace gapi {
namespace wip {
namespace gst {
class GAPI_EXPORTS GStreamerPipeline
class GAPI_EXPORTS_W GStreamerPipeline
{
public:
class Priv;
explicit GStreamerPipeline(const std::string& pipeline);
GAPI_WRAP explicit GStreamerPipeline(const std::string& pipeline);
IStreamSource::Ptr getStreamingSource(const std::string& appsinkName,
const GStreamerSource::OutputType outputType =
GStreamerSource::OutputType::MAT);
@@ -40,6 +40,18 @@ protected:
using GStreamerPipeline = gst::GStreamerPipeline;
// NB: Function for using from python
// FIXME: a separate function is created due to absence of wrappers for `shared_ptr<> `
// Ideally would be to wrap the `GStreamerPipeline::getStreamingSource()` method as is
GAPI_EXPORTS_W cv::Ptr<IStreamSource>
inline get_streaming_source(cv::Ptr<GStreamerPipeline>& pipeline,
const std::string& appsinkName,
const GStreamerSource::OutputType outputType
= GStreamerSource::OutputType::MAT)
{
return pipeline->getStreamingSource(appsinkName, outputType);
}
} // namespace wip
} // namespace gapi
} // namespace cv
@@ -82,6 +82,14 @@ protected:
using GStreamerSource = gst::GStreamerSource;
// NB: Overload for using from python
GAPI_EXPORTS_W cv::Ptr<IStreamSource>
inline make_gst_src(const std::string& pipeline,
const GStreamerSource::OutputType outputType =
GStreamerSource::OutputType::MAT)
{
return make_src<GStreamerSource>(pipeline, outputType);
}
} // namespace wip
} // namespace gapi
} // namespace cv