Using gapi::NV12toRGB

Is there any description or sample code of how to use gapi::NV12toRGB, or other gapi conversion routines, with cv::Mat source and outputs? Something that actually works would be nice.

I’ve been through the code and google and cannot find anything.

Hello!

The description of functions is available on official OpenCV Docs portal - the particular gapi::NV12toRGB function description is here.

As for the usage, there are no samples on this particular function, but there is a test where you can see how to use it (modules/gapi/test/common/gapi_imgproc_tests_inl.hpp:775);
a simple image processing pipeline (including gapi::BGR2Gray conversion usage) can be seen in modules/gapi/samples/api_example.cpp.

1 Like

Hi @LarryK348 ,

Any operation available in G-API is tested, so a proper test might give you a hint.

For NV12toRGB: opencv/gapi_imgproc_tests_inl.hpp at 4.6.0 · opencv/opencv · GitHub

You may find that this operation has two inputs, so assumes that you have Y and UV planes already separated. This may not be suitable for the real world data sources (e.g. cameras or decoders) where all you have is some Surface, Texture, or DMAFD encapsulating both planes.

In G-API, we have a special data structure for that: OpenCV: cv::GFrame Class Reference & OpenCV: cv::MediaFrame Class Reference

GFrame is a graph data type, and MediaFrame is a run-time data structure. There is a number of methods available to process GFrame in the graph depending on your scenario:

And note some components (like inference) already have direct GFrame input support, so no explicit conversion required.