How to access a gray frame in preprocess plug-in?

complete information .

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

I want to set the preprocess roi-params adaptive to variable images.
so, firstly I need to access a gray fram from gstbuffer.

in this function:
/* Process entire frames in the batched buffer. */
static GstFlowReturn
gst_nvdspreprocess_on_frame (GstNvDsPreProcess * nvdspreprocess, GstBuffer * inbuf,
NvBufSurface * in_surf)

NvBufSurfaceMap (in_surf, i, 0, NVBUF_MAP_READ);

        // sync mapped data for CPU access

NvBufSurfaceSyncForCpu (in_surf, i, 0);
cv::Mat nv12_frame(h0 * 3 / 2, w0, CV_8UC1, in_surf->surfaceList[i].mappedAddr.addr[0]);

// Convert NV12 frame to grayscale
cv::Mat gray_frame;
cv::cvtColor(nv12_frame, gray_frame, cv::COLOR_YUV2GRAY_NV12);

after running, I found the result is not correct.
Please tell me what’s the problem.

Thank you.

1.Please make sure the format of in_surf is NV12.
2.Please make sure the method below is right for get the Nv12 data to Mat.

cv::Mat nv12_frame(h0 * 3 / 2, w0, CV_8UC1, in_surf->surfaceList[i].mappedAddr.addr[0]);
  1. You can try to add the code to the dump_rois API in our demo code first.

I’ll check it. thx.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

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