NVIDIA DeepStream SDK API Reference

9.0 Release
9.0/sources/gst-plugins/gst-nvdsvisionencoder-c/preprocess.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 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 #ifndef __PREPROCESS_H__
14 #define __PREPROCESS_H__
15 
16 #include <cuda_runtime.h>
17 #include <glib.h>
18 #include "nvbufsurface.h"
19 #include "nvbufsurftransform.h"
20 #include "nvdsmeta.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
31  NvBufSurface *input_surface,
32  guint batch_id,
33  NvDsObjectMeta **obj_meta_array,
34  guint num_objects,
35  NvBufSurface *prealloc_output_surface,
36  guint target_width,
37  guint target_height,
38  guint gpu_id,
39  guint max_batch_size,
40  NvBufSurfaceParams *prealloc_surf_list,
41  NvBufSurfTransformRect *prealloc_src_rect,
42  NvBufSurfTransformRect *prealloc_dst_rect);
43 
50  NvBufSurface *input_surface,
51  const guint *batch_ids,
52  NvDsObjectMeta **obj_meta_array,
53  guint num_objects,
54  NvBufSurface *prealloc_output_surface,
55  guint target_width,
56  guint target_height,
57  guint gpu_id,
58  guint max_batch_size,
59  NvBufSurfaceParams *prealloc_surf_list,
60  NvBufSurfTransformRect *prealloc_src_rect,
61  NvBufSurfTransformRect *prealloc_dst_rect,
62  gboolean output_for_gpu);
63 
65  NvBufSurface *rgb_surface,
66  float *output_tensor,
67  guint num_images,
68  guint width,
69  guint height,
70  gboolean use_siglip_normalization);
71 
74  NvBufSurface *rgb_surface,
75  float *d_output_tensor,
76  guint num_images,
77  guint width,
78  guint height,
79  gboolean use_siglip_normalization);
80 
82  NvBufSurface *rgba_surface,
83  float *output_tensor,
84  guint num_images,
85  guint width,
86  guint height,
87  gboolean use_siglip_normalization);
88 
91  NvBufSurface *rgba_surface,
92  float *d_output_tensor,
93  guint num_images,
94  guint width,
95  guint height,
96  gboolean use_siglip_normalization);
97 
102  const void* rgba_surface,
103  int surface_width,
104  int surface_height,
105  int surface_pitch,
106  const float* crop_boxes,
107  int num_crops,
108  float* output,
109  int target_width,
110  int target_height,
111  cudaStream_t stream
112 );
113 
130  const void* nv12_surface,
131  int surface_width,
132  int surface_height,
133  int surface_pitch,
134  const float* crop_boxes,
135  int num_crops,
136  float* output,
137  int target_width,
138  int target_height,
139  cudaStream_t stream
140 );
141 
146 void* get_nvbufsurface_device_ptr(NvBufSurface* surf, unsigned int buf_idx);
147 
151 void unmap_nvbufsurface(NvBufSurface* surf, unsigned int buf_idx);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif // __PREPROCESS_H__
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: sources/includes/nvbufsurftransform.h:35
preprocess_with_nvbufsurftransform
int preprocess_with_nvbufsurftransform(NvBufSurface *input_surface, guint batch_id, NvDsObjectMeta **obj_meta_array, guint num_objects, NvBufSurface *prealloc_output_surface, guint target_width, guint target_height, guint gpu_id, guint max_batch_size, NvBufSurfaceParams *prealloc_surf_list, NvBufSurfTransformRect *prealloc_src_rect, NvBufSurfTransformRect *prealloc_dst_rect)
NEW SGIE-style preprocessing using NvBufSurfTransform Uses pre-allocated buffers and output surface (...
unmap_nvbufsurface
void unmap_nvbufsurface(NvBufSurface *surf, unsigned int buf_idx)
Unmap NvBufSurface after use.
get_nvbufsurface_device_ptr
void * get_nvbufsurface_device_ptr(NvBufSurface *surf, unsigned int buf_idx)
Map and get device pointer from NvBufSurface Note: Caller must call unmap_nvbufsurface after use.
NvBufSurface
Holds information about batched buffers.
Definition: sources/includes/nvbufsurface.h:597
NvBufSurfTransformRect
Holds the coordinates of a rectangle.
Definition: sources/includes/nvbufsurftransform.h:158
rgb_surface_to_tensor_device
int rgb_surface_to_tensor_device(NvBufSurface *rgb_surface, float *d_output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
GPU path: write tensor on device (no D2H).
NvBufSurfaceParams
Hold the information of single buffer in the batch.
Definition: sources/includes/nvbufsurface.h:562
preprocess_batch_with_nvbufsurftransform
int preprocess_batch_with_nvbufsurftransform(NvBufSurface *input_surface, const guint *batch_ids, NvDsObjectMeta **obj_meta_array, guint num_objects, NvBufSurface *prealloc_output_surface, guint target_width, guint target_height, guint gpu_id, guint max_batch_size, NvBufSurfaceParams *prealloc_surf_list, NvBufSurfTransformRect *prealloc_src_rect, NvBufSurfTransformRect *prealloc_dst_rect, gboolean output_for_gpu)
Single-call batch preprocess (SGIE-style): all objects from all frames in one NvBufSurfTransform.
rgb_surface_to_tensor
int rgb_surface_to_tensor(NvBufSurface *rgb_surface, float *output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
rgba_surface_to_tensor_device
int rgba_surface_to_tensor_device(NvBufSurface *rgba_surface, float *d_output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
GPU path for RGBA: write tensor on device (no D2H).
rgba_surface_to_tensor
int rgba_surface_to_tensor(NvBufSurface *rgba_surface, float *output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
preprocess_crops_rgba
int preprocess_crops_rgba(const void *rgba_surface, int surface_width, int surface_height, int surface_pitch, const float *crop_boxes, int num_crops, float *output, int target_width, int target_height, cudaStream_t stream)
LEGACY: Preprocess multiple crops from an RGBA surface.
preprocess_crops_nv12
int preprocess_crops_nv12(const void *nv12_surface, int surface_width, int surface_height, int surface_pitch, const float *crop_boxes, int num_crops, float *output, int target_width, int target_height, cudaStream_t stream)
Preprocess multiple crops from an NV12 surface.
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: sources/includes/nvdsmeta.h:360