NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/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: 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 __PREPROCESS_H__
19 #define __PREPROCESS_H__
20 
21 #include <cuda_runtime.h>
22 #include <glib.h>
23 #include "nvbufsurface.h"
24 #include "nvbufsurftransform.h"
25 #include "nvdsmeta.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
36  NvBufSurface *input_surface,
37  guint batch_id,
38  NvDsObjectMeta **obj_meta_array,
39  guint num_objects,
40  NvBufSurface *prealloc_output_surface,
41  guint target_width,
42  guint target_height,
43  guint gpu_id,
44  guint max_batch_size,
45  NvBufSurfaceParams *prealloc_surf_list,
46  NvBufSurfTransformRect *prealloc_src_rect,
47  NvBufSurfTransformRect *prealloc_dst_rect);
48 
55  NvBufSurface *input_surface,
56  const guint *batch_ids,
57  NvDsObjectMeta **obj_meta_array,
58  guint num_objects,
59  NvBufSurface *prealloc_output_surface,
60  guint target_width,
61  guint target_height,
62  guint gpu_id,
63  guint max_batch_size,
64  NvBufSurfaceParams *prealloc_surf_list,
65  NvBufSurfTransformRect *prealloc_src_rect,
66  NvBufSurfTransformRect *prealloc_dst_rect,
67  gboolean output_for_gpu);
68 
70  NvBufSurface *rgb_surface,
71  float *output_tensor,
72  guint num_images,
73  guint width,
74  guint height,
75  gboolean use_siglip_normalization);
76 
79  NvBufSurface *rgb_surface,
80  float *d_output_tensor,
81  guint num_images,
82  guint width,
83  guint height,
84  gboolean use_siglip_normalization);
85 
87  NvBufSurface *rgba_surface,
88  float *output_tensor,
89  guint num_images,
90  guint width,
91  guint height,
92  gboolean use_siglip_normalization);
93 
96  NvBufSurface *rgba_surface,
97  float *d_output_tensor,
98  guint num_images,
99  guint width,
100  guint height,
101  gboolean use_siglip_normalization);
102 
107  const void* rgba_surface,
108  int surface_width,
109  int surface_height,
110  int surface_pitch,
111  const float* crop_boxes,
112  int num_crops,
113  float* output,
114  int target_width,
115  int target_height,
116  cudaStream_t stream
117 );
118 
135  const void* nv12_surface,
136  int surface_width,
137  int surface_height,
138  int surface_pitch,
139  const float* crop_boxes,
140  int num_crops,
141  float* output,
142  int target_width,
143  int target_height,
144  cudaStream_t stream
145 );
146 
151 void* get_nvbufsurface_device_ptr(NvBufSurface* surf, unsigned int buf_idx);
152 
156 void unmap_nvbufsurface(NvBufSurface* surf, unsigned int buf_idx);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif // __PREPROCESS_H__
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: sources/includes/nvbufsurftransform.h:35
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.
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_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).
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
NvBufSurfaceParams
Hold the information of single buffer in the batch.
Definition: sources/includes/nvbufsurface.h:562
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)
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).
unmap_nvbufsurface
void unmap_nvbufsurface(NvBufSurface *surf, unsigned int buf_idx)
Unmap NvBufSurface after use.
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.
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.
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 (...
_NvDsObjectMeta
Holds metadata for an object in the frame.
Definition: sources/includes/nvdsmeta.h:365