NVIDIA DeepStream SDK API Reference

7.1 Release
kitti_dump_probe.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 #include <string>
14 #include <sys/stat.h>
15 #include <fstream>
16 
17 #include "buffer_probe.hpp"
18 
19 #define UNTRACKED_OBJECT_ID 0xFFFFFFFFFFFFFFFF
20 
21 namespace deepstream {
22 
24 
25  public:
28  char bbox_file[1024] = {0};
29  std::string output_dir = "/tmp/kitti/";
30  probe.getProperty("kitti-dir", output_dir);
31  FILE *bbox_params_dump_file = NULL;
32  // if (!buffer_data.get<NvDsBatchMetaHandle>(BUF_DATA_KEY_VIDEO_BATCH_META)) {
33  // return true;
34  // }
35 
36  FrameMetadata::Iterator frame_itr;
37 
38  for (data.initiateIterator(frame_itr); !frame_itr->done(); frame_itr->next()) {
39 
40  // guint stream_id = frame_meta->pad_index;
41  uint stream_id = (*frame_itr)->padIndex();
42  snprintf(bbox_file, sizeof(bbox_file) - 1, "%s/%03u_%06lu.txt",
43  output_dir.c_str(), stream_id,
44  (ulong)(*frame_itr)->frameNum());
45  bbox_params_dump_file = fopen(bbox_file, "w");
46  if (!bbox_params_dump_file) continue;
47 
48  FrameMetadata& frame_meta = frame_itr->get();
50 
51  for (frame_meta.initiateIterator(obj_itr); !obj_itr->done(); obj_itr->next()) {
52  ObjectMetadata& object_meta = obj_itr->get();
53  float confidence = object_meta.confidence();
54  float left = object_meta.rectParams().left;
55  float top = object_meta.rectParams().top;
56  float right = left + object_meta.rectParams().width;
57  float bottom = top + object_meta.rectParams().height;
58 
59  if (object_meta.objectId() == UNTRACKED_OBJECT_ID) {
60  fprintf(bbox_params_dump_file,
61  "%s 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
62  object_meta.label().c_str(), left, top, right, bottom, confidence);
63  } else {
64  fprintf(bbox_params_dump_file,
65  "%s %lu 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
66  object_meta.label().c_str(), object_meta.objectId(), left, top, right, bottom,
67  confidence);
68  }
69  }
70  fclose(bbox_params_dump_file);
71  }
72  return probeReturn::Probe_Ok;
73  }
74  };
75 
76 }
77 
buffer_probe.hpp
deepstream::probeReturn::Probe_Ok
@ Probe_Ok
Nothing abnormal, the buffer will be treated as usual.
deepstream::ObjectMetadata::Iterator
std::unique_ptr< AbstractIterator< ObjectMetadata > > Iterator
Definition: metadata.hpp:153
_NvOSD_RectParams::width
float width
Holds the box's width in pixels.
Definition: nvll_osd_struct.h:147
UNTRACKED_OBJECT_ID
#define UNTRACKED_OBJECT_ID
Definition: kitti_dump_probe.hpp:19
deepstream::ObjectMetadata::objectId
unsigned long int objectId() const
Number to identify the object which is tracked in the scene.
deepstream::BufferProbe
Represent a custom object for the purpose of probing output buffers.
Definition: buffer_probe.hpp:58
deepstream::BufferProbe::IBatchMetadataOperator
Read/write interface for handling batch metadata.
Definition: buffer_probe.hpp:111
deepstream::FrameMetadata::initiateIterator
void initiateIterator(ObjectMetadata::Iterator &) const
Get the iterator for object metadata within it.
deepstream::NvDsKittiDump
Definition: kitti_dump_probe.hpp:23
deepstream::ObjectMetadata
Object metadata.
Definition: metadata.hpp:151
deepstream::probeReturn
probeReturn
Return values from user implemented probe interfaces.
Definition: buffer_probe.hpp:42
deepstream
Definition: buffer.hpp:33
deepstream::BatchMetadata::initiateIterator
void initiateIterator(FrameMetadata::Iterator &) const
Get the iterator for frame metadata within it.
deepstream::BatchMetadata
Holds information about a formed batch containingframes from different sources.
Definition: metadata.hpp:407
_NvOSD_RectParams::left
float left
Holds the box's left coordinate in pixels.
Definition: nvll_osd_struct.h:141
deepstream::NvDsKittiDump::NvDsKittiDump
NvDsKittiDump()
Definition: kitti_dump_probe.hpp:26
deepstream::FrameMetadata::Iterator
std::unique_ptr< AbstractIterator< FrameMetadata > > Iterator
Definition: metadata.hpp:338
deepstream::ObjectMetadata::label
std::string label() const
A string to describe the object class.
deepstream::NvDsKittiDump::handleData
virtual probeReturn handleData(BufferProbe &probe, BatchMetadata &data)
Definition: kitti_dump_probe.hpp:27
_NvOSD_RectParams::height
float height
Holds the box's height in pixels.
Definition: nvll_osd_struct.h:149
_NvOSD_RectParams::top
float top
Holds the box's top coordinate in pixels.
Definition: nvll_osd_struct.h:144
deepstream::ObjectMetadata::confidence
float confidence() const
Confidence level.
deepstream::ObjectMetadata::rectParams
NvOSD_RectParams & rectParams() const
Bounding box of the object.
deepstream::Object::getProperty
Object & getProperty(const std::string &name, T &value, Args &... args)
Template for getting multiple properties.
Definition: object.hpp:171
deepstream::FrameMetadata
Holds information for a single frame.
Definition: metadata.hpp:336