How can I get gray value of every pixel?

Hardware Platform (Jetson / GPU) NX
• DeepStream Version 6.11
• JetPack Version (valid for Jetson only) 5.02
• TensorRT Version 8.4

Modifying the preprocess. I want to configure my own ROI, so I need to obtain gray value of current frame.
below is part of my function.

gint* calc_roi (GstNvDsPreProcess * nvdspreprocess, NvDsPreProcessBatch *batch,
NvBufSurface * outsurf)
{
// cv::Mat in_mat, out_mat;
static guint cnt = 0; // guint src_id = G_MAXUINT; // guint roi_cnt = 0;
static gint x_roi[4];

// Map the buffer so that it can be accessed by CPU
gint i = 0;
if (NvBufSurfaceMap (outsurf, i, 0, NVBUF_MAP_READ) != 0) {
GST_ELEMENT_ERROR (nvdspreprocess, STREAM, FAILED,
(“%s:buffer map to be accessed by CPU failed”, func), (NULL));
return FALSE;
}

// sync mapped data for CPU access
NvBufSurfaceSyncForCpu (outsurf, i,0);

I donnot know how to obtain gray value from outsurf, please help.

The RGB or YUV data are in NvBufSurface. Frequently Asked Questions — DeepStream 6.1.1 Release documentation

https://docs.nvidia.com/metropolis/deepstream/dev-guide/sdk-api/structNvBufSurface.html

You may refer to /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-image-meta-test

Thanks.

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