Holoviz Migration
In Holoscan SDK 4.x, one HolovizOp did everything. You listed tensor names in
its tensors parameter, connected producers to its receivers port, and the
operator found each named tensor, guessed or read its type, and drew it as a
layer. The same operator owned the window, the camera, the input callbacks,
headless capture, and an immediate-mode viz:: library for custom drawing.
In Holoscan SDK 5.x, you declare everything the operator draws before the graph
compiles. A LayerStack lists typed layers, and each layer has its own typed
input port. A sink descriptor says where frames go. A trigger and a freshness
bound say when a frame is drawn. Small operators such as WindowDisplayOp,
ImGuiOp, and CompositorOp cover the cases that once needed the full
operator. Invalid declarations fail at construction or graph compilation. The
runtime also checks delivered tensors, and the renderer validates frame contents.
This page describes the Visualization module in Holoscan SDK 5.1. It maps every 4.x Holoviz parameter, port, input type, and library call to its 5.1 replacement, and lists the 4.x features that have no 5.1 equivalent yet. If you already ported to 5.0, also read Moving from 5.0 to 5.1. For the 5.x operators themselves, see Visualization. For the rest of the runtime, see the shared migration map and the Python migration guide.
- How each 4.x
HolovizOpparameter, port, and input type maps to 5.x - How to port image, LUT, 2D geometry, and text layers
- How the window, display, and headless outputs changed
- Which 4.x features have no 5.x equivalent, and what to do instead
Concept map
Declare layers instead of tensor names
A 4.x application listed InputSpec entries and connected every producer to
receivers:
In 5.x, declare the same layers on a LayerStack and connect each producer to
its own port. Set the maximum size of every layer, because the renderer sizes
its memory from these values once:
The listing shows graph wiring; it assumes graph, source, and detector
already exist. The detector must emit a contiguous host float32 tensor of
shape (4N,) for N rectangles, ordered as x0, y0, x1, y1 per rectangle.
Declare its output rank as 1. Propagate the source image’s acquisition time
with EmitOptions::capture_time on the derived boxes, using a clock domain
admitted by the graph. Without a capture timestamp, boxes are ineligible for
the side input’s capture-time selector, even if they were just computed. See
Emitting outputs
for the emission contract.
Keep these rules in mind:
- One operator holds at most
kMaxLayerPorts(8) layers of any kind. For a larger stack, render the lower layers to an RGBA8CudaSinkDesc. Connect that output as the first image layer of the nextHolovizOp, with up to seven additional layers above it. Repeat this chain as needed. Separate overlay-only renders clear untouched pixels to opaque black, so blending them over the camera withCompositorOpcan hide the underlying image. The shippedcuda_sink_exampleinmodules/visualization/examples/operatorsdemonstrates chaining twoHolovizOpinstances. - Layer names are port names. They must be non-empty and unique, and they must
not collide with the fixed
outputport or with a<name>_color_lutport that a LUT layer binds. - In 4.x one tensor could feed several layers, for example the same
boxestensor drawn as rectangles and as a line strip. In 5.x, declare one layer per drawing and calladd_flowfrom the producer to each layer’s port. - An image producer must emit
schema::ImageT. The 4.x operator also accepted a plainTensoror a GXFVideoBufferand inferred the image format; 5.x reads the encoding, size, color space, and plane layout from theImageTand checks them against the layer. - Each image layer declares the element type and rank that its format reads. A producer that promises an incompatible tensor fails graph compilation, and a delivered tensor that violates the requirement fails the run.
- The operator must be added to a partition explicitly.
For the full layer and port reference, see HolovizOp.
Image layers
The 4.x color input type becomes an ImageLayerDesc layer. The 4.x operator
picked a format from the tensor shape or used image_format; 5.x requires
ImageLayerDesc::format, and the frame’s encoding must match it.
The Pixel and Color Conversion operators can convert a frame to a supported format inside the graph.
Color handling is stricter:
- Each image layer declares the color space of its source in
color_space:kPassThrough(the default),kSRGBNonlinear, orkBT709Linear. A frame labeled with another color space is dropped, so a mislabeled source shows nothing instead of wrong colors. - For
kNV12andkYUYV422,yuv_modelandyuv_rangeare required. 4.x defaulted to BT.601 and full range when you did not set them. - 4.x
x_chroma_locationandy_chroma_locationhave no equivalent. 5.x reconstructs chroma at the sample center. A 4.x layer that used the defaultCOSITED_EVENcan show a half-pixel chroma shift after the port. - The 4.x image
viewslist becomes one optionalview(ViewTransform: offset and scale in normalized framebuffer units). An image layer cannot be drawn several times or with a 3D matrix.
5.x image layers accept host or CUDA memory, padded rows, and NV12 planes at any
offset. Frames may be any size up to max_width and max_height, subject to
chroma alignment: kNV12 needs an even width and height, and kYUYV422 needs
an even width but allows an odd height. The declared maximums follow the same
rules. For example, NV12 rejects 640 x 479 and YUYV422 rejects 639 x 479.
Color lookup tables
The 4.x color_lut input type and the operator-wide color_lut parameter
become a LUTLayerDesc with its own table:
- Each LUT layer has its own table of up to
kMaxLUTSize(65536) entries. In 4.x, everycolor_lutlayer shared one table. - The index tensor must be in CUDA device or managed memory. Host masks that 4.x accepted must be copied to the device first.
- Index elements can be
uint8,uint16,uint32,int8,int16,int32, orfloat32. An integer is the index, and a float is rounded down. Indexes below 0 or past the end clamp to the first or last entry. - Set
color_lut_input = trueto replace the table at run time from the graph. 4.x had no way to change the table after initialization.
2D geometry
The 4.x 2D primitive input types become a GeometryLayerDesc with one
GeometryTopology:
Coordinates are still normalized to [0, 1] with the origin at the top-left corner. Several details changed:
- Size is required. 4.x let crosses, ovals, and text omit their size and used 0.05. 5.x requires every float of every primitive.
- Oval sizes are radii. 4.x read the third and fourth values as the full width and height of the oval. 5.x reads them as radii. Halve the values when you port.
- Crosses are no longer kept square. 4.x scaled the horizontal arm by the
window aspect ratio. 5.x applies
sizein normalized units on both axes, so a cross on a wide window is wider than it is tall. - One topology per layer.
topologiesis a list, but only its first entry is drawn, and the operator logs a warning when it has more. A 4.x spec that mixed primitives across tensors becomes several layers. - Flat host coordinates. The coordinates must be a contiguous host
float32tensor with rank 1. ForNrectangles, flatten the legacy(2N, 2)corner array to(4N,), preserving the corner order. In NumPy, usenp.ascontiguousarray(box_coords, dtype=np.float32).reshape(-1). Declare rank 1 in the producer contract in either language. 4.x also drew coordinates in CUDA memory. - Fixed line width.
default_line_widthis in framebuffer pixels and is honored on every GPU. 4.x line widths depended on an optional Vulkan feature. There is nopoint_size, because there are no 2D points. - No views. A 2D geometry layer always covers the full framebuffer.
color gives every primitive in the layer one color, as in 4.x. To draw
primitives in several colors, declare one layer per color.
Text
The 4.x TEXT input type took (x, y, size) coordinates and a fixed list of
strings set at initialization. A 5.x TextLayerDesc takes the strings from
each frame instead. Its input is a host uint8 tensor of shape {N, 16 + L}:
each row is a TextRunHeader followed by up to L bytes of NUL-padded UTF-8
text.
TextRunHeader::xandyare framebuffer pixels by default. Setnormalized_coordinates = trueto keep the 4.x [0, 1] coordinates.size_pxis the glyph height in framebuffer pixels. The 4.xsizewas a fraction of the window height; multiply by the framebuffer height to convert.- Each run has its own color, packed as
0xAABBGGRR. In 4.x, one layer used one color. max_glyphsbounds the text bytes in one frame.- The built-in font is monospace and covers ASCII 32 to 127. Other bytes draw
as
?. The 4.xfont_pathparameter and its TrueType font support have no equivalent.
Windows, displays, and headless output
Exclusive display now uses the Linux DRM interface only. 4.x could take a monitor from a running X server; in 5.x, no X server or Wayland compositor may hold the GPU. See Enable exclusive display.
In 4.x, enable_render_buffer_output exposed the rendered framebuffer in
both windowed and headless applications. To migrate an application that
displays and records the same frame, render into a CudaSinkDesc and connect
output to a WindowDisplayOp and to the recorder or other consumers.
The CUDA sink output supports kR8Unorm, kR8G8B8A8Unorm, kB8G8R8A8Unorm,
their sRGB variants, kR16Unorm, and kR16G16B16A16Unorm. The deployment must
bind the output’s CUDA device with
CompileOptions::deployment.bind_tensor_output_device. When the consumer still
holds every pooled buffer, the operator drops that frame instead of waiting.
Timing
A 4.x HolovizOp ran when its conditions allowed, and every tensor named in
tensors had to be present on every call, or compute() raised an error. 5.x
replaces this with a declared trigger:
LayerTrigger(the default, layer 0) draws one frame for each sample on the named layer. Name the layer by index, by name, or by handle.ClockTriggeroffers render opportunities at a fixed period, 60 Hz by default. Input admission still decides whether an opportunity runscompute(). With a lone image layer, a stopped producer eventually exhausts themax_input_agehold and stops activations, including window-event polling. A clock trigger is not an independent window-event pump.HolovizOpOptions::max_input_age(default 100 ms) bounds how old the other layers’ samples may be. A layer with no new sample draws its last one again until it is older than this bound.
Tensor contracts and frame-content checks have different outcomes. A producer
that declares an incompatible element type, rank, or memory location is
rejected when the graph is built or compiled. A delivered tensor that violates
a port contract can end the session with kProtocolError. This applies to
image inputs, host rank-1 float32 geometry, host rank-2 uint8 text, and the
optional host rank-2 float32 color-table input.
Content checks happen after those contracts are satisfied. For example, a host rank-2 byte text tensor with rows shorter than the 16-byte header is logged and skipped for that activation; it does not end the session. The LUT mask input checks its accepted element types, shapes, and device residency inside the operator. Validate or filter samples before emission when your application needs to drop contract-invalid data and continue.
Side-layer samples must carry a genuine capture timestamp comparable to the
trigger in the graph’s clock domain. Preserve the image acquisition time on
derived overlays with EmitOptions::capture_time in C++ or
EmitOptions.capture_time in Python. Increasing max_input_age cannot make an
unstamped sample eligible.
Use depth-one, drop-oldest mailboxes for the trigger and overlay edges, as in the worked examples, so a slow display or a faster overlay producer does not build a queue of old samples. See Temporal contract.
These 4.x timing features have no equivalent:
FirstPixelOutConditionandPresentDoneCondition. No operator-level condition waits for presentation.- The
HOLOSCAN_HOLOVIZ_MUTEXmultiprocess lock and theholoviz_multiprocess_mutex_pathandmultiprocess_framedrop_waittime_msparameters.
Window events and user interface
- Closing the window. A
HolovizOpactivation that observes a window-close event requests a cooperative stop of the whole session. This replaceswindow_close_condition,window_close_scheduling_term, andinterrupt_app_on_window_close. If input admission prevents further activations, the operator cannot observe the event. Handle camera outages and application-owned shutdown throughRunSession.request_stop()or the corresponding C++ session API; a clock trigger alone does not guarantee close-button handling during a stall. - Escape key. 4.x closed the window on Escape. 5.x does so only when
WindowSinkDesc::close_on_escapeistrue. - Input callbacks.
key_callback,unicode_char_callback,mouse_button_callback,scroll_callback,cursor_pos_callback,framebuffer_size_callback,window_size_callback, andwindow_close_callbackhave no equivalent. TheHolovizOpwindow does not pass mouse or keyboard input to the application. - ImGui and custom drawing.
layer_callback, which let an application add layers or ImGui widgets inside theHolovizOpframe, has no equivalent.ImGuiOp(C++ only) shows one image stream in its own window and calls your callback to draw Dear ImGui widgets over each frame. To keep theHolovizOplayers under the widgets, renderHolovizOpinto aCudaSinkDescwithkR8G8B8A8Unormand connect itsoutputto anImGuiOp. See ImGuiOp.
The viz:: library
The 4.x holoviz module exposed an immediate-mode API: viz::Init, Begin
and End, layer calls such as ImageCudaDevice, ImageHost, LUT,
Primitive, PrimitiveCudaDevice, Text, and DepthMap, and helpers such as
ReadFramebuffer, SetCamera, GetCameraPose, SetFont, WaitForPresent,
and GetVBlankCounter.
5.x has no public replacement. The HoloViz rendering interface below the
operators installs its headers, but it is internal: it has no source or ABI
compatibility promise and can change in any release. Port custom drawing to
HolovizOp layers and the display operators. If your 4.x application relies
on a viz:: feature that the operators do not provide, please describe your use
case on the
Holoscan SDK support forum
so that the Holoscan team can consider it for a future release. See
Support and Contributing
for issue-reporting and contribution guidance.
Python
The Python operator takes typed dataclasses from
holoscan_visualization.operators instead of InputSpec dictionaries:
As in the C++ listing, graph, source, and detector are omitted setup.
The detector emits a contiguous host float32 tensor with shape (4N,) for
N rectangles and declares rank 1. Flatten a legacy coordinate array with
np.ascontiguousarray(box_coords, dtype=np.float32).reshape(-1). Pass the
source image’s acquisition time in hs.EmitOptions(capture_time=...) when
emitting the boxes, using the graph’s admitted clock domain. This lets the
side-layer selector pair the overlay with the video.
The other declarations follow the same pattern: TextLayer, LutLayer,
ViewTransform, ExclusiveDisplaySink, CudaSink, LayerTrigger, and
ClockTrigger. Pass trigger and max_input_age as keyword arguments. Callbacks have no Python equivalent, and
ImGuiOp is not available from Python.
4.x features with no 5.x equivalent
This table lists every 4.x Holoviz feature that 5.1 does not provide, with the closest alternative.
Recap
- A 4.x tensor-name
InputSpecbecomes a typed layer on aLayerStack, with its own input port and a declared maximum size. - Image producers emit
schema::ImageT, and each image layer declares its format and color space. - 2D geometry has one topology and one color per layer, host coordinates, required sizes, and oval radii instead of diameters. Points and triangles have no equivalent.
- Text strings, positions, and colors come from each frame.
- Sinks replace the window, exclusive-display, and headless parameters. The CUDA sink can feed a display and other consumers at the same time.
- Triggers and
max_input_agereplace conditions. An activation that observes a window-close event requests a cooperative session stop; input stalls can prevent that activation. - 3D geometry, depth maps, the 3D camera, callbacks, in-window ImGui, HDR,
present conditions, and the
viz::library have no 5.1 equivalent.