Can we set a file name in savging img in Deepstream?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) AGXSaver
• DeepStream Version 6.3

I save images in deepstream-app inside gst-dsexample plugin using the following lines of codes.

if (dsexample->process_full_frame) {    
    //std::chrono::time_point<std::chrono::system_clock> before = std::chrono::system_clock::now();
    
    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next) {
          NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data); 
          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_NOHELMET) {
                   NvDsObjEncUsrArgs frameData = { 0 };
		   frameData.isFrame = 1;
		   frameData.saveImg = true;
		   frameData.attachUsrMeta = false;
		   frameData.scaleImg = FALSE;
		   frameData.scaledWidth = 0;
		   frameData.scaledHeight = 0;
		   frameData.quality = 80;
	       nvds_obj_enc_process (dsexample->obj_ctx_handle, &frameData, surface, NULL, frame_meta);
          }
          }
          //dsexample->frame_count++;
    }

Now images are saved in default filename. Can we set file name in saving images?

Could you try to use the fileNameImg parameter?

Yes this is what I did and it worked.

if (obj_meta->class_id == PGIE_CLASS_ID_NOHELMET) {
                   NvDsObjEncUsrArgs frameData = { 0 };
		   frameData.isFrame = 1;
		   frameData.saveImg = true;
		   frameData.attachUsrMeta = false;
		   frameData.scaleImg = FALSE;
		   
		   std::time_t rawtime;
           std::tm* timeinfo;
            char buffer [80];
            std::time(&rawtime);
            timeinfo = std::localtime(&rawtime);
            std::strftime(buffer,80,"%d%m%Y_%H%M_bishan_",timeinfo); 
            cnt++;
            std::stringstream stream;
            stream << cnt;
            std::string str;
            stream >> str;
             str = str+".jpg";                 
             strcpy(frameData.fileNameImg, buffer ); 
            strcat(frameData.fileNameImg, str.c_str());
           frameData.scaledWidth = 0;
		   frameData.scaledHeight = 0;
		   frameData.quality = 80;
	           nvds_obj_enc_process (dsexample->obj_ctx_handle, &frameData, surface, NULL, frame_meta);
              }

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