Access specific pixels of Nvbufsurface and convert them from YUV color space to RGB color space

/**
 * Scale the entire frame to the processing resolution maintaining aspect ratio.
 * Or crop and scale objects to the processing resolution maintaining the aspect
 * ratio. Remove the padding required by hardware and convert from RGBA to RGB
 * using openCV. These steps can be skipped if the algorithm can work with
 * padded data and/or can work with RGBA.
 */
static GstFlowReturn
get_converted_mat (GstDsExample * dsexample, NvBufSurface *input_buf, gint idx,
    NvOSD_RectParams * crop_rect_params, gdouble & ratio, gint input_width,
    gint input_height)

I wanted access specific pixel (100, 200) value from the data present in input_buf. Based on the gstdsexample.cpp I followed this approach to use a function similar to
get_converted_mat() to create a mat surface( let say buf_mat) from nvbufsurface and access the RGB value of specific pixel indexing buf_mat. It works fine. But as I need to access just a specific pixel, I don’t want convert entire nvbufsurface to mat and then index it. Is there any way to access just the specific pixel value from Nvbufsurface which is YUV color space and convert to RGB color space?

Thanks,
Ganesh.

1 Like