Holoscan Vision#
Holoscan Vision packages pipeline-native image operators for Holoscan applications. Eight operators wrap CV-CUDA, and Bayer demosaic is backed by NPP. They work on the tensors already in your graph and submit work on the operator’s CUDA stream.
Package info#
| Package | holoscan-vision |
|---|---|
| GitHub repository | nvidia-holoscan/holoscan-sdk |
| Version | 5.0.0 |
| C++ namespace | holoscan::vision |
| Python namespace | holoscan_vision |
| Holoscan SDK | 5.0.0 or later, tested with 5.0.0 |
| Platforms | x86_64, aarch64 |
| Languages | C++, Python |
| License | Apache-2.0 |
| Maintainer | Holoscan Team, NVIDIA |
| Debian package | holoscan-vision |
| PyPI package | holoscan-vision-cu13 |
Operators#
BayerDemosaicOpreconstructs RGB or RGBA from Bayer data (NPP; rank-3, single-channel input only).ResizeOpresizes images (nearest, linear, cubic, or area interpolation).CustomCropOpextracts a rectangle (the full crop must fit inside the input).CopyMakeBorderOpadds padding (declare the maximum output dimensions).RemapOpapplies a coordinate map (requires a two-channel F32 map; map age and synchronization are configurable).NormalizeOpnormalizes channel values (preserves input dtype).ConvertToOpconverts dtype and scales values (use before normalization for U8-to-F32 conversion).ReformatOpchanges interleaved or planar layout (other Vision image operators require HWC or NHWC).NonMaximumSuppressionOpfilters detection boxes (S16 boxes and F32 scores must share a capture time).
Quick Start#
Installation#
Configure the NVIDIA repository for your platform using the SDK installation guide, then install the module and its matching Core dependency.
sudo apt update
sudo apt install holoscan-vision
Use a Python 3.12 or newer virtual environment with CUDA 13.
python -m pip install holoscan-vision-cu13
No Yocto recipe is published for this SDK 5 module yet. The current Holoscan Yocto layer targets SDK 4.6.
Example Usage#
Resize an image to 1280 × 720. These fragments assume an existing graph with compatible image ports; execution setup is omitted.
find_package(holoscan COMPONENTS vision REQUIRED)
target_link_libraries(my_pipeline PRIVATE holoscan::vision)
#include <holoscan/vision/resize_op.hpp>
// ...
auto resize = graph.op<holoscan::vision::ResizeOp>("resize");
resize.set_params(holoscan::vision::ResizeOpParams{
.width = 1280, .height = 720, .max_batch_size = 4U,
.interpolation = holoscan::vision::InterpolationMode::kLinear,
});
graph.add_flow(source->output, resize->input);
// ...
from holoscan_vision.operators import ResizeOp
# ...
resize = ResizeOp(
graph, "resize", width=1280, height=720,
max_batch_size=4, interpolation="linear",
)
graph.add_flow(source.output, resize.input)
# ...
Bind the resize.output tensor pool to a CUDA device before compiling the graph; see device placement.
Docs#
Image operators use input → output ports carrying holoscan.schema.Image with a CUDA tensor. They submit work on the operator's CUDA stream without staging images through host memory. Unless noted below, image layouts are HWC or NHWC. Packed and chroma-subsampled encodings such as YUYV and NV12 must be converted before entering these operators.
BayerDemosaicOp#
BayerDemosaicOp reconstructs an RGB or RGBA image from a single-channel Bayer mosaic. Each input pixel measures only one color; NPP's CFA-to-RGB(A) interpolation reconstructs the missing channels from neighboring samples. Output keeps the input width, height, and U8 or U16 element type.
| Parameter | What it sets |
|---|---|
bayer_grid_pos |
Bayer phase at the input origin: BGGR, RGGB, GBRG (default), or GRBG |
generate_alpha |
Produce four-channel RGBA instead of three-channel RGB; default false |
alpha_value |
Constant alpha when generating RGBA; default 255 |
Remarks. Input must be a CUDA U8 or U16 tensor shaped [H, W, 1], with even width and height. The declared Bayer encoding must agree with bayer_grid_pos. Alpha is unscaled: use 65535 for opaque U16 output. Demosaicing updates the output encoding and plane layout; color space and effective precision are marked unknown because interpolation changes the samples.
ResizeOp#
ResizeOp changes an image's spatial dimensions using CV-CUDA. Nearest-neighbor selects source samples, linear and cubic interpolation blend neighboring samples, and area interpolation averages over source regions. Choose interpolation according to the image content and whether you are enlarging or reducing it. The operator preserves channel count and dtype.
| Parameter | What it sets |
|---|---|
width, height |
Output dimensions in pixels |
max_batch_size |
Largest batch the output pool must hold |
interpolation |
nearest, linear, cubic, or area |
Remarks. Supports one, three, or four channels with U8, U16, S16, or F32 elements. Set max_batch_size to the real application bound before graph compilation. Resizing changes geometry; when dimensions change, ROI offsets reset and a Bayer encoding becomes CUSTOM. Use nearest-neighbor when interpolating label values would be inappropriate.
CustomCropOp#
CustomCropOp extracts a rectangular region from each input image with CV-CUDA. It copies that region into a contiguous output image without resizing or changing sample values. The rectangle uses pixel coordinates relative to the input image's top-left corner.
| Parameter | What it sets |
|---|---|
x, y |
Top-left pixel of the crop |
width, height |
Output rectangle dimensions |
max_batch_size |
Largest admitted image batch |
Remarks. The complete rectangle must fit inside the input; the operator rejects an out-of-bounds crop rather than clipping or padding it. Supports one through four channels with U8, S8, U16, S16, S32, F32, or F64 elements. ROI offsets advance by the crop origin, and Bayer phase is adjusted for odd crop offsets.
CopyMakeBorderOp#
CopyMakeBorderOp adds padding around an image with CV-CUDA. It copies the original pixels into the padded output and fills the surrounding region with a constant or samples extrapolated from the input. Output width is input_width + left + right; height is input_height + top + bottom.
| Parameter | What it sets |
|---|---|
top, bottom, left, right |
Nonnegative padding widths in pixels |
border_mode |
constant, replicate, reflect, wrap, or reflect_101 |
border_value |
Constant fill: one value for all channels, or one per channel |
max_width, max_height |
Maximum padded output dimensions used to size the output pool |
max_batch_size |
Maximum output batch size |
Remarks. Set capacity for the padded result, not just the original image. Supports U8, U16, S16, or F32 with one, three, or four channels; two-channel input is supported only for U8. Nonzero padding changes Bayer encoding to CUSTOM, because the resulting image no longer represents an uninterrupted sensor mosaic.
RemapOp#
RemapOp warps an image using a two-channel F32 coordinate map, for example for lens correction or geometric rectification. For each destination position, CV-CUDA samples the map to find the source coordinate, then samples the input image at that coordinate. Separate interpolation settings control those two steps; border settings define what happens outside the source image.
Ports are input and map → output. The map can be shared across a batch or supplied per image, and its spatial resolution can differ from the output resolution.
| Parameter | What it sets |
|---|---|
width, height, max_batch_size |
Output dimensions and maximum batch capacity |
input_interpolation, map_interpolation |
nearest, linear, or cubic sampling for the image and map |
map_value_mode |
Absolute pixel coordinates, absolute normalized coordinates, or relative normalized offsets |
align_corners |
Alignment of corner pixel centers for normalized coordinates |
border_mode, border_value |
Extrapolation and optional constant fill outside the image |
map_synchronization |
Reuse the latest causal map (default), or require an exact capture-time match |
map_max_age |
Maximum age of a reusable map; the default allows reuse throughout the run |
Remarks. U8 images support one, three, or four channels; F32 images support one channel. The F32 map has two channels and a batch size of one or the image batch size. Exact synchronization requires identical image and map capture times. The output takes its capture time and identity from the image; map flags are combined with image flags. Remapping resets ROI offsets and changes Bayer encoding to CUSTOM.
NormalizeOp#
NormalizeOp applies channel-wise normalization with CV-CUDA while preserving image shape and dtype. In ordinary mode it computes (input - base) * scale * global_scale + shift. With scale_is_stddev: true, the channel multiplier becomes 1 / sqrt(scale * scale + epsilon), enabling mean/standard-deviation normalization with a variance regularizer.
| Parameter | What it sets |
|---|---|
base |
Subtracted offset: one value or one per channel; default [0] |
scale |
Channel multiplier, or standard deviation when enabled; default [1] |
global_scale, shift |
Additional shared multiplier and final offset; defaults 1 and 0 |
scale_is_stddev |
Interpret scale as standard deviation; default false |
epsilon |
Nonnegative variance regularizer for standard-deviation mode; default 0 |
Remarks. Supports one, three, or four channels with U8, S8, U16, S16, S32, or F32 elements. This operator does not promote integers to floating point: put ConvertToOp with F32 output before it when fractional results are needed. A zero standard deviation requires positive epsilon. Value-changing normalization clears the color-space and effective-precision claims in image metadata.
ConvertToOp#
ConvertToOp changes an image's scalar dtype and optionally rescales its values. CV-CUDA applies output = alpha * input + beta and converts to output_type, with the selected rounding for integer output. Geometry and channel count stay the same. A common use is converting U8 camera data to F32 before normalization.
| Parameter | What it sets |
|---|---|
output_type |
U8, S8, U16, S16, S32, F32 (default), or F64 |
alpha, beta |
Scale and offset; defaults 1 and 0 |
rounding |
nearest or truncate for integer output |
Remarks. Supports one through four channels and the same scalar types listed for output. A plain U8-to-F32 cast preserves values in the 0–255 range; set alpha to 1/255 if you need 0–1 values. The operator updates image encoding for the new dtype when a named encoding exists, otherwise it uses CUSTOM.
ReformatOp#
ReformatOp rearranges image storage between interleaved HWC/NHWC and planar CHW/NCHW layouts using CV-CUDA. This is a memory-layout transformation: it keeps spatial dimensions, channel values, and dtype, and does not perform a color conversion or normalization.
| Parameter | What it sets |
|---|---|
mode |
Direction of conversion between interleaved and planar storage |
Remarks. Supports one through four channels with U8, S8, U16, S16, S32, F32, or F64 elements. Other Vision image operators accept HWC/NHWC; convert planar output back before passing it to one of them. The output is contiguous, and metadata is updated to describe its new layout.
NonMaximumSuppressionOp#
NonMaximumSuppressionOp filters detection boxes with CV-CUDA using confidence and overlap thresholds. It rejects low-scoring candidates and suppresses overlapping boxes according to their scores and Intersection over Union (IoU): intersection area divided by union area. The result is a selection mask over the original candidates, rather than a compacted array of boxes.
Ports are boxes + scores → mask. Boxes are S16 [N, W, 4] in (x, y, width, height) form, scores are F32 [N, W], and the output is a U8 [N, W] mask.
| Parameter | What it sets |
|---|---|
max_boxes |
Maximum number of candidate boxes per batch item |
max_batch_size |
Maximum number of batch items |
score_threshold |
Inclusive minimum score in [0, 1]; default 0 |
iou_threshold |
Permitted overlap threshold in (0, 1]; default 0.5 |
Remarks. Boxes and scores must have identical capture times and the same clock domain and CUDA device. Box coordinates and scores must be tightly packed within each row; box base addresses and batch strides need 8-byte alignment, scores need 4-byte alignment. Apply the emitted mask downstream to select the retained boxes.
Shared image requirements#
All tensors in an invocation must use the same CUDA device. Interleaved channels and pixels must be tightly packed; row and batch pitch may include padding. CV-CUDA's 32-bit addressing requires each byte stride and total strided span to fit within INT32_MAX. Output tensors use contiguous storage from bounded runtime pools.
See the Vision reference for image metadata rules and the parameter headers for the complete schemas.
Device placement#
Every Vision output needs an explicit device binding. For the resize example:
options.deployment.bind_tensor_output_device(
holoscan::TensorOutputDevicePlacement{
.operator_path = "resize", .output_port = "output",
.device = holoscan::DeviceId{0},
});
Build options#
HOLOSCAN_BUILD_VISION is on by default; set it to OFF for a source build without Vision. Python bindings require both HOLOSCAN_BUILD_PYTHON and HOLOSCAN_BUILD_VISION.
Examples#
| Example | What it shows |
|---|---|
vision_pipeline |
A complete C++ graph with image-processing and detection branches, including device placement |