Need sample code to create new struct NvDsFrameMeta

I am trying to create new NvDsBatchMeta with new NvDsFrameMeta list with the following code:

//create batch_meta with batch_size=5
NvDsBatchMeta * batch_meta = nvds_create_batch_meta(5);

//I can get empty frame_meta
NvDsFrameMeta * empty_frame_meta = nvds_acquire_frame_meta_from_pool (batch_meta);

The question is how can I create new NvDsFrameMeta struct so that I can add it to batch_meta with nvds_add_frame_meta_to_batch(batch_meta, new_frame_meta);

If I try to add the “empty_frame_meta” 5 times, it ends that all NvDsFrameMetaList in batch_meta points to the same address of empty_frame_meta. Since all addresses of NvDsFrameMetaList are the same, all NvDsFrameMetas in NvDsFrameMetaList contains the same content, which you can see it will be so wrong.

Can you provide a simple sample code to add 5 new NvDsFrameMeta struct to NvDsBatchMeta? Thanks.

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• 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)

Never mind. I have figured out right way to create new NvDsFrameMetaData with the following:
guint batchSize = 5;
NvDsBatchMeta * out_batch_meta = nvds_create_batch_meta(batchSize);
NvDsFrameMeta * templ_frame_meta = nvds_acquire_frame_meta_from_pool (out_batch_meta);
NvDsFrameMeta * out_frame_meta = new NvDsFrameMeta();
*out_frame_meta = *templ_frame_meta;
//then fill in out_frame_meta here
nvds_add_frame_meta_to_batch(out_batch_meta, out_frame_meta);

This has nothing to do with Hardware, SDK version, etc.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.