Gstreamer Pipeline to NV12toBGR using GAPI
I am using a gstreamer pipeline with OpenCV VideoCapture on Jetson Nano. The source is captured in NV12 and I have to convert to BGR in the gstreamer pipeline. In order to optimize it, I thought I would use Graph-API. My understanding is that I would leave the pipeline in the NV12 format and then I would do something like the following for GAPI:
cv::GMat in;
cv::GMat out = cv::gapi::NV12toBGR(in);
cv::GComputation ac(in, out);
//videocapture stuff
ac.apply(input, output);
But as it turns out, NV12toBGR has two parameters for y and uv respectively. How are you supposed to use this function alongside a gstreamer pipeline that would capture in NV12?
My gstreamer pipeline for VdieoCapture typically looks like this:
nvarugscamerasrc sensor_id=0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=NV12 ! nvvidconv ! video/x-raw, format=I420 ! appsink max-buffers=1 drop=true
Later, I convert the YUV_I420 to BGR with cvtColor. I figured I could just go from NV12 to BGR instead of this current method.
looks like it's the equivalent of cvtColorTwoPlane
how do you acquire the nv12 imge ? how does it look like in memory ?
if it's inside a cv::Mat, you could try to split it into 2 ROIs, upper 2/3 height for Y, lower 1/3 for UV
Here is link for cv.cvtColorTwoPlane
@berak Output image of the same row/column size and depth as ysrc
^^ i asked about the input
Well I'm not really sure how to check because the gstreamer pipeline won't open since NV12 isn't a supported format in OpenCV. I figured the pipeline would only be able to give me one Mat which I would send into the function, but evidently that's not how the function works.
I guess I'm partly confused as to the purpose of this function. It seems perfect to work with Nvidia's stuff so I was just assuming it would be easy for me to add to the gstreamer pipeline.
it's also unclear what your "gstreamer pipeline" exactly is.
btw, most android phones seem to use nv12 natively, so this is not an "exotic problem"
Sorry, updated my question with the gstreamer pipeline I am using