NVIDIA DeepStream SDK API Reference

8.0 Release
cuosd_kernel.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2025 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 CUOSD_KERNEL_H
14 #define CUOSD_KERNEL_H
15 
16 enum class ImageFormat : int {
17  None = 0,
18  RGB = 1,
19  RGBA = 2,
20  BlockLinearNV12 = 3,
21  PitchLinearNV12 = 4
22 };
23 
24 enum class CommandType : int {
25  None = 0,
26  Circle = 1,
27  Rectangle = 2,
28  Text = 3,
29  Segment = 4,
30  PolyFill = 5,
31  RGBASource = 6,
32  NV12Source = 7,
33  BoxBlur = 8
34 };
35 
36 struct TextLocation{
38  int text_x;
39  int text_w, text_h;
40 };
41 
42 // cuOSDContextCommand includes basic attributes for color and bounding box coordinate
45  unsigned char c0, c1, c2, c3;
46  int bounding_left = 0;
47  int bounding_top = 0;
48  int bounding_right = 0;
49  int bounding_bottom = 0;
50 };
51 
52 // CircleCommand:
53 // cx, cy: center point coordinate of the circle
54 // thickness: border width in case > 0, -1 stands for fill mode
57 
58  CircleCommand(int cx, int cy, int radius, int thickness, unsigned char c0, unsigned char c1, unsigned char c2, unsigned char c3);
59 };
60 
61 // RectangleCommand:
62 // ax1, ..., dy1: 4 outer corner points coordinate of the rectangle
63 // ax2, ..., dy2: 4 inner corner points coordinate of the rectangle
64 // a1 ------ d1
65 // | a2---d2 |
66 // | | | |
67 // | b2---c2 |
68 // b1 ------ c1
69 // thickness: border width in case > 0, -1 stands for fill mode
71  int thickness = -1;
72  bool interpolation = false;
73  float ax1, ay1, bx1, by1, cx1, cy1, dx1, dy1;
74  float ax2, ay2, bx2, by2, cx2, cy2, dx2, dy2;
75 
77 };
78 
80  int kernel_size = 7;
81 
83 };
84 
85 // TextCommand:
86 // text_line_size && ilocation are inner attribute for text memory management
89  int ilocation;
90 
91  TextCommand() = default;
92  TextCommand(int text_line_size, int ilocation, unsigned char c0, unsigned char c1, unsigned char c2, unsigned char c3);
93 };
94 
95 // SegmentCommand:
96 // scale_x: seg mask w / outer rect w
97 // scale_y: seg mask h / outer rect h
99  float* d_seg;
101  float scale_x, scale_y;
103 
104  SegmentCommand();
105 };
106 
107 // PolyFillCommand:
109  int* d_pts;
110  int n_pts;
111 
112  PolyFillCommand();
113 };
114 
115 // RGBASourceCommand:
116 // d_src: device pointer for incoming rgba source image
118  void* d_src;
120  float scale_x, scale_y;
121 
123 };
124 
125 // NV12SourceCommand:
126 // d_src0: device pointer for Y plane of incoming nv12 source image
127 // d_src1: device pointer for UV plane of incoming nv12 source image
128 // block_linear: input device pointers are block linear or pitch linear
130  void* d_src0;
131  void* d_src1;
133  float scale_x, scale_y;
135 
137 };
138 
140  void* image_data0, void* image_data1, int width, int stride, int height, ImageFormat format,
141  const TextLocation* text_location, const unsigned char* text_bitmap, int text_bitmap_width, const int* line_location_base,
142  const unsigned char* commands, const int* commands_offset, int num_commands,
143  int bounding_left, int bounding_top, int bounding_right, int bounding_bottom,
144  bool have_rotatebox, const unsigned char* blur_commands, int num_blur_commands,
145  void* stream
146 );
147 
148 #endif // CUOSD_KERNEL_H
RGBASourceCommand::scale_x
float scale_x
Definition: cuosd_kernel.h:120
SegmentCommand::seg_threshold
float seg_threshold
Definition: cuosd_kernel.h:102
BoxBlurCommand
Definition: cuosd_kernel.h:79
cuOSDClockFormat::None
@ None
cuOSDContextCommand::bounding_bottom
int bounding_bottom
Definition: cuosd_kernel.h:49
CommandType::Text
@ Text
cuOSDContextCommand::bounding_right
int bounding_right
Definition: cuosd_kernel.h:48
TextLocation
Definition: cuosd_kernel.h:36
TextLocation::text_x
int text_x
Definition: cuosd_kernel.h:38
CircleCommand
Definition: cuosd_kernel.h:55
RGBASourceCommand::src_stride
int src_stride
Definition: cuosd_kernel.h:119
NV12SourceCommand::scale_y
float scale_y
Definition: cuosd_kernel.h:133
CommandType::Circle
@ Circle
RectangleCommand::cy1
float cy1
Definition: cuosd_kernel.h:73
RectangleCommand::cx2
float cx2
Definition: cuosd_kernel.h:74
CommandType::Rectangle
@ Rectangle
CommandType::RGBASource
@ RGBASource
SegmentCommand::scale_x
float scale_x
Definition: cuosd_kernel.h:101
CircleCommand::radius
int radius
Definition: cuosd_kernel.h:56
RGBASourceCommand::RGBASourceCommand
RGBASourceCommand()
cuOSDContextCommand::c3
unsigned char c3
Definition: cuosd_kernel.h:45
PolyFillCommand::n_pts
int n_pts
Definition: cuosd_kernel.h:110
CircleCommand::CircleCommand
CircleCommand(int cx, int cy, int radius, int thickness, unsigned char c0, unsigned char c1, unsigned char c2, unsigned char c3)
cuOSDContextCommand::c0
unsigned char c0
Definition: cuosd_kernel.h:45
RGBASourceCommand
Definition: cuosd_kernel.h:117
RectangleCommand::ax1
float ax1
Definition: cuosd_kernel.h:73
TextCommand
Definition: cuosd_kernel.h:87
RectangleCommand::dx2
float dx2
Definition: cuosd_kernel.h:74
NV12SourceCommand::d_src0
void * d_src0
Definition: cuosd_kernel.h:130
NV12SourceCommand::src_width
int src_width
Definition: cuosd_kernel.h:132
RectangleCommand::ax2
float ax2
Definition: cuosd_kernel.h:74
NV12SourceCommand::d_src1
void * d_src1
Definition: cuosd_kernel.h:131
RectangleCommand::interpolation
bool interpolation
Definition: cuosd_kernel.h:72
cuOSDContextCommand
Definition: cuosd_kernel.h:43
BoxBlurCommand::BoxBlurCommand
BoxBlurCommand()
cuOSDContextCommand::bounding_left
int bounding_left
Definition: cuosd_kernel.h:46
RectangleCommand::dx1
float dx1
Definition: cuosd_kernel.h:73
NV12SourceCommand::src_height
int src_height
Definition: cuosd_kernel.h:132
CircleCommand::thickness
int thickness
Definition: cuosd_kernel.h:56
RectangleCommand::by1
float by1
Definition: cuosd_kernel.h:73
RGBASourceCommand::scale_y
float scale_y
Definition: cuosd_kernel.h:120
cuOSDContextCommand::type
CommandType type
Definition: cuosd_kernel.h:44
CommandType::None
@ None
NV12SourceCommand::scale_x
float scale_x
Definition: cuosd_kernel.h:133
RectangleCommand::RectangleCommand
RectangleCommand()
cuOSDContextCommand::bounding_top
int bounding_top
Definition: cuosd_kernel.h:47
cuOSDImageFormat::PitchLinearNV12
@ PitchLinearNV12
RGBASourceCommand::d_src
void * d_src
Definition: cuosd_kernel.h:118
NV12SourceCommand::block_linear
bool block_linear
Definition: cuosd_kernel.h:134
CircleCommand::cx
int cx
Definition: cuosd_kernel.h:56
TextCommand::text_line_size
int text_line_size
Definition: cuosd_kernel.h:88
CommandType::Segment
@ Segment
NV12SourceCommand::NV12SourceCommand
NV12SourceCommand()
RectangleCommand::bx1
float bx1
Definition: cuosd_kernel.h:73
TextLocation::image_x
int image_x
Definition: cuosd_kernel.h:37
TextLocation::text_h
int text_h
Definition: cuosd_kernel.h:39
TextLocation::image_y
int image_y
Definition: cuosd_kernel.h:37
SegmentCommand::SegmentCommand
SegmentCommand()
PolyFillCommand::d_pts
int * d_pts
Definition: cuosd_kernel.h:109
TextLocation::text_w
int text_w
Definition: cuosd_kernel.h:39
CommandType::NV12Source
@ NV12Source
CommandType::PolyFill
@ PolyFill
NV12SourceCommand
Definition: cuosd_kernel.h:129
SegmentCommand::seg_height
int seg_height
Definition: cuosd_kernel.h:100
SegmentCommand::seg_width
int seg_width
Definition: cuosd_kernel.h:100
CommandType
CommandType
Definition: cuosd_kernel.h:24
BoxBlurCommand::kernel_size
int kernel_size
Definition: cuosd_kernel.h:80
RectangleCommand
Definition: cuosd_kernel.h:70
cuOSDContextCommand::c2
unsigned char c2
Definition: cuosd_kernel.h:45
CircleCommand::cy
int cy
Definition: cuosd_kernel.h:56
TextCommand::ilocation
int ilocation
Definition: cuosd_kernel.h:89
RectangleCommand::by2
float by2
Definition: cuosd_kernel.h:74
TextCommand::TextCommand
TextCommand()=default
RectangleCommand::cx1
float cx1
Definition: cuosd_kernel.h:73
cuOSDImageFormat::RGBA
@ RGBA
PolyFillCommand
Definition: cuosd_kernel.h:108
RectangleCommand::dy1
float dy1
Definition: cuosd_kernel.h:73
NV12SourceCommand::src_stride
int src_stride
Definition: cuosd_kernel.h:132
RectangleCommand::thickness
int thickness
Definition: cuosd_kernel.h:71
SegmentCommand::scale_y
float scale_y
Definition: cuosd_kernel.h:101
RGBASourceCommand::src_height
int src_height
Definition: cuosd_kernel.h:119
RectangleCommand::cy2
float cy2
Definition: cuosd_kernel.h:74
PolyFillCommand::PolyFillCommand
PolyFillCommand()
ImageFormat
ImageFormat
Definition: cuosd_kernel.h:16
cuOSDContextCommand::c1
unsigned char c1
Definition: cuosd_kernel.h:45
RectangleCommand::dy2
float dy2
Definition: cuosd_kernel.h:74
SegmentCommand
Definition: cuosd_kernel.h:98
cuOSDImageFormat::RGB
@ RGB
cuOSDImageFormat::BlockLinearNV12
@ BlockLinearNV12
RectangleCommand::ay2
float ay2
Definition: cuosd_kernel.h:74
CommandType::BoxBlur
@ BoxBlur
RGBASourceCommand::src_width
int src_width
Definition: cuosd_kernel.h:119
RectangleCommand::ay1
float ay1
Definition: cuosd_kernel.h:73
RectangleCommand::bx2
float bx2
Definition: cuosd_kernel.h:74
cuosd_launch_kernel
void cuosd_launch_kernel(void *image_data0, void *image_data1, int width, int stride, int height, ImageFormat format, const TextLocation *text_location, const unsigned char *text_bitmap, int text_bitmap_width, const int *line_location_base, const unsigned char *commands, const int *commands_offset, int num_commands, int bounding_left, int bounding_top, int bounding_right, int bounding_bottom, bool have_rotatebox, const unsigned char *blur_commands, int num_blur_commands, void *stream)
ds3d::v2xinfer::format
static std::string format(const char *fmt,...)
Definition: sources/libs/ds3d/inference_custom_lib/ds3d_v2x_infer_custom_preprocess/tensor.hpp:26
SegmentCommand::d_seg
float * d_seg
Definition: cuosd_kernel.h:99