NVIDIA DeepStream SDK API Reference

6.4 Release
gstdsexample_optimized.h
Go to the documentation of this file.
1 
23 #ifndef __GST_DSEXAMPLE_H__
24 #define __GST_DSEXAMPLE_H__
25 
26 #include <gst/base/gstbasetransform.h>
27 #include <gst/video/video.h>
28 
29 /* Open CV headers */
30 #ifdef WITH_OPENCV
31 #include "opencv2/imgproc/imgproc.hpp"
32 #include "opencv2/highgui/highgui.hpp"
33 #endif
34 
35 #include <cuda.h>
36 #include <cuda_runtime.h>
37 #include "nvbufsurface.h"
38 #include "nvbufsurftransform.h"
39 #include "gst-nvquery.h"
40 #include "gstnvdsmeta.h"
42 #include "nvtx3/nvToolsExt.h"
43 
44 #include <condition_variable>
45 #include <mutex>
46 #include <thread>
47 #include <vector>
48 
49 /* Package and library details required for plugin_init */
50 #define PACKAGE "dsexample"
51 #define VERSION "1.0"
52 #define LICENSE "Proprietary"
53 #define DESCRIPTION "NVIDIA example plugin for integration with DeepStream on DGPU/Jetson"
54 #define BINARY_PACKAGE "NVIDIA DeepStream 3rdparty IP integration example plugin"
55 #define URL "http://nvidia.com/"
56 
57 
58 G_BEGIN_DECLS
59 /* Standard boilerplate stuff */
60 typedef struct _GstDsExample GstDsExample;
62 
63 /* Standard boilerplate stuff */
64 #define GST_TYPE_DSEXAMPLE (gst_dsexample_get_type())
65 #define GST_DSEXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DSEXAMPLE,GstDsExample))
66 #define GST_DSEXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DSEXAMPLE,GstDsExampleClass))
67 #define GST_DSEXAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DSEXAMPLE, GstDsExampleClass))
68 #define GST_IS_DSEXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DSEXAMPLE))
69 #define GST_IS_DSEXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DSEXAMPLE))
70 #define GST_DSEXAMPLE_CAST(obj) ((GstDsExample *)(obj))
71 
73 #define NVDSEXAMPLE_MAX_BATCH_SIZE G_MAXUINT
74 
75 struct _GstDsExample
76 {
77  GstBaseTransform base_trans;
78 
81 
85  GMutex process_lock;
86 
88  GQueue *process_queue;
89 
91  GCond process_cond;
92 
94  GQueue *buf_queue;
95 
97  GCond buf_cond;
98 
100  GThread *process_thread;
101 
103  gboolean stop;
104 
107  guint unique_id;
108 
110  guint64 frame_num;
111 
114 
117 
120 
122  GstVideoInfo video_info;
123 
125  gint processing_width;
126  gint processing_height;
127 
130 
132  guint gpu_id;
133 
135  gboolean process_full_frame;
136 
139 
141  GstFlowReturn last_flow_ret;
142 
145 
148 
150  nvtxDomainHandle_t nvtx_domain;
151 };
152 
153 typedef struct
154 {
158  gdouble scale_ratio_x = 0.0;
162  gdouble scale_ratio_y = 0.0;
164  NvDsObjectMeta *obj_meta = nullptr;
165  NvDsFrameMeta *frame_meta = nullptr;
168  guint batch_index = 0;
170  gulong frame_num = 0;
172  NvBufSurfaceParams *input_surf_params = nullptr;
174 
178 typedef struct
179 {
181  std::vector < GstDsExampleFrame > frames;
183  GstBuffer *inbuf = nullptr;
185  gulong inbuf_batch_num = 0;
190  gboolean push_buffer = FALSE;
194  gboolean event_marker = FALSE;
195 
196 #ifdef WITH_OPENCV
197 
198  cv::Mat * cvmat;
199 #else
201 #endif
202 
203  nvtxRangeId_t nvtx_complete_buf_range = 0;
205 
207 struct _GstDsExampleClass
208 {
209  GstBaseTransformClass parent_class;
210 };
211 
212 GType gst_dsexample_get_type (void);
213 
214 G_END_DECLS
215 #endif /* __GST_DSEXAMPLE_H__ */
_GstDsExample::transform_params
NvBufSurfTransformParams transform_params
Parameters to use for transforming buffers.
Definition: gstdsexample_optimized.h:147
GstDsExampleBatch
Holds information about the batch of frames to be inferred.
Definition: gstdsexample_optimized.h:178
DsExampleCtx
struct DsExampleCtx DsExampleCtx
Definition: dsexample_lib.h:31
_NvBufSurfaceTransformParams
Holds transform parameters for a transform call.
Definition: nvbufsurftransform.h:185
_GstDsExample::process_lock
GMutex process_lock
Processing Queue and related synchronization structures.
Definition: gstdsexample_optimized.h:85
_GstDsExample::process_full_frame
gboolean process_full_frame
Boolean indicating if entire frame or cropped objects should be processed.
Definition: gstdsexample.h:116
NvBufSurface
Holds information about batched buffers.
Definition: nvbufsurface.h:503
_GstDsExample::processing_width
gint processing_width
Resolution at which frames/objects should be processed.
Definition: gstdsexample.h:103
gst-nvquery.h
_GstDsExample::video_info
GstVideoInfo video_info
Input video info (resolution, color format, framerate, etc)
Definition: gstdsexample.h:100
GstDsExample
typedefG_BEGIN_DECLS struct _GstDsExample GstDsExample
Definition: gstdsexample.h:59
_GstDsExample::current_batch_num
gulong current_batch_num
Current batch number of the input batch.
Definition: gstdsexample_optimized.h:138
_GstDsExample::gpu_id
guint gpu_id
GPU ID on which we expect to execute the task.
Definition: gstdsexample.h:113
_GstDsExample::buf_cond
GCond buf_cond
Gcondition for buf queue.
Definition: gstdsexample_optimized.h:97
_GstDsExample::buf_queue
GQueue * buf_queue
Queue to receive processed data from output thread.
Definition: gstdsexample_optimized.h:94
_GstDsExample::cuda_stream
cudaStream_t cuda_stream
CUDA Stream used for allocating the CUDA task.
Definition: gstdsexample.h:86
_GstDsExampleClass
Boiler plate stuff.
Definition: gstdsexample.h:123
_GstDsExample::max_batch_size
guint max_batch_size
Maximum batch size.
Definition: gstdsexample_optimized.h:129
_GstDsExample::process_cond
GCond process_cond
Gcondition for process queue.
Definition: gstdsexample_optimized.h:91
_GstDsExample
Definition: gstdsexample.h:71
_NvBufSurfTransformConfigParams
Holds configuration parameters for a transform/composite session.
Definition: nvbufsurftransform.h:167
NvBufSurfaceParams
Hold the information of single buffer in the batch.
Definition: nvbufsurface.h:470
_GstDsExample::nvtx_domain
nvtxDomainHandle_t nvtx_domain
NVTX Domain.
Definition: gstdsexample_optimized.h:150
_GstDsExampleClass::parent_class
GstBaseTransformClass parent_class
Definition: gstdsexample.h:125
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: nvbufsurftransform.h:29
_GstDsExample::frame_num
guint64 frame_num
Frame number of the current input buffer.
Definition: gstdsexample.h:83
gstnvdsmeta.h
_GstDsExample::transform_config_params
NvBufSurfTransformConfigParams transform_config_params
Config params required by NvBufSurfTransform API.
Definition: gstdsexample_optimized.h:144
_GstDsExample::process_thread
GThread * process_thread
Output thread.
Definition: gstdsexample_optimized.h:100
_GstDsExample::unique_id
guint unique_id
Unique ID of the element.
Definition: gstdsexample.h:80
dsexample_lib.h
_GstDsExample::stop
gboolean stop
Boolean to signal output thread to stop.
Definition: gstdsexample_optimized.h:103
gst_dsexample_get_type
GType gst_dsexample_get_type(void)
_GstDsExample::process_queue
GQueue * process_queue
Queue to send data to output thread for processing.
Definition: gstdsexample_optimized.h:88
GstDsExampleBatch::frames
std::vector< GstDsExampleFrame > frames
Vector of frames in the batch.
Definition: gstdsexample_optimized.h:181
GstDsExampleFrame
Definition: gstdsexample_optimized.h:153
_GstDsExample::inter_buf
NvBufSurface * inter_buf
the intermediate scratch buffer for conversions RGBA
Definition: gstdsexample.h:92
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
_GstDsExample::base_trans
GstBaseTransform base_trans
Definition: gstdsexample.h:73
_GstDsExample::dsexamplelib_ctx
DsExampleCtx * dsexamplelib_ctx
Context of the custom algorithm library.
Definition: gstdsexample.h:76
_NvDsFrameMeta
Holds metadata for a frame in a batch.
Definition: nvdsmeta.h:284
_GstDsExample::last_flow_ret
GstFlowReturn last_flow_ret
GstFlowReturn returned by the latest buffer pad push.
Definition: gstdsexample_optimized.h:141
nvbufsurftransform.h
_GstDsExample::batch_insurf
NvBufSurface batch_insurf
Temporary NvBufSurface for batched transformations.
Definition: gstdsexample_optimized.h:116
nvbufsurface.h
_GstDsExample::processing_height
gint processing_height
Definition: gstdsexample.h:104
GstDsExampleBatch::inter_buf
NvBufSurface * inter_buf
Definition: gstdsexample_optimized.h:200
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: nvdsmeta.h:342