Hello, I am testing nvBuffer and OpenCV data Transfer by using examples from camera_v4l2_cuda. My camera is a USB MJPEG. At the first step, I successfully ran the original code of camera_v4l2_cuda. After that, I modified the code to create cv::Mat from nvBuffer. It cause a Segmentation fault (core dump) when I ran it. Could you advise what should I do?
Thank you for advise, the problem was solved. Below is my late code.
/* transfer mmap to opencv Mat */
NvBufferParams params;
void *pdata = NULL;
NvBufferGetParams(ctx->render_dmabuf_fd, ¶ms);
NvBufferMemMap(ctx->render_dmabuf_fd, 0, NvBufferMem_Read_Write, &pdata);
NvBufferMemSyncForCpu(ctx->render_dmabuf_fd, 0, &pdata);
//
// put data into matprocess queue.
cv::Mat picBGR = cv::Mat(ctx->cam_h, ctx->cam_w, CV_8UC4, pdata);
cv::Mat matIn = picBGR.clone();
//
// Unmap hardware buffer, and put buffer back to video queue.
NvBufferMemUnMap(ctx->render_dmabuf_fd, 0, &pdata); // ← must unmap after opencv display.
…
and I did some patches in function prepare_buffers_mjpeg, I used NvBufferColorFormat_ARGB32.
input_params.colorFormat= NvBufferColorFormat_ARGB32 ;
…
above code is work fine with my camera ELP MJPEG 260fps @640x360.