NVIDIA DeepStream SDK API Reference

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