NVIDIA DeepStream SDK API Reference

8.0 Release
sample_video_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 <iostream>
14 #include <string>
15 #include <memory>
16 #include <vector>
17 
18 #include "buffer_probe.hpp"
19 
20 using namespace std;
21 
22 #define MAX_DISPLAY_LEN 64
23 #define PGIE_CLASS_ID_VEHICLE 0
24 #define PGIE_CLASS_ID_PERSON 2
25 
26 namespace deepstream
27 {
28 
30  {
31  public:
33  virtual ~CountMarker() {}
34 
36  {
37  FrameMetadata::Iterator frame_itr;
38  for (data.initiateIterator(frame_itr); !frame_itr->done(); frame_itr->next())
39  {
40  auto vehicle_count = 0;
41  auto person_count = 0;
42  FrameMetadata &frame_meta = frame_itr->get();
44  for (frame_meta.initiateIterator(obj_itr); !obj_itr->done(); obj_itr->next())
45  {
46  ObjectMetadata &object_meta = obj_itr->get();
47  auto class_id = object_meta.classId();
48  if (class_id == PGIE_CLASS_ID_VEHICLE)
49  {
50  vehicle_count++;
51  }
52  else if (class_id == PGIE_CLASS_ID_PERSON)
53  {
54  person_count++;
55  }
56  }
57  DisplayMetadata display_meta;
58  if (data.acquire(display_meta))
59  {
60  std::stringstream ss;
61  ss << "Person=" << person_count << ",Vehicle=" << vehicle_count;
62  std::string str = ss.str();
63  int font_size = 0;
64  char font[] = "Serif";
65  probe.getProperty("font-size", font_size);
67  (char *)str.c_str(),
68  10, //< x offset
69  12, //< y offset
70  {font, (unsigned int)font_size, {1.0, 1.0, 1.0, 1.0}}, //< font and color
71  1,
72  {0.0, 0.0, 0.0, 1.0} //< background
73  };
74  display_meta.add(label);
75  (*frame_itr)->append(display_meta);
76  }
77  }
78 
79  return probeReturn::Probe_Ok;
80  }
81  };
82 
83 }
buffer_probe.hpp
deepstream::ObjectMetadata::Iterator
std::unique_ptr< AbstractIterator< ObjectMetadata > > Iterator
Definition: metadata.hpp:157
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::ObjectMetadata::classId
unsigned int classId() const
Number to identify the class of the object.
deepstream::CountMarker::~CountMarker
virtual ~CountMarker()
Definition: sample_video_probe.hpp:33
PGIE_CLASS_ID_VEHICLE
#define PGIE_CLASS_ID_VEHICLE
Definition: sample_video_probe.hpp:23
deepstream::FrameMetadata::initiateIterator
void initiateIterator(ObjectMetadata::Iterator &) const
Get the iterator for object metadata within it.
deepstream::ObjectMetadata
Object metadata.
Definition: metadata.hpp:155
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.
PGIE_CLASS_ID_PERSON
#define PGIE_CLASS_ID_PERSON
Definition: sample_video_probe.hpp:24
deepstream::BatchMetadata
Holds information about a formed batch containingframes from different sources.
Definition: metadata.hpp:652
deepstream::FrameMetadata::Iterator
std::unique_ptr< AbstractIterator< FrameMetadata > > Iterator
Definition: metadata.hpp:419
deepstream::DisplayMetadata
Metadata for overlay display on a frame.
Definition: metadata.hpp:372
deepstream::CountMarker::handleData
virtual probeReturn handleData(BufferProbe &probe, BatchMetadata &data)
Definition: sample_video_probe.hpp:35
_NvOSD_TextParams
Holds parameters of text to be overlayed.
Definition: nvll_osd_struct.h:115
deepstream::CountMarker
Definition: sample_video_probe.hpp:29
deepstream::CountMarker::CountMarker
CountMarker()
Definition: sample_video_probe.hpp:32
deepstream::BatchMetadata::acquire
bool acquire(DisplayMetadata &)
Initialize an empty display metadata.
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:417
deepstream::DisplayMetadata::add
bool add(NvOSD_TextParams &)
Add a text label.