NVIDIA DeepStream SDK API Reference

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