Resize GAPI inputs in IStreamSource

Hi there,

I have set up a custom implementation of the IStreamSource interface and implemented the “pull” and the “descr_of” method. In the latter, I return the metadata of the first frame I capture.

Now, it can happen, that my source changes its dimensions at some point (as I am recording windows on the screen). As soon as this happens, the pipeline crashes with the error code “libc++abi.dylib: terminating with uncaught exception of type std::logic_error: OpenCV kernel output parameter was reallocated. Incorrect meta data was provided?”

The reason seams to be clear: On start, I report some dimensions and later those dimensions change… Now, how can I resolve this issue? I checked an the “descr_of” method is only once at startup so I don’t know how I can report a change in dimensions later on.


That’s my fear : that the open cv gapi source be of constant size. Interesting point from Maurice. Can someone confirm or infirm ?.
Btw, Maurice Can you share a bit of your implementation? There isn’t any example of istreamingsource implementation out there. Just wandering if you could stream out a constant size and then do the resize with cv:: Rect after pulling the image out of the istreamingsource?

Hi @Maurice!

Unfortunately, currently stream sources are expected to provide data of the exact same size - G-API allocates internal data structures based on that information. When a stream runs, the input size can not be changed.

You can, however, stop the stream and run it with a new Source - with different dimensions in - and this should work.

If you expect your data to change dimensions as part of the single stream, please report a feature request on Github so we’ll take that for the design review

1 Like

There is cap.hpp which implements a bare minimum IStreamSource over the cv::VideoCapture, and there are more advanced GStreamer-based and oneVPL-based sources are coming:

Beware: these implementations may be hard to follow and the “constant size” limitation is still there

1 Like