NVIDIA DeepStream SDK API Reference

9.1 Release
sources/gst-plugins/gst-dsexample-cuda/gstdsexample_cuda.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025-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 __GST_DSEXAMPLE_CUDA_H__
19 #define __GST_DSEXAMPLE_CUDA_H__
20 
21 #include <gst/base/gstbasetransform.h>
22 #include <gst/video/video.h>
23 
24 /* Open CV headers */
25 #pragma GCC diagnostic push
26 #if __GNUC__ >= 8
27 #pragma GCC diagnostic ignored "-Wclass-memaccess"
28 #endif
29 #ifdef WITH_OPENCV
30 #include "opencv2/imgproc/imgproc.hpp"
31 #include "opencv2/highgui/highgui.hpp"
32 #include "opencv2/core/cuda.hpp"
33 #include "opencv2/cudaimgproc.hpp"
34 #include "opencv2/cudafilters.hpp"
35 #endif
36 #pragma GCC diagnostic pop
37 
38 #include <cuda.h>
39 #include <cuda_runtime.h>
40 #include "nvbufsurface.h"
41 #include "nvbufsurftransform.h"
42 #include "gst-nvquery.h"
43 #include "gstnvdsmeta.h"
44 #include "dsexample_lib/dsexample_lib.h"
45 
46 /* Package and library details required for plugin_init */
47 #define PACKAGE "dsexample"
48 #define VERSION "1.0"
49 #define LICENSE "Proprietary"
50 #define DESCRIPTION "NVIDIA example plugin for integration with DeepStream on DGPU"
51 #define BINARY_PACKAGE "NVIDIA DeepStream 3rdparty IP integration example plugin"
52 #define URL "http://nvidia.com/"
53 
54 
55 G_BEGIN_DECLS
56 /* Standard boilerplate stuff */
57 typedef struct _GstDsExample GstDsExample;
59 
60 /* Standard boilerplate stuff */
61 #define GST_TYPE_DSEXAMPLE (gst_dsexample_get_type())
62 #define GST_DSEXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DSEXAMPLE,GstDsExample))
63 #define GST_DSEXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DSEXAMPLE,GstDsExampleClass))
64 #define GST_DSEXAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DSEXAMPLE, GstDsExampleClass))
65 #define GST_IS_DSEXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DSEXAMPLE))
66 #define GST_IS_DSEXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DSEXAMPLE))
67 #define GST_DSEXAMPLE_CAST(obj) ((GstDsExample *)(obj))
68 
70 #define NVDSEXAMPLE_MAX_BATCH_SIZE 1024
71 
72 struct _GstDsExample
73 {
74  GstBaseTransform base_trans;
75 
76  // Context of the custom algorithm library
78 
79  // Unique ID of the element. The labels generated by the element will be
80  // updated at index `unique_id` of attr_info array in NvDsObjectParams.
81  guint unique_id;
82 
83  // Frame number of the current input buffer
84  guint64 frame_num;
85 
86  // CUDA Stream used for allocating the CUDA task
88 
89  // Device buffer to store RGB data for use by algorithm
91 
92  // the intermediate scratch buffer for conversions RGBA
94 
95 #ifdef WITH_OPENCV
96  // OpenCV GPU mat containing RGB data
97  cv::cuda::GpuMat *cvgpumat;
98 #endif
99 
100  // Input video info (resolution, color format, framerate, etc)
101  GstVideoInfo video_info;
102 
103  // Resolution at which frames/objects should be processed
104  gint processing_width;
105  gint processing_height;
106 
107  // Flag which defince igpu/dgpu
108  guint is_integrated;
109 
110  // Maximum batch size
111  guint max_batch_size;
112 
113  // GPU ID on which we expect to execute the task
114  guint gpu_id;
115 
116  // Boolean indicating if entire frame or cropped objects should be processed
117  gboolean process_full_frame;
118 
119  // Boolean indicating if to blur the detected objects
120  gboolean blur_objects;
121 
124 };
125 
126 // Boiler plate stuff
127 struct _GstDsExampleClass
128 {
129  GstBaseTransformClass parent_class;
130 };
131 
132 GType gst_dsexample_get_type (void);
133 
134 G_END_DECLS
135 #endif /* __GST_DSEXAMPLE_H__ */
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: sources/includes/nvbufsurftransform.h:35
GstDsExample
typedefG_BEGIN_DECLS struct _GstDsExample GstDsExample
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:54
_GstDsExample::process_full_frame
gboolean process_full_frame
Boolean indicating if entire frame or cropped objects should be processed.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:114
NvBufSurface
Holds information about batched buffers.
Definition: sources/includes/nvbufsurface.h:597
_GstDsExample::processing_width
gint processing_width
Resolution at which frames/objects should be processed.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:101
gst_dsexample_get_type
GType gst_dsexample_get_type(void)
_GstDsExample::video_info
GstVideoInfo video_info
Input video info (resolution, color format, framerate, etc)
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:98
_GstDsExample::gpu_id
guint gpu_id
GPU ID on which we expect to execute the task.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:111
_GstDsExample::cuda_stream
cudaStream_t cuda_stream
CUDA Stream used for allocating the CUDA task.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:84
_GstDsExample::blur_objects
gboolean blur_objects
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:117
_GstDsExampleClass
Boiler plate stuff.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:124
_GstDsExample::max_batch_size
guint max_batch_size
Maximum batch size.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:108
_GstDsExample
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:69
_NvBufSurfTransformConfigParams
Holds configuration parameters for a transform/composite session.
Definition: sources/includes/nvbufsurftransform.h:175
_GstDsExampleClass::parent_class
GstBaseTransformClass parent_class
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:126
_GstDsExample::frame_num
guint64 frame_num
Frame number of the current input buffer.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:81
DsExampleCtx
struct DsExampleCtx DsExampleCtx
Definition: sources/gst-plugins/gst-dsexample/dsexample_lib/dsexample_lib.h:26
_GstDsExample::transform_config_params
NvBufSurfTransformConfigParams transform_config_params
Config params required by NvBufSurfTransform API.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:120
_GstDsExample::unique_id
guint unique_id
Unique ID of the element.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:78
_GstDsExample::inter_buf
NvBufSurface * inter_buf
the intermediate scratch buffer for conversions RGBA
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:90
_GstDsExample::base_trans
GstBaseTransform base_trans
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:71
_GstDsExample::dsexamplelib_ctx
DsExampleCtx * dsexamplelib_ctx
Context of the custom algorithm library.
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:74
_GstDsExample::is_integrated
guint is_integrated
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:105
_GstDsExample::device_rgb_buf
void * device_rgb_buf
Definition: sources/gst-plugins/gst-dsexample-cuda/gstdsexample_cuda.h:90
_GstDsExample::processing_height
gint processing_height
Definition: sources/gst-plugins/gst-dsexample/gstdsexample.h:102