Hi,
I’m working with opencv and gstreamer, I’m using the following code to extract the frames of the pipeline.
static GstPadProbeReturn frame_processing(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
buffer = (GstBuffer *)info->data;
map_info = {0};
dmabuf_fd = 0;
gst_buffer_map(buffer, &map_info, GST_MAP_READ);
ExtractFdFromNvBuffer((void *)map_info.data, &dmabuf_fd);
{
egl_image = NvEGLImageFromFd(egl_display, dmabuf_fd);
cudaFree(0);
status = cuGraphicsEGLRegisterImage(&p_resource, egl_image, CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD);
status = cuGraphicsResourceGetMappedEglFrame(&egl_frame, p_resource, 0, 0);
status = cuCtxSynchronize();
cv::cuda::GpuMat d_mat_BGRA(H, W, CV_8UC4, egl_frame.frame.pPitch[0]);
...
doing things...
...
}
return GST_PAD_PROBE_OK;
}
Ok, my doubt is with the following line:
cv::cuda::GpuMat d_mat_BGRA(H, W, CV_8UC4, egl_frame.frame.pPitch[0]);
I want try to understand why here is CV_8UC4. I have two cameras, one of them is a thermal camera and with this configuration my program doesn’t work. But with my other visible camera, my program it’s works.
When I put the thermal camera, when I try to convert the image to gray with “cvtcolor” for example my program crashes.
I try too putting:
cv::cuda::GpuMat d_mat_BGRA(H, W, CV_8UC1, egl_frame.frame.pPitch[0]);
d_mat_BGRA.setTo(cv::Scalar(255));
And the image is correct but when I try to modify it I see the image wrong, as if the image had noise or something similar.
Any help about this topic will be well receive.
Thanks