-
Notifications
You must be signed in to change notification settings - Fork 28
/
pydoc.hpp
155 lines (131 loc) · 6.68 KB
/
pydoc.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PYHOLOSCAN_OPERATORS_FORMAT_CONVERTER_PYDOC_HPP
#define PYHOLOSCAN_OPERATORS_FORMAT_CONVERTER_PYDOC_HPP
#include <string>
#include "../../macros.hpp"
namespace holoscan::doc::FormatConverterOp {
// PyFormatConverterOp Constructor
PYDOC(FormatConverterOp, R"doc(
Format conversion operator.
**==Named Inputs==**
source_video : nvidia::gxf::Tensor or nvidia::gxf::VideoBuffer
The input video frame to process. If the input is a VideoBuffer it must be in format
GXF_VIDEO_FORMAT_RGBA, GXF_VIDEO_FORMAT_RGB or GXF_VIDEO_FORMAT_NV12. If a video buffer is
not found, the input port message is searched for a tensor with the name specified by
`in_tensor_name`. This must be a tensor in one of several supported formats (unsigned 8-bit
int or float32 graycale, unsigned 8-bit int RGB or RGBA YUV420 or NV12). The tensor or video
buffer may be in either host or device memory (a host->device copy is performed if needed).
**==Named Outputs==**
tensor : nvidia::gxf::Tensor
The output video frame after processing. The shape, data type and number of channels of this
output tensor will depend on the specific parameters that were set for this operator. The
name of the Tensor transmitted on this port is determined by ``out_tensor_name``.
**==Device Memory Requirements==**
When using this operator with a ``holoscan.resources.BlockMemoryPool``, between 1 and 3 device
memory blocks (``storage_type=1``) will be required based on the input tensors and parameters:
- 1.) In all cases there is a memory block needed for the output tensor. The size of this
block will be ``out_height * out_width * out_channels * out_element_size_bytes`` where
``(out_height, out_width)`` will either be ``(in_height, in_width)`` (or
``(resize_height, resize_width)`` a resize was specified). `out_element_size` is the
element size in bytes (e.g. 1 for RGB888 or 4 for Float32).
- 2.) If a resize is being done, another memory block is required for this. This block will
have size ``resize_height * resize_width * in_channels * in_element_size_bytes``.
- 3.) If the input tensor will be in host memory, a memory block is needed to copy the input
to the device. This block will have size
``in_height * in_width * in_channels * in_element_size_bytes``.
Thus when declaring the memory pool, `num_blocks` will be between 1 and 3 and `block_size`
must be greater or equal to the largest of the individual blocks sizes described above.
Parameters
----------
fragment : holoscan.core.Fragment (constructor only)
The fragment that the operator belongs to.
pool : holoscan.resources.Allocator
Memory pool allocator used by the operator.
out_dtype : str
Destination data type. The available options are:
- ``"rgb888"``
- ``"uint8"``
- ``"float32"``
- ``"rgba8888"``
- ``"yuv420"``
- ``"nv12"``
in_dtype : str, optional
Source data type. The available options are:
- ``"rgb888"``
- ``"uint8"``
- ``"float32"``
- ``"rgba8888"``
- ``"yuv420"``
- ``"nv12"``
in_tensor_name : str, optional
The name of the input tensor. Default value is ``""`` (empty string).
out_tensor_name : str, optional
The name of the output tensor. Default value is ``""`` (empty string).
scale_min : float, optional
Output will be clipped to this minimum value. Default value is ``0.0``.
scale_max : float, optional
Output will be clipped to this maximum value. Default value is ``1.0``.
alpha_value : int, optional
Unsigned integer in range [0, 255], indicating the alpha channel value to use
when converting from RGB to RGBA. Default value is ``255``.
resize_height : int, optional
Desired height for the (resized) output. Height will be unchanged if ``resize_height`` is ``0``.
Default value is ``0``.
resize_width : int, optional
Desired width for the (resized) output. Width will be unchanged if ``resize_width`` is ``0``.
Default value is ``0``.
resize_mode : int, optional
Resize mode enum value corresponding to NPP's NppiInterpolationMode.
Values available at:
https://docs.nvidia.com/cuda/npp/nppdefs.html?highlight=Two%20parameter%20cubic%20filter#c.NppiInterpolationMode
- NPPI_INTER_UNDEFINED (``0``): Undefined filtering interpolation mode.
- NPPI_INTER_NN (``1``): Nearest neighbor filtering.
- NPPI_INTER_LINEAR (``2``): Linear interpolation.
- NPPI_INTER_CUBIC (``4``): Cubic interpolation.
- NPPI_INTER_CUBIC2P_BSPLINE (``5``): Two-parameter cubic filter (B=1, C=0)
- NPPI_INTER_CUBIC2P_CATMULLROM (``6``): Two-parameter cubic filter (B=0, C=1/2)
- NPPI_INTER_CUBIC2P_B05C03 (``7``): Two-parameter cubic filter (B=1/2, C=3/10)
- NPPI_INTER_SUPER (``8``): Super sampling.
- NPPI_INTER_LANCZOS (``16``): Lanczos filtering.
- NPPI_INTER_LANCZOS3_ADVANCED (``17``): Generic Lanczos filtering with order 3.
- NPPI_SMOOTH_EDGE (``0x8000000``): Smooth edge filtering.
Default value is ``0`` (NPPI_INTER_UNDEFINED) which would be equivalent to ``4``
(NPPI_INTER_CUBIC).
channel_order : sequence of int
Sequence of integers describing how channel values are permuted.
Default value is ``[0, 1, 2]`` for 3-channel images and ``[0, 1, 2, 3]`` for 4-channel images.
cuda_stream_pool : holoscan.resources.CudaStreamPool, optional
`holoscan.resources.CudaStreamPool` instance to allocate CUDA streams.
Default value is ``None``.
name : str, optional (constructor only)
The name of the operator. Default value is ``"format_converter"``.
)doc")
PYDOC(initialize, R"doc(
Initialize the operator.
This method is called only once when the operator is created for the first time,
and uses a light-weight initialization.
)doc")
PYDOC(setup, R"doc(
Define the operator specification.
Parameters
----------
spec : holoscan.core.OperatorSpec
The operator specification.
)doc")
} // namespace holoscan::doc::FormatConverterOp
#endif /* PYHOLOSCAN_OPERATORS_FORMAT_CONVERTER_PYDOC_HPP */