NVIDIA DeepStream SDK API Reference

9.0 Release
sources/gst-plugins/gst-nvdsvisionencoder-c/preprocess.h File Reference

Go to the source code of this file.

Functions

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 (like nvinfer SGIE does) More...
 
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. More...
 
int rgb_surface_to_tensor (NvBufSurface *rgb_surface, float *output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
 
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). More...
 
int rgba_surface_to_tensor (NvBufSurface *rgba_surface, float *output_tensor, guint num_images, guint width, guint height, gboolean use_siglip_normalization)
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
void unmap_nvbufsurface (NvBufSurface *surf, unsigned int buf_idx)
 Unmap NvBufSurface after use. More...
 

Function Documentation

◆ 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_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.

batch_ids[i] = frame batch_id for object i. output_for_gpu: if TRUE, call SyncForDevice (next step is GPU); if FALSE, SyncForCpu (avoids unnecessary D2H sync on device path).

◆ 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.

Parameters
nv12_surfaceDevice pointer to NV12 surface
surface_widthWidth of the surface
surface_heightHeight of the surface
surface_pitchPitch (stride) of the surface
crop_boxesHost array of crop boxes [num_crops, 4] (left, top, width, height)
num_cropsNumber of crops
outputDevice pointer for output [num_crops, 3, target_h, target_w]
target_widthTarget width for each crop
target_heightTarget height for each crop
streamCUDA stream
Returns
0 on success, -1 on error

◆ 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_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 (like nvinfer SGIE does)

◆ 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 
)

◆ 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).

Use with nvds_triton_client_infer_device for FPS.

◆ 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 
)

◆ 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).

Use with nvds_triton_client_infer_device for FPS.

◆ unmap_nvbufsurface()

void unmap_nvbufsurface ( NvBufSurface surf,
unsigned int  buf_idx 
)

Unmap NvBufSurface after use.