OpenCV 4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::GStreamingCompiled Class Reference

Represents a computation (graph) compiled for streaming. More...

#include <opencv2/gapi/gstreaming.hpp>

Collaboration diagram for cv::GStreamingCompiled:

Public Member Functions

GAPI_WRAP GStreamingCompiled ()
 
const GMetaArgsmetas () const
 Vector of metadata this graph was compiled for.
 
 operator bool () const
 Check if compiled object is valid (non-empty)
 
const GMetaArgsoutMetas () const
 Vector of metadata descriptions of graph outputs.
 
bool pull (cv::GOptRunArgsP &&outs)
 Get some next available data from the pipeline.
 
bool pull (cv::GRunArgsP &&outs)
 Get the next processed frame from the pipeline.
 
GAPI_WRAP bool running () const
 Test if the pipeline is running.
 
template<typename T , typename... Args>
void setSource (Args &&... args)
 Constructs and specifies an input video stream for a single-input computation pipeline with the given parameters.
 
void setSource (const gapi::wip::IStreamSource::Ptr &s)
 Specify an input video stream for a single-input computation pipeline.
 
void setSource (GRunArgs &&ins)
 Specify the input data to GStreamingCompiled for processing, a generic version.
 
GAPI_WRAP void start ()
 Start the pipeline execution.
 
GAPI_WRAP void stop ()
 Stop (abort) processing the pipeline.
 
bool try_pull (cv::GRunArgsP &&outs)
 Try to get the next processed frame from the pipeline.
 

Detailed Description

Represents a computation (graph) compiled for streaming.

This class represents a product of graph compilation (calling cv::GComputation::compileStreaming()). Objects of this class actually do stream processing, and the whole pipeline execution complexity is incapsulated into objects of this class. Execution model has two levels: at the very top, the execution of a heterogeneous graph is aggressively pipelined; at the very bottom the execution of every internal block is determined by its associated backend. Backends are selected based on kernel packages passed via compilation arguments ( see G-API Graph Compilation Arguments, GNetworkPackage, GKernelPackage for details).

GStreamingCompiled objects have a "player" semantics – there are methods like start() and stop(). GStreamingCompiled has a full control over a videostream and so is stateful. You need to specify the input stream data using setSource() and then call start() to actually start processing. After that, use pull() or try_pull() to obtain next processed data frame from the graph in a blocking or non-blocking way, respectively.

Currently a single GStreamingCompiled can process only one video streat at time. Produce multiple GStreamingCompiled objects to run the same graph on multiple video streams.

See also
GCompiled

Constructor & Destructor Documentation

◆ GStreamingCompiled()

GAPI_WRAP cv::GStreamingCompiled::GStreamingCompiled ( )
Python:
cv.GStreamingCompiled() -> <GStreamingCompiled object>

Member Function Documentation

◆ metas()

const GMetaArgs & cv::GStreamingCompiled::metas ( ) const

Vector of metadata this graph was compiled for.

Returns
Unless reshape is not supported, return value is the same vector which was passed to cv::GComputation::compile() to produce this compiled object. Otherwise, it is the latest metadata vector passed to reshape() (if that call was successful).

◆ operator bool()

cv::GStreamingCompiled::operator bool ( ) const
explicit

Check if compiled object is valid (non-empty)

Returns
true if the object is runnable (valid), false otherwise

◆ outMetas()

const GMetaArgs & cv::GStreamingCompiled::outMetas ( ) const

Vector of metadata descriptions of graph outputs.

Returns
vector with formats/resolutions of graph's output objects, auto-inferred from input metadata vector by operations which form this computation.
Note
GCompiled objects produced from the same cv::GComputiation graph with different input metas may return different values in this vector.

◆ pull() [1/2]

bool cv::GStreamingCompiled::pull ( cv::GOptRunArgsP && outs)
Python:
cv.GStreamingCompiled.pull() -> retval

Get some next available data from the pipeline.

This method takes a vector of cv::optional object. An object is assigned to some value if this value is available (ready) at the time of the call, and resets the object to empty() if it is not.

This is a blocking method which guarantees that some data has been written to the output vector on return.

Using this method only makes sense if the graph has desynchronized parts (see cv::gapi::desync). If there is no desynchronized parts in the graph, the behavior of this method is identical to the regular pull() (all data objects are produced synchronously in the output vector).

Use gout() to create an output parameter vector.

Output vectors must have the same number of elements as defined in the cv::GComputation protocol (at the moment of its construction). Shapes of elements also must conform to protocol (e.g. cv::optional<cv::Mat> needs to be passed where cv::GMat has been declared as output, and so on). Run-time exception is generated on type mismatch.

This method writes new data into objects passed via output vector. If there is no data ready yet, this method blocks. Use try_pull() if you need a non-blocking version.

Parameters
outsvector of output parameters to obtain.
Returns
true if next result has been obtained, false marks end of the stream.
See also
cv::gapi::desync

◆ pull() [2/2]

bool cv::GStreamingCompiled::pull ( cv::GRunArgsP && outs)
Python:
cv.GStreamingCompiled.pull() -> retval

Get the next processed frame from the pipeline.

Use gout() to create an output parameter vector.

Output vectors must have the same number of elements as defined in the cv::GComputation protocol (at the moment of its construction). Shapes of elements also must conform to protocol (e.g. cv::Mat needs to be passed where cv::GMat has been declared as output, and so on). Run-time exception is generated on type mismatch.

This method writes new data into objects passed via output vector. If there is no data ready yet, this method blocks. Use try_pull() if you need a non-blocking version.

Parameters
outsvector of output parameters to obtain.
Returns
true if next result has been obtained, false marks end of the stream.

◆ running()

GAPI_WRAP bool cv::GStreamingCompiled::running ( ) const
Python:
cv.GStreamingCompiled.running() -> retval

Test if the pipeline is running.

Note
This method is not thread-safe (with respect to the user side) at the moment. Protect the access if start()/stop()/setSource() may be called on the same object in multiple threads in your application.
Returns
true if the current stream is not over yet.

◆ setSource() [1/3]

template<typename T , typename... Args>
void cv::GStreamingCompiled::setSource ( Args &&... args)
inline
Python:
cv.GStreamingCompiled.setSource(callback) -> None

Constructs and specifies an input video stream for a single-input computation pipeline with the given parameters.

Throws if pipeline is already running. Use stop() and then setSource() to run the graph on a new video stream.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
argsarguments used to construct and initialize a stream source.
Here is the call graph for this function:

◆ setSource() [2/3]

void cv::GStreamingCompiled::setSource ( const gapi::wip::IStreamSource::Ptr & s)
Python:
cv.GStreamingCompiled.setSource(callback) -> None

Specify an input video stream for a single-input computation pipeline.

Throws if pipeline is already running. Use stop() and then setSource() to run the graph on a new video stream.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sa shared pointer to IStreamSource representing the input video stream.

◆ setSource() [3/3]

void cv::GStreamingCompiled::setSource ( GRunArgs && ins)
Python:
cv.GStreamingCompiled.setSource(callback) -> None

Specify the input data to GStreamingCompiled for processing, a generic version.

Use gin() to create an input parameter vector.

Input vectors must have the same number of elements as defined in the cv::GComputation protocol (at the moment of its construction). Shapes of elements also must conform to protocol (e.g. cv::Mat needs to be passed where cv::GMat has been declared as input, and so on). Run-time exception is generated on type mismatch.

In contrast with regular GCompiled, user can also pass an object of type GVideoCapture for a GMat parameter of the parent GComputation. The compiled pipeline will start fetching data from that GVideoCapture and feeding it into the pipeline. Pipeline stops when a GVideoCapture marks end of the stream (or when stop() is called).

Passing a regular Mat for a GMat parameter makes it "infinite" source – pipeline may run forever feeding with this Mat until stopped explicitly.

Currently only a single GVideoCapture is supported as input. If the parent GComputation is declared with multiple input GMat's, one of those can be specified as GVideoCapture but all others must be regular Mat objects.

Throws if pipeline is already running. Use stop() and then setSource() to run the graph on a new video stream.

Note
This method is not thread-safe (with respect to the user side) at the moment. Protect the access if start()/stop()/setSource() may be called on the same object in multiple threads in your application.
Parameters
insvector of inputs to process.
See also
gin

◆ start()

GAPI_WRAP void cv::GStreamingCompiled::start ( )
Python:
cv.GStreamingCompiled.start() -> None

Start the pipeline execution.

Use pull()/try_pull() to obtain data. Throws an exception if a video source was not specified.

setSource() must be called first, even if the pipeline has been working already and then stopped (explicitly via stop() or due stream completion)

Note
This method is not thread-safe (with respect to the user side) at the moment. Protect the access if start()/stop()/setSource() may be called on the same object in multiple threads in your application.

◆ stop()

GAPI_WRAP void cv::GStreamingCompiled::stop ( )
Python:
cv.GStreamingCompiled.stop() -> None

Stop (abort) processing the pipeline.

Note - it is not pause but a complete stop. Calling start() will cause G-API to start processing the stream from the early beginning.

Throws if the pipeline is not running.

◆ try_pull()

bool cv::GStreamingCompiled::try_pull ( cv::GRunArgsP && outs)

Try to get the next processed frame from the pipeline.

Use gout() to create an output parameter vector.

This method writes new data into objects passed via output vector. If there is no data ready yet, the output vector remains unchanged and false is returned.

Returns
true if data has been obtained, and false if it was not. Note: false here doesn't mark the end of the stream.

The documentation for this class was generated from the following file: