Jump to content

ConvertToOp

From RidgeRun Developer Wiki

🚧 Documentation is under development

The Holoscan SDK guide is currently under active development. Some sections may be incomplete or change without notice.

Questions? Contact RidgeRun or email to support@ridgerun.com.

Contents Pin





ConvertToOp

ConvertToOp scales and offsets each image value, then converts it to the chosen scalar type. It produces a new CUDA tensor while preserving image geometry and capture metadata. Use it, for example, to convert U8 pixels to floating-point values before further processing.

Numeric conversion is separate from layout conversion and channel-wise normalization.

Input arguments

Each result follows alpha × input + beta. Integral destinations use saturating conversion and the selected rounding mode. ConvertToOpParams has these defaults:

Parameter Default and Meaning
output_type kF32. VisionElementType supports U8, S8, U16, S16, S32, F32 and F64.
alpha 1.0; finite double multiplier.
beta 0.0; finite double offset.
rounding kNearest; RoundingMode also accepts kTruncate toward zero for integral results.

All four fields are CompileTime parameters, frozen for an accepted plan. Set the whole aggregate before compilation; changing the authoring handle does not update an existing run. The parameter-field default supplies that rule, and output_type is also a capacity dependency.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA device 1 OnEach HWC or NHWC image, one to four channels, using one of the supported scalar types.
output CUDA device, contiguous N/A Same activation Same geometry, batch, channel order and metadata as the input, with the configured output type.

The input must use a supported interleaved HWC or NHWC layout. The output is a new contiguous tensor on the same CUDA device.

Example

In graph composition, with graph already declared, include <holoscan/vision/convert_to_op.hpp> and configure:

auto convert = graph.op<holoscan::vision::ConvertToOp>("to-f32");
convert.set_params(holoscan::vision::ConvertToOpParams{
    .output_type = holoscan::vision::VisionElementType::kF32,
    .alpha = 1.0 / 255.0,
    .beta = 0.0,
    .rounding = holoscan::vision::RoundingMode::kNearest,
});

This configuration fragment maps U8 values 0 and 255 to F32 values 0 and 1. Connect a compatible CUDA producer to convert->input and consume convert->output. The complete pipeline linked below supplies those operators and checks, including CUDA copy outcomes and run termination.

Build

Follow Build the SDK on AGX Orin for the SDK build and installation. Link the installed holoscan::vision target in the application.


Related examples and concepts

Examples

Concepts

Source You can find the source code at ConvertToOp.

Official documentation

NVIDIA Holoscan SDK User Guide provides the official operator and application reference.


Cookies help us deliver our services. By using our services, you agree to our use of cookies.