Convert RGB and BGR data to other format

HI guys,
we want to convert RGB or BGR frame to other format like NV12, I420 but nvvidconv and nvvideoconvert does’nt support these format as input and out put. Even nvbuf_utils header does’nt have these format so should it be better to use CUDA for converting?
Thanks so much

please help me

With gstreamer you may use videoconvert for converting BGR/RGB to/from BGRx/RGBA and use nvvidconv for converting BGRx/RGBA to/from another format such as NV12, I420, YUY2, …
Note that videoconvert uses system memory (video/x-raw) while nvvidconv may expect at least one of its input or output in NVMM memory.

... ! video/x-raw,format=BGR ! videoconvert ! video/x-raw, format=BGRx ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! ...

... ! video/x-raw,format=RGB ! videoconvert ! video/x-raw, format=RGBA ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! ...

Thanks for your answer
In fact nvbuf_util.h doesn’t have RGB/BGR format but nvbufsurface.h has NVBUF_COLOR_FORMAT_RGB and NVBUF_COLOR_FORMAT_BGR, so we don’t want to use videoconvert because it’s not as fast as DMA.
RGBA, BGRA, BGRx and RGBx have extra alpha channel and data is packed as a sequence like (R-G-B-255, R-G-B-255 ,…) where the last 255 is the alpha channel byte. However, the alpha byte is not used in Image Processing algorithms so it must be omitted which is time consuming. So what should we do?

Please check the discussion in
[Gstreamer] nvvidconv, BGR as INPUT - #4 by DaneLLL
The hardware converter does not support 24-bit BGR so you would need to convert to RGBA.

And then you can re-sample RGBA to BGR through CUDA code. We have sample code in jetson_multiemdia_api samples for re-sampling RGBA to individual B, G R planes. It is not exactly same as re-sampling RGBA to BGR, but you may take a look.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.