NVIDIA DeepStream SDK API Reference

8.0 Release
libs/nvds_analytics/nvds_analytics.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2025 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 #ifndef _NVDS_ANALYTICS_H_
13 #define _NVDS_ANALYTICS_H_
14 #include <iostream>
15 #include <vector>
16 #include <memory>
17 #include <unordered_map>
18 
19 #ifdef __cplusplus
20 extern "C"
21 {
22 #endif
23 
24 
25 enum class eMode {
26  balanced,
27  strict,
28  loose
29 };
30 
31 enum class eModeDir {
32  use_dir,
33  pos_to_neg,
35 };
36 
37 constexpr int LAST_N_FRAMES=10;
38 constexpr int TIME_OUT_MSEC=8000;
39 constexpr uint32_t MED_FILT_MSEC=1000;
40 typedef struct {
41  bool enable;
42  std::vector<std::pair<int, int>> roi_pts;
43  std::string roi_label;
44  bool inverse_roi;
45  std::vector<int> operate_on_class;
46  int stream_id;
47 }ROIInfo;
48 
49 typedef struct {
50  bool enable;
51  std::vector<std::pair<int, int>> roi_pts;
52  std::string oc_label;
53  std::vector<int> operate_on_class;
54  int stream_id;
55  int time_threshold_in_ms;
56  int object_threshold;
58 
59 
60 typedef struct {
61  bool enable;
62  bool extended;
63  std::string lc_label;
64  std::pair <double, double> lc_dir;
65  std::vector <double> lc_info;
66  std::vector<std::pair<int, int>> lcdir_pts;
67  std::vector<int> operate_on_class;
68  int stream_id;
69  enum eMode mode;
70  enum eModeDir mode_dir;
72 
73 typedef struct {
74  bool enable;
75  std::string dir_label;
76  std::pair <double, double> dir_data;
77  std::pair<int, int> x1y1;
78  std::pair<int, int> x2y2;
79  std::vector<int> operate_on_class;
80  int stream_id;
81  enum eMode mode;
83 
84 typedef struct {
85  std::vector <ROIInfo> roi_info;
86  std::vector <OverCrowdingInfo> overcrowding_info;
87  std::vector <LineCrossingInfo> linecrossing_info;
88  std::vector <DirectionInfo> direction_info;
89  int config_width;
90  int config_height;
91 
92 }StreamInfo;
93 /*
94 enum DSANALYTICS_STATUS {
95  eDSANALYTICS_STATUS_NO_EVENT = 0,
96  eDSANALYTICS_STATUS_INSIDE_ROI = 1,
97  eDSANALYTICS_STATUS_ROI_OVERCROWDING = 2,
98  eDSANALYTICS_STATUS_DIRECTION_FOLLOWED = 3,
99  eDSANALYTICS_STATUS_LINE_CROSSED = 4
100 };*/
101 
102 typedef struct {
103  uint32_t left;
104  uint32_t top;
105  uint32_t width;
106  uint32_t height;
107  uint64_t object_id;
108  int32_t class_id;
109 // std::unordered_map <std::string, enum DSANALYTICS_STATUS >obj_status;
110  std::string str_obj_status;
111  std::vector <std::string> roiStatus;
112  std::vector <std::string> ocStatus;
113  std::vector <std::string> lcStatus;
114  std::string dirStatus;
115 
116 }ObjInf;
117 
118 typedef struct {
119  bool overCrowding;
120  uint32_t overCrowdingCount;
121 
123 
124 typedef struct {
125  std::vector <ObjInf> objList;
126  std::unordered_map<std::string, OverCrowdStatus> ocStatus;
127  std::unordered_map<int, uint32_t> objCnt;
128  std::unordered_map<std::string, uint32_t> objInROIcnt;
129  std::unordered_map<std::string, uint64_t> objLCCumCnt;
130  std::unordered_map<std::string, uint64_t> objLCCurrCnt;
131  uint64_t frmPts {0};
132  int32_t srcId;
133 
135 
136 
137 class NvDsAnalyticCtx
138 {
139 public:
140  static std::unique_ptr<NvDsAnalyticCtx> create(StreamInfo &stream_info,
141  int32_t src_id, int32_t width=1920,
142  int32_t height=1080, uint32_t filtTime=MED_FILT_MSEC, uint32_t timeOut=300, uint32_t hist=50);
143  void destroy();
144  virtual void processSource(NvDsAnalyticProcessParams &process_params) = 0;
146 
147  };
148  virtual ~NvDsAnalyticCtx() {};
149 private:
150 };
151 
152 using NvDsAnalyticCtxUptr = std::unique_ptr<NvDsAnalyticCtx>;
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif
NvDsAnalyticProcessParams
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:124
eMode::balanced
@ balanced
eMode
eMode
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:25
eModeDir::pos_to_neg
@ pos_to_neg
eModeDir
eModeDir
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:31
NvDsAnalyticCtxUptr
std::unique_ptr< NvDsAnalyticCtx > NvDsAnalyticCtxUptr
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:152
eModeDir::use_dir
@ use_dir
NvDsAnalyticCtx
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:137
eMode::loose
@ loose
LAST_N_FRAMES
constexpr int LAST_N_FRAMES
Definition: libs/nvds_analytics/nvds_analytics.h:37
LineCrossingInfo
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:60
TIME_OUT_MSEC
constexpr int TIME_OUT_MSEC
Definition: libs/nvds_analytics/nvds_analytics.h:38
OverCrowdingInfo
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:49
eModeDir::neg_to_pos
@ neg_to_pos
NvDsAnalyticCtx::processSource
virtual void processSource(NvDsAnalyticProcessParams &process_params)=0
DirectionInfo
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:73
StreamInfo
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:84
NvDsAnalyticCtx::create
static std::unique_ptr< NvDsAnalyticCtx > create(StreamInfo &stream_info, int32_t src_id, int32_t width=1920, int32_t height=1080, uint32_t filtTime=MED_FILT_MSEC, uint32_t timeOut=300, uint32_t hist=50)
ROIInfo
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:40
NvDsAnalyticCtx::~NvDsAnalyticCtx
virtual ~NvDsAnalyticCtx()
Definition: libs/nvds_analytics/nvds_analytics.h:148
OverCrowdStatus
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:118
ObjInf
Definition: gst-plugins/gst-nvdsanalytics/nvds_analytics.h:102
eMode::strict
@ strict
MED_FILT_MSEC
constexpr uint32_t MED_FILT_MSEC
Definition: libs/nvds_analytics/nvds_analytics.h:39
NvDsAnalyticCtx::NvDsAnalyticCtx
NvDsAnalyticCtx()
Definition: libs/nvds_analytics/nvds_analytics.h:145
NvDsAnalyticCtx::destroy
void destroy()