ssnyder
December 24, 2019, 12:18am
#1
I’m trying to modify deepstream-app-main.c to use the frame width and height while processing bounding boxes. I replaced the original all_bbox_generated function with this one:
static void
all_bbox_generated (AppCtx * appCtx, GstBuffer * buf,
NvDsBatchMeta * batch_meta, guint index)
{
for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = l_frame->data;
g_print("frame size %d x %d\n", frame_meta->source_frame_width, frame_meta->source_frame_height);
}
}
The resulting output for every frame is:
frame size 0 x 0
frame size 0 x 0
frame size 0 x 0
frame size 0 x 0
Why are these metadata fields not being set? How do I get the overall frame dimensions corresponding to the bounding box coordinates?
amycao
December 24, 2019, 2:03am
#2
ssnyder
December 24, 2019, 2:12am
#3
Hi, I’m looking for the frame dimensions, not the bounding box coordinates.
amycao
December 24, 2019, 2:15am
#4
as for frame dimensions, see NvBufSurface from sources/includes/nvbufsurface.h
ssnyder
December 24, 2019, 2:55am
#5
Ok, so NvDsFrameMeta.source_frame_height and .source_frame_width are not used.
The buffer needs to be mapped to a GstMapInfo struct then NvBufSurfaceParams.width and NvBufSurfaceParams.height can be used.
static void
all_bbox_generated (AppCtx * appCtx, GstBuffer * buf,
NvDsBatchMeta * batch_meta, guint index)
{
for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = l_frame->data;
g_print("NvDsFrameMeta.source_frame_width=%d\n", frame_meta->source_frame_width);
g_print("NvDsFrameMeta.source_frame_height=%d\n", frame_meta->source_frame_height);
}
GstMapInfo map_info;
memset(&map_info, 0, sizeof(map_info));
if (!gst_buffer_map (buf, &map_info, GST_MAP_READ)){
g_print("Error: Failed to map GST buffer");
} else {
NvBufSurface *surface = NULL;
surface = (NvBufSurface *) map_info.data;
g_print("NvBufSurfaceParams.width=%d\n", surface->surfaceList[0].width);
g_print("NvBufSurfaceParams.height=%d\n", surface->surfaceList[0].height);
gst_buffer_unmap(buf, &map_info);
}
}
Output:
NvDsFrameMeta.source_frame_width=0
NvDsFrameMeta.source_frame_height=0
NvBufSurfaceParams.width=608
NvBufSurfaceParams.height=480
1 Like