Here is the point wise answer
- Yes, I am testing with deepstream-app. Please see the main config file, I have already shared model config file in earlier post.
[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5
[tiled-display]
enable=0
[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
type=4
uri=rtsp://127.0.0.1:8555/stream
num-sources=1
gpu-id=0
# (0): memtype_device - Memory type Device
# (1): memtype_pinned - Memory type Host Pinned
# (2): memtype_unified - Memory type Unified
cudadec-memtype=0
rtsp-reconnect-interval-sec=1
select-rtp-protocol=4
latency=500
udp-buffer-size=100000000
#rtsp-reconnect-attempts=10
[sink0]
enable=0
#Type - 1=FakeSink 2=EglSink/nv3dsink (Jetson only) 3=File
type=1
container=1
#sync=0
codec=1
enc-type=0
source-id=0
gpu-id=0
nvbuf-memory-type=0
[sink1]
enable=1
type=4
#1=mp4 2=mkv
container=1
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
#iframeinterval=10
bitrate=3000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
# set profile only for hw encoder, sw encoder selects profile based on sw-preset
profile=0
rtsp-port=8550
udp-buffer-size=100000000
[osd]
enable=1
gpu-id=0
border-width=1
text-size=7
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0
nvbuf-memory-type=0
display-bbox=1
display-text=1
[streammux]
gpu-id=0
##Boolean property to inform muxer that sources are live
#live-source=0
live-source=1
batch-size=1
buffer-pool-size=500
## Set muxer output width and height
width=1920
height=1080
#width=640
#height=480
##Enable to maintain aspect ratio wrt source, and allow black borders, works
##along with width, height properties
enable-padding=1
nvbuf-memory-type=0
## If set to TRUE, system timestamp will be attached as ntp timestamp
## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
attach-sys-ts-as-ntp=1
batched-push-timeout=33333
sync-inputs=1
#frame-duration=1000
[primary-gie]
enable=1
gpu-id=0
batch-size=1
#Required by the app for OSD, not a plugin property
bbox-border-color0=0;0;1;1
bbox-border-color1=0;0;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;0;1;1
interval=0
#Required by the app for SGIE, when used along with config-file property
gie-unique-id=1
nvbuf-memory-type=0
config-file=scrfd_config.txt
[secondary-pre-process0]
enable=1
operate-on-gie-id=1
config-file=primary_preprocess.txt
[secondary-gie0]
enable=1
gpu-id=0
batch-size=1
gie-unique-id=2
input-tensor-meta=1
operate-on-gie-id=1
nvbuf-memory-type=0
config-file=yolo_config.txt
[secondary-pre-process1]
enable=1
operate-on-gie-id=1
config-file=secondary_preprocess_recog.txt
[secondary-gie1]
enable=1
gpu-id=0
batch-size=1
gie-unique-id=3
operate-on-gie-id=1
nvbuf-memory-type=0
input-tensor-meta=0
config-file=recog_config.txt
[secondary-pre-process3]
enable=1
operate-on-gie-id=1
config-file=secondary_preprocess.txt
[secondary-gie2]
enable=1
gpu-id=0
batch-size=1
gie-unique-id=4
input-tensor-meta=1
operate-on-gie-id=1
nvbuf-memory-type=0
config-file=swap_config.txt
[secondary-gie3]
enable=1
gpu-id=0
batch-size=1
gie-unique-id=5
input-tensor-meta=0
operate-on-gie-id=2
nvbuf-memory-type=0
config-file=solider_config.txt
[tracker]
enable=1
# For NvDCF and DeepSORT tracker, tracker-width and tracker-height must be a multiple of 32, respectively
tracker-width=640
tracker-height=640
ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_NvSORT.yml
display-tracking-id=1
[tests]
file-loop=0
- I have added the code in attach_tensor_output_meta() and I am able to access the raw tensor.
if (nvinfer->input_tensor_from_meta) {
/* Attach tensor meta as part of ROI Meta */
nvds_add_user_meta_to_roi (frame.roi_meta, user_meta);
/* Attach ROI Meta to Frame Meta */
NvDsUserMeta *user_meta = nvds_acquire_user_meta_from_pool (batch_meta);
user_meta->user_meta_data = frame.roi_meta;
user_meta->base_meta.meta_type =
(NvDsMetaType) NVDS_ROI_META;
user_meta->base_meta.release_func = release_user_meta_at_frame_level;
user_meta->base_meta.copy_func = NULL;
user_meta->base_meta.batch_meta = batch_meta;
nvds_add_user_meta_to_frame (frame.frame_meta, user_meta);
/* if object is roi itself */
if (frame.obj_meta) {
nvds_add_user_meta_to_obj (frame.obj_meta, user_meta);
//std::cout << "[DEBUG] Attached ROI meta to Object: " << frame.obj_meta << std::endl;
// Post-attachment: verify object meta contents again
NvDsFrameMeta *om = frame.frame_meta;
std::cout << __func__ << "Frame Num: " << om->frame_num << " " << om << std::endl;
for (NvDsUserMetaList *l = om->frame_user_meta_list; l; l = l->next) {
NvDsUserMeta *meta = (NvDsUserMeta *)l->data;
std::cout << " [POST] meta_type: " << meta->base_meta.meta_type << std::endl;
NvDsRoiMeta *roi_meta =
(NvDsRoiMeta *) meta->user_meta_data;
for (NvDsUserMetaList * r_user = roi_meta->roi_user_meta_list;
r_user != NULL; r_user = r_user->next){
NvDsUserMeta *tensor_user_meta = (NvDsUserMeta *) r_user->data;
if (tensor_user_meta->base_meta.meta_type != NVDSINFER_TENSOR_OUTPUT_META)
continue;
NvDsInferTensorMeta *tensor_meta = (NvDsInferTensorMeta *) tensor_user_meta->user_meta_data;
NvDsInferLayerInfo *layer_info = &tensor_meta->output_layers_info[0];
float *output_data = (float *) layer_info->buffer;
std::cout << tensor_meta->unique_id << std::endl;
}
}
}
}
I got below debug prints
attach_tensor_output_metaFrame Num: 116 0xfffe50064100
[POST] meta_type: 29 (I confirmed with header file that it is NVDS_ROI_META)
4 (unique_id)
attach_tensor_output_metaFrame Num: 117 0xfffe5005c500
[POST] meta_type: 29 (I confirmed with header file that it is NVDS_ROI_META)
4 (unique_id)
attach_tensor_output_meta Frame Num: 118 0xfffe50058b60
[POST] meta_type: 29 (I confirmed with header file that it is NVDS_ROI_META)
4 (unique_id)
- Then I added below code in analytics_done_buf_prob(). Here also I found raw tensor data.
static GstPadProbeReturn
analytics_done_buf_prob (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{
NvDsMetaList *l_frame = NULL;
NvDsMetaList *l_user_meta = NULL;
NvDsInstanceBin *bin = (NvDsInstanceBin *) u_data;
guint index = bin->index;
AppCtx *appCtx = bin->appCtx;
GstBuffer *buf = (GstBuffer *) info->data;
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
if (!batch_meta) {
NVGSTDS_WARN_MSG_V ("Batch meta not found for buffer %p", buf);
return GST_PAD_PROBE_OK;
}
// Iterate through the frame metadata list
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
std::cout << __func__ << " " << frame_meta << " " << frame_meta->frame_num << std::endl;
for (l_user_meta = frame_meta->frame_user_meta_list; l_user_meta != NULL;
l_user_meta = l_user_meta->next) {
NvDsUserMeta *roi_user_meta = (NvDsUserMeta *) l_user_meta->data;
if (roi_user_meta->base_meta.meta_type != NVDS_ROI_META)
continue;
/* convert to roi metadata */
NvDsRoiMeta *roi_meta =
(NvDsRoiMeta *) roi_user_meta->user_meta_data;
for (NvDsUserMetaList * r_user = roi_meta->roi_user_meta_list;
r_user != NULL; r_user = r_user->next){
NvDsUserMeta *tensor_user_meta = (NvDsUserMeta *) r_user->data;
if (tensor_user_meta->base_meta.meta_type != NVDSINFER_TENSOR_OUTPUT_META)
continue;
NvDsInferTensorMeta *meta = (NvDsInferTensorMeta *) tensor_user_meta->user_meta_data;
std::cout << "raw tensor data received: " << meta->unique_id << std::endl;
}
}
}
I got below debug prints
analytics_done_buf_prob 0xfffe5005c500 117
raw tensor data received: 4
analytics_done_buf_prob 0xfffe50058b60 118
raw tensor data received: 4
analytics_done_buf_prob 0xfffe500585c0 119
raw tensor data received: 4
I then added debug prints in gie_processing_done_buf_prob() to print frame_meta pointer address and frame_num
static GstPadProbeReturn
gie_processing_done_buf_prob (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
// Retrieve the GstBuffer and the instance bin and app context
GstBuffer *buf = (GstBuffer *) info->data;
NvDsInstanceBin *bin = (NvDsInstanceBin *) u_data;
guint index = bin->index;
AppCtx *appCtx = bin->appCtx;
NvDsObjectMeta *obj_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvDsMetaList *l_obj = NULL;
NvDsMetaList *l_user_meta = NULL;
NvDsUserMeta *user_meta = NULL;
unsigned char *user_meta_data = NULL;
// Check if the buffer is writable, if so, process the buffer
if (gst_buffer_is_writable(buf)) {
process_buffer(buf, appCtx, index);
}
// Retrieve the NvDsBatchMeta from the GstBuffer (contains metadata for batch processing)
unsigned int count = 0;
std::vector<cv::Point2f> keypoints; // Vector to store keypoints
std::vector<cv::Mat> images; // Vector to store inferred images
std::vector<cv::Mat> M_list; // List to store transformation matrices
// Vector to store all detected objects and their info
std::vector<ObjectInfo> detected_objects;
//nvds_get_current_metadata_info(batch_meta);
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);
// Iterate through the frame metadata list
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
NvDsDisplayMeta *display_meta = NULL;
if (!frame_meta) continue;
std::cout << "frame_meta: " << frame_meta << std::endl;
guint frame_width = frame_meta->source_frame_width;
guint frame_height = frame_meta->source_frame_height;
frame_meta: 0xffff040568e0
No frame user meta for 117
frame_meta: 0xffff04056c10
No frame user meta for 118
frame_meta: 0xffff04018a10
No frame user meta for 119
From this I concluded that the data is flowing from attach_tensor_output_meta → analytics_done_buf_prob but not to gie_processing_done_buf_prob. I also noticed that the frame_meta pointer address for the same frame_num is pointer matching for attach_tensor_output_meta and analytics_done_buf_prob while it is different in gie_processing_done_buf_prob. This the reason I am not able to get metadata.
Request you to please resolve this on priority. I believe that you are aware that there was another issue linked to input-tensor-meta=1 and output-tensor-meta=1. I have put the link in my earlier post. I am highlighting it so that you can look at any side effect caused by it.
Regards