NVIDIA DeepStream SDK API Reference

8.0 Release
sample_video_receiver.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 
15 #include "data_receiver.hpp"
16 
17 #define PGIE_CLASS_ID_VEHICLE 0
18 #define PGIE_CLASS_ID_PERSON 2
19 
20 namespace deepstream {
21 
23  public:
24  virtual int consume(DataReceiver& receiver, Buffer buffer) {
25  VideoBuffer video_buffer = buffer;
26  BatchMetadata batch_meta = video_buffer.getBatchMetadata();
27  batch_meta.iterate([](const FrameMetadata& frame_data) {
28  auto vehicle_count = 0;
29  auto person_count = 0;
30  frame_data.iterate([&](const ObjectMetadata& object_data) {
31  auto class_id = object_data.classId();
32  if (class_id == PGIE_CLASS_ID_VEHICLE) {
33  vehicle_count++;
34  } else if (class_id == PGIE_CLASS_ID_PERSON ) {
35  person_count++;
36  }
37  });
38  std::cout << "Object Counter: " <<
39  " Pad Idx = " << frame_data.padIndex() <<
40  " Frame Number = " << frame_data.frameNum() <<
41  " Vehicle Count = " << vehicle_count <<
42  " Person Count = " << person_count << std::endl;
43  });
44  return 1;
45  }
46 };
47 }
deepstream::VideoBuffer::getBatchMetadata
BatchMetadata getBatchMetadata()
deepstream::DataReceiver::IDataConsumer
required interface for a data receiver
Definition: data_receiver.hpp:45
deepstream::ObjectMetadata::classId
unsigned int classId() const
Number to identify the class of the object.
PGIE_CLASS_ID_VEHICLE
#define PGIE_CLASS_ID_VEHICLE
Definition: sample_video_receiver.hpp:17
deepstream::BatchMetadata::iterate
unsigned int iterate(const std::function< void(const FrameMetadata &)> &func) const
Iterate the frame metadata within it.
receiver
static deepstream::Cloud2DeviceReceiver receiver
Definition: smart_recording_action.hpp:24
deepstream::ObjectCounter
Definition: sample_video_receiver.hpp:22
deepstream::ObjectMetadata
Object metadata.
Definition: metadata.hpp:155
deepstream
Definition: buffer.hpp:33
deepstream::FrameMetadata::padIndex
unsigned int padIndex() const
Index of the pad from which the frame is generated.
deepstream::BatchMetadata
Holds information about a formed batch containingframes from different sources.
Definition: metadata.hpp:652
PGIE_CLASS_ID_PERSON
#define PGIE_CLASS_ID_PERSON
Definition: sample_video_receiver.hpp:18
deepstream::Buffer
Base class of a buffer.
Definition: buffer.hpp:46
deepstream::ObjectCounter::consume
virtual int consume(DataReceiver &receiver, Buffer buffer)
Definition: sample_video_receiver.hpp:24
deepstream::FrameMetadata::frameNum
int frameNum() const
Frame number.
deepstream::DataReceiver
A specific signal handler for consuming data.
Definition: data_receiver.hpp:37
deepstream::FrameMetadata::iterate
unsigned int iterate(const std::function< void(const ObjectMetadata &)> &func) const
Iterate the object metadata within it.
data_receiver.hpp
deepstream::VideoBuffer
Definition: buffer.hpp:169
deepstream::FrameMetadata
Holds information for a single frame.
Definition: metadata.hpp:417