NVIDIA DeepStream SDK API Reference
9.2 Release
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#include <iostream>
19
#include <string>
20
#include <memory>
21
#include <vector>
22
23
#include "buffer_probe.hpp"
24
25
using namespace
std
;
26
27
#define MAX_DISPLAY_LEN 64
28
#define PGIE_CLASS_ID_VEHICLE 0
29
#define PGIE_CLASS_ID_PERSON 2
30
31
namespace
deepstream
32
{
33
34
class
CountMarker :
public
BufferProbe::IBatchMetadataOperator
35
{
36
public
:
37
CountMarker
() {}
38
virtual
~CountMarker
() {}
39
40
virtual
probeReturn
handleData
(
BufferProbe
&probe,
BatchMetadata
&
data
)
41
{
42
FrameMetadata::Iterator
frame_itr;
43
for
(
data
.initiateIterator(frame_itr); !frame_itr->done(); frame_itr->next())
44
{
45
auto
vehicle_count = 0;
46
auto
person_count = 0;
47
FrameMetadata
&frame_meta = frame_itr->get();
48
ObjectMetadata::Iterator
obj_itr;
49
for
(frame_meta.
initiateIterator
(obj_itr); !obj_itr->done(); obj_itr->next())
50
{
51
ObjectMetadata
&object_meta = obj_itr->get();
52
auto
class_id = object_meta.
classId
();
53
if
(class_id ==
PGIE_CLASS_ID_VEHICLE
)
54
{
55
vehicle_count++;
56
}
57
else
if
(class_id ==
PGIE_CLASS_ID_PERSON
)
58
{
59
person_count++;
60
}
61
}
62
DisplayMetadata
display_meta;
63
if
(
data
.acquire(display_meta))
64
{
65
std::stringstream ss;
66
ss <<
"Person="
<< person_count <<
",Vehicle="
<< vehicle_count;
67
std::string str = ss.str();
68
int
font_size = 0;
69
char
font[] =
"Serif"
;
70
probe.
getProperty
(
"font-size"
, font_size);
71
NvOSD_TextParams
label =
NvOSD_TextParams
{
72
(
char
*)str.c_str(),
73
10,
//< x offset
74
12,
//< y offset
75
{font, (
unsigned
int)font_size, {1.0, 1.0, 1.0, 1.0}},
//< font and color
76
1,
77
{0.0, 0.0, 0.0, 1.0}
//< background
78
};
79
display_meta.
add
(label);
80
(*frame_itr)->append(display_meta);
81
}
82
}
83
84
return
probeReturn::Probe_Ok;
85
}
86
};
87
88
}
deepstream::ObjectMetadata::Iterator
std::unique_ptr< AbstractIterator< ObjectMetadata > > Iterator
Definition:
service-maker/includes/metadata.hpp:208
deepstream::BufferProbe
Represent a custom object for the purpose of probing output buffers.
Definition:
service-maker/includes/buffer_probe.hpp:63
deepstream::ObjectMetadata::classId
unsigned int classId() const
Number to identify the class of the object.
deepstream::CountMarker::~CountMarker
virtual ~CountMarker()
Definition:
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp:38
PGIE_CLASS_ID_PERSON
#define PGIE_CLASS_ID_PERSON
Definition:
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp:29
deepstream::FrameMetadata::initiateIterator
void initiateIterator(ObjectMetadata::Iterator &) const
Get the iterator for object metadata within it.
deepstream::ObjectMetadata
Object metadata.
Definition:
service-maker/includes/metadata.hpp:206
deepstream::probeReturn
probeReturn
Return values from user implemented probe interfaces.
Definition:
service-maker/includes/buffer_probe.hpp:47
deepstream
Definition:
service-maker/includes/buffer.hpp:38
deepstream::BatchMetadata
Holds information about a formed batch containingframes from different sources.
Definition:
service-maker/includes/metadata.hpp:841
deepstream::FrameMetadata::Iterator
std::unique_ptr< AbstractIterator< FrameMetadata > > Iterator
Definition:
service-maker/includes/metadata.hpp:480
deepstream::DisplayMetadata
Metadata for overlay display on a frame.
Definition:
service-maker/includes/metadata.hpp:433
deepstream::CountMarker::handleData
virtual probeReturn handleData(BufferProbe &probe, BatchMetadata &data)
Definition:
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp:40
_NvOSD_TextParams
Holds parameters of text to be overlayed.
Definition:
includes/nvll_osd_struct.h:120
std
Extensions to the C++ standard library.
Definition:
includes/opentelemetry/nostd/string_view.h:212
PGIE_CLASS_ID_VEHICLE
#define PGIE_CLASS_ID_VEHICLE
Definition:
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp:28
data
JSAMPIMAGE data
Definition:
sources/libs/nvll_batch_jpeg_encode/oss/jpeglib.h:967
deepstream::CountMarker::CountMarker
CountMarker()
Definition:
9.2/service-maker/sources/modules/sample_video_probe/sample_video_probe.hpp:37
deepstream::Object::getProperty
Object & getProperty(const std::string &name, T &value, Args &... args)
Template for getting multiple properties.
Definition:
service-maker/includes/object.hpp:177
deepstream::FrameMetadata
Holds information for a single frame.
Definition:
service-maker/includes/metadata.hpp:478
deepstream::DisplayMetadata::add
bool add(NvOSD_TextParams &)
Add a text label.
Privacy Policy
|
Your Privacy Choices
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Wed Oct 28 2026 12:02:37 | PR-09318-R32