NVIDIA DeepStream SDK API Reference

9.0 Release
sources/includes/nvll_obb.h File Reference

Go to the source code of this file.

Typedefs

typedef struct _NvOBBDumpCtx NvOBBDumpCtx
 OBB dump context handle. More...
 

Functions

NvOBBDumpCtxnvobb_dump_create_context (int gpu_id, cudaStream_t cuda_stream)
 Create OBB dump context. More...
 
void nvobb_dump_destroy_context (NvOBBDumpCtx *ctx)
 Destroy OBB dump context. More...
 
NvOBBDumpCtxnvobb_dump_get_singleton (int gpu_id, cudaStream_t cuda_stream)
 Get or create singleton OBB dump context. More...
 
void nvobb_dump_cleanup_singleton (void)
 Cleanup singleton OBB dump context. More...
 
bool nvobb_dump_frame (NvOBBDumpCtx *ctx, NvBufSurface *input_surf, void *rect_params_array, int num_rects, unsigned int frame_num)
 Process frame and dump OBBs. More...
 
cudaError_t nvobb_rotate_gpu (const uint8_t *aabb_pixels, int aabb_width, int aabb_height, int aabb_pitch, int obb_width, int obb_height, float obb_cx, float obb_cy, float angle_rad, cudaStream_t stream, uint8_t **d_output)
 Rotate OBB to rectangular RGBA on GPU (standalone) More...
 
uint8_t * nvobb_rotate_cpu (const uint8_t *aabb_pixels, int aabb_width, int aabb_height, int aabb_pitch, int obb_width, int obb_height, float obb_cx, float obb_cy, float angle_rad)
 Rotate OBB to rectangular RGBA on CPU (standalone) More...
 

Typedef Documentation

◆ NvOBBDumpCtx

typedef struct _NvOBBDumpCtx NvOBBDumpCtx

OBB dump context handle.

Note: NvOSD_RectParams and NvOSD_ColorParams are defined in nvll_osd_struct.h and are included via nvll_osd_api.h

Definition at line 30 of file sources/includes/nvll_obb.h.

Function Documentation

◆ nvobb_dump_cleanup_singleton()

void nvobb_dump_cleanup_singleton ( void  )

Cleanup singleton OBB dump context.

Should be called during application shutdown to properly release all OBB dump resources. Thread-safe and idempotent.

◆ nvobb_dump_create_context()

NvOBBDumpCtx* nvobb_dump_create_context ( int  gpu_id,
cudaStream_t  cuda_stream 
)

Create OBB dump context.

Initializes the OBB dumping system. Reads configuration from environment variables:

  • NVDS_OBB_DUMP_ENABLED: Set to 1 to enable (default: disabled)
  • NVDS_OBB_DUMP_DIR: Output directory (default: /tmp/obb_dumps)
  • NVDS_OBB_DUMP_QUALITY: JPEG quality 1-100 (default: 90)
  • NVDS_OBB_DUMP_FRAME_INTERVAL: Dump every Nth frame (default: 30)
  • NVDS_OBB_DUMP_MIN_ANGLE: Minimum angle threshold in degrees (default: 1.0)
Parameters
gpu_idGPU device ID
cuda_streamCUDA stream to use for async operations
Returns
NvOBBDumpCtx* Context handle, or NULL if disabled or failed

◆ nvobb_dump_destroy_context()

void nvobb_dump_destroy_context ( NvOBBDumpCtx ctx)

Destroy OBB dump context.

Waits for all pending encodes to finish and frees all resources.

Parameters
ctxContext handle

◆ nvobb_dump_frame()

bool nvobb_dump_frame ( NvOBBDumpCtx ctx,
NvBufSurface input_surf,
void *  rect_params_array,
int  num_rects,
unsigned int  frame_num 
)

Process frame and dump OBBs.

Extracts and saves rotated OBBs from the frame. This function:

  1. Checks frame interval (only processes every Nth frame)
  2. For each OBB with angle >= min_angle: a. Calculates AABB containing the rotated OBB b. Crops AABB using NvBufSurfTransform (GPU) c. Extracts rotated pixels using obb_scanline_rotate_gpu d. Encodes to JPEG using nvds_obj_encode
Parameters
ctxContext handle
input_surfInput surface containing the frame
rect_params_arrayArray of rectangle parameters (NvOSD_RectParams*)
num_rectsNumber of rectangles in the array
frame_numFrame number (for filename generation)
Returns
bool true on success, false on failure

◆ nvobb_dump_get_singleton()

NvOBBDumpCtx* nvobb_dump_get_singleton ( int  gpu_id,
cudaStream_t  cuda_stream 
)

Get or create singleton OBB dump context.

Thread-safe lazy initialization of global OBB dump context. The context is created once and reused across all OSD drawing calls.

Parameters
gpu_idGPU device ID
cuda_streamCUDA stream (0 for default stream)
Returns
Pointer to singleton context, or NULL if disabled/failed

◆ nvobb_rotate_cpu()

uint8_t* nvobb_rotate_cpu ( const uint8_t *  aabb_pixels,
int  aabb_width,
int  aabb_height,
int  aabb_pitch,
int  obb_width,
int  obb_height,
float  obb_cx,
float  obb_cy,
float  angle_rad 
)

Rotate OBB to rectangular RGBA on CPU (standalone)

This function performs ONLY the rotation on CPU. No dumping, no threading, no encoding. Use this when you want to process rotated OBBs yourself and don't need GPU acceleration.

Parameters
aabb_pixelsInput AABB pixels (CPU memory, RGBA format)
aabb_widthWidth of input AABB
aabb_heightHeight of input AABB
aabb_pitchPitch (stride) of AABB in bytes
obb_widthWidth of output OBB
obb_heightHeight of output OBB
obb_cxCenter X of OBB in AABB space
obb_cyCenter Y of OBB in AABB space
angle_radRotation angle in radians
Returns
uint8_t* Allocated CPU buffer with rotated OBB (RGBA), or NULL on failure Caller must free with g_free() or free()
Note
Memory management: Caller is responsible for freeing returned buffer with g_free()
Output format: RGBA, tightly packed, row-major, size = obb_width × obb_height × 4 bytes

◆ nvobb_rotate_gpu()

cudaError_t nvobb_rotate_gpu ( const uint8_t *  aabb_pixels,
int  aabb_width,
int  aabb_height,
int  aabb_pitch,
int  obb_width,
int  obb_height,
float  obb_cx,
float  obb_cy,
float  angle_rad,
cudaStream_t  stream,
uint8_t **  d_output 
)

Rotate OBB to rectangular RGBA on GPU (standalone)

This function performs ONLY the rotation on GPU. No dumping, no threading, no encoding. Use this when you want to process rotated OBBs yourself (e.g., for tracking, feature extraction, etc.)

Parameters
aabb_pixelsInput AABB pixels (GPU memory, RGBA format)
aabb_widthWidth of input AABB
aabb_heightHeight of input AABB
aabb_pitchPitch (stride) of AABB in bytes
obb_widthWidth of output OBB
obb_heightHeight of output OBB
obb_cxCenter X of OBB in AABB space
obb_cyCenter Y of OBB in AABB space
angle_radRotation angle in radians
streamCUDA stream for async execution (use 0 for default stream)
[out]d_outputPointer to receive allocated GPU buffer with rotated OBB Caller must free with cudaFree()
Returns
cudaError_t cudaSuccess on success, error code on failure
Note
Memory management: Caller is responsible for freeing *d_output with cudaFree()
Output format: RGBA, tightly packed, row-major, size = obb_width × obb_height × 4 bytes