**• Hardware Platform (Jetson NX) **
**• DeepStream Version (5.1) **
• JetPack Version (4.5.1)
• TensorRT Version (7.1.3)
Hello, Sir/Madam
I am using the deepstream-test5 with ip cam(1920x1080p) in my job now.
I have search around the forum for green image issues, and found this solution. However, I replace two files (deepstream_primary_gie_bin.c and deepstream_primary_gie.h), the problem is not solved.
When I set [streammux] with low resolution, I got the correct result. I have same problem like this.
My question is that how can I get correct frame from pipeline. Where can I find the code from deepstream which cause this problem.
this is my sample code where I got frame from pipeline:
cv::Mat enc_object(GstBuffer * buf, guint stream_id)
{
NvBufSurface *ip_surf = NULL;
char* src_data = NULL;
GstMapInfo inmap = GST_MAP_INFO_INIT;
if (!gst_buffer_map (buf, &inmap, GST_MAP_READ)) {
g_print ("Error: Failed to map gst buffer\n");
gst_buffer_unmap (buf, &inmap);
return "error";
}
ip_surf = (NvBufSurface *) inmap.data;
src_data = (char*) malloc(ip_surf->surfaceList[stream_id].dataSize);
if(src_data == NULL) g_print("Error: failed to malloc src_data \n");
#ifdef PLATFORM_TEGRA
NvBufSurfaceMap (ip_surf, -1, -1, NVBUF_MAP_READ);
NvBufSurfacePlaneParams *pParams = &ip_surf->surfaceList[stream_id].planeParams;
unsigned int offset = 0;
for(unsigned int num_planes=0; num_planes < pParams->num_planes; num_planes++){
if(num_planes>0)
offset += pParams->height[num_planes-1]*(pParams->bytesPerPix[num_planes-1]*pParams->width[num_planes-1]);
for (unsigned int h = 0; h < pParams->height[num_planes]; h++) {
memcpy((void *)(src_data+offset+h*pParams->bytesPerPix[num_planes]*pParams->width[num_planes]),
(void *)((char *)ip_surf->surfaceList[stream_id].mappedAddr.addr[num_planes]+h*pParams->pitch[num_planes]),
pParams->bytesPerPix[num_planes]*pParams->width[num_planes]
);
}
}
NvBufSurfaceSyncForDevice (ip_surf, -1, -1);
NvBufSurfaceUnMap (ip_surf, -1, -1);
#else
cudaMemcpy((void*)src_data,
(void*)ip_surf->surfaceList[stream_id].dataPtr,
ip_surf->surfaceList[stream_id].dataSize,
cudaMemcpyDeviceToHost);
#endif
gint frame_width = (gint)ip_surf->surfaceList[stream_id].width;
gint frame_height = (gint)ip_surf->surfaceList[stream_id].height;
gint frame_step = ip_surf->surfaceList[stream_id].pitch;
cv::Mat picYV12 = cv::Mat(frame_height * 3/2, frame_width, CV_8UC1, src_data, frame_step);
cv::Mat picBGR = cv::Mat (cv::Size(frame_width, frame_height), CV_8UC3);
cv::cvtColor(picYV12, picBGR, CV_YUV2BGR_NV12);
if(src_data != NULL) {
free(src_data);
src_data = NULL;
}
gst_buffer_unmap (buf, &inmap);
return picBGR;
}
Thank you very much.