When using deepstream_lpr_app for license plate recognition, how to take a screenshot of the vehicle with the detection frame?

@kesong Hello, I read the description you posted about nvdsosd, and I also put the probe after calling nvdsosd. Then I refer to How to save the complete frame with bounding boxes in deepstream-image-meta-test? u=user85575 and Deepstream save image with bounding box - #8 by Mike these two posts. And encapsulated a function with osd_sink_pad_buffer_probe in the deepstream_image_meta_test example, but no screenshots appeared after running. Below is the program I wrote, please help me.

int write_frame2(GstBuffer *buf, char *picture)
{
	NvDsMetaList * l_frame = NULL;
	NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
	NvDsObjectMeta *obj_meta = NULL;
	NvDsMetaList * l_obj = NULL;
	
	for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next) {
		NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
		if (!frame_meta) {
			continue;
		}
		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) {
				continue;
			}
			
			/* For Demonstration Purposes we are writing metadata to jpeg images of
			 * only vehicles for the first 100 frames only.
			 * The files generated have a 'OSD' prefix. */
			  NvDsUserMetaList *usrMetaList = obj_meta->obj_user_meta_list;
			  FILE *file;
			  printf("1111111111111111111\n");
			  while (usrMetaList != NULL) {
			  	printf("000000000000000\n");
				NvDsUserMeta *usrMetaData = (NvDsUserMeta *) usrMetaList->data;
				if (usrMetaData->base_meta.meta_type == NVDS_CROP_IMAGE_META) {
				  NvDsObjEncOutParams *enc_jpeg_image =
					  (NvDsObjEncOutParams *) usrMetaData->user_meta_data;
				  /* Write to File */
				  file = fopen (picture, "wb");
				  fwrite (enc_jpeg_image->outBuffer, sizeof (uint8_t),
					  enc_jpeg_image->outLen, file);
				  fclose (file);
				  usrMetaList = NULL;
				} else {
				  usrMetaList = usrMetaList->next;
				}
			  }
			
		}
	}
	
	return 0;

}

Call function command:
write_frame2(buf, "tmp/test.jpg");
Through debugging, it is found that the variable usrMetaList is always NULL, so the picture cannot be saved.Please help me.