Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson /)
**• DeepStream Version 6.3
**• JetPack Version (valid for Jetson only) 5.1.2
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
hello,
I want save frame with opencv at osd_sink_pad_buffer_probe(), application is deepstream-test1, this How to convert NvBufSurface to cv::Mat - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums is demo,but third time core dump,
Another question is frame color format, deepstream-test1 osd_sink_pad_buffer_probe frame color format is 6(NV12), but my application is 19 (RGBA),cv::mat clone not core dump, but memory very increase fast. I want know how to set it , it depend what?
code like this:
static GstPadProbeReturn
osd_sink_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
GstBuffer *buf = (GstBuffer *) info->data;
guint num_rects = 0;
NvDsObjectMeta *obj_meta = NULL;
guint vehicle_count = 0;
guint person_count = 0;
NvDsMetaList * l_frame = NULL;
NvDsMetaList * l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;
GstMapInfo mapInfo;
memset(&mapInfo, 0, sizeof(mapInfo));
if (!gst_buffer_map(buf, &mapInfo, GST_MAP_READ))
{
g_error("Error: Failed to map gst buffer\n");
}
NvBufSurface *surface = (NvBufSurface *)mapInfo.data;
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
int offset = 0;
if (NvBufSurfaceMap(surface, -1, -1, NVBUF_MAP_READ) != 0)
{
printf("buffer map to be accessed by CPU failed\n");
}
NvBufSurfaceSyncForCpu(surface, -1, -1);
printf("infer w %d h %d color format %d \n", surface->surfaceList[frame_meta->batch_id].planeParams.width[0],
surface->surfaceList[frame_meta->batch_id].planeParams.height[0],
(int)(surface->surfaceList[frame_meta->batch_id].colorFormat));
guint height = surface->surfaceList[frame_meta->batch_id].height;
guint width = surface->surfaceList[frame_meta->batch_id].width;
cv::Mat frameMat = cv::Mat(height*3/2,
width, CV_8UC1,
surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0],
surface->surfaceList[frame_meta->batch_id].planeParams.pitch[0]);
cv::Mat frameOri = frameMat.clone();
NvBufSurfaceUnMap(surface, -1, -1);
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
l_obj = l_obj->next) {
obj_meta = (NvDsObjectMeta *) (l_obj->data);
if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
vehicle_count++;
num_rects++;
}
if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
person_count++;
num_rects++;
}
}
display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
display_meta->num_labels = 1;
txt_params->display_text = (char*)g_malloc0 (MAX_DISPLAY_LEN);
offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ", person_count);
offset = snprintf(txt_params->display_text + offset , MAX_DISPLAY_LEN, "Vehicle = %d ", vehicle_count);
/* Now set the offsets where the string should appear */
txt_params->x_offset = 10;
txt_params->y_offset = 12;
/* Font , font-color and font-size */
txt_params->font_params.font_name = "Serif";
txt_params->font_params.font_size = 10;
txt_params->font_params.font_color.red = 1.0;
txt_params->font_params.font_color.green = 1.0;
txt_params->font_params.font_color.blue = 1.0;
txt_params->font_params.font_color.alpha = 1.0;
/* Text background color */
txt_params->set_bg_clr = 1;
txt_params->text_bg_clr.red = 0.0;
txt_params->text_bg_clr.green = 0.0;
txt_params->text_bg_clr.blue = 0.0;
txt_params->text_bg_clr.alpha = 1.0;
nvds_add_display_meta_to_frame(frame_meta, display_meta);
}
g_print ("Frame Number = %d Number of objects = %d "
"Vehicle Count = %d Person Count = %d\n",
frame_number, num_rects, vehicle_count, person_count);
frame_number++;
return GST_PAD_PROBE_OK;
}