Jump to content

CopyMakeBorderOp

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





CopyMakeBorderOp

CopyMakeBorderOp copies an image into a larger CUDA image and fills the added border with constants or an edge-extrapolation rule. The original pixels retain their size and position relative to one another; the operator allocates a new output and does not enlarge the input in place.

Use padding for a larger canvas or a border needed by a later stage. ResizeOp changes the size of the image content itself.

Input arguments

CopyMakeBorderOpParams separates the largest permitted output from the border to apply:

Parameter Default and Rule
max_width, max_height Each defaults to 1; positive signed 32-bit maximum output dimensions. Recompile-required and required on complete load.
max_batch_size 1; range 1–65,535. Recompile-required and required on complete load.
top, bottom, left, right Each defaults to 0; nonnegative signed 32-bit counts. CompileTime.
border_mode kConstant; BorderMode also permits replicate, reflect, wrap and reflect101. CompileTime.
border_value {0.F}; nonempty finite vector of at most four values. Use one value or one per image channel. CompileTime.

Replicate repeats the nearest edge sample; reflect includes the edge, reflect101 omits its repetition, and wrap draws from the opposite edge. Constant mode uses the fill vector. The implementation checks that vector's cardinality even for other border modes, so keep it valid.

Set the full aggregate before compilation. Neither the border widths nor the fill vector are admitted live parameters. The projected output span is max_width × max_height × max_batch_size × 4 channels × 4 bytes and must fit INT32_MAX. Setup rejects capacities too small even for a one-pixel image plus the authored border; compute checks the actual final dimensions as well.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA device 1 OnEach Interleaved HWC or NHWC image. U8 supports one to four channels; U16, S16 and F32 support one, three or four.
output CUDA device, contiguous N/A Same activation Border is added to the spatial dimensions. Type, channels, batch and capture metadata are preserved.

The resulting dimensions must fit the configured maximum width, height and batch size.

Example

For a 640 × 480 input, include <holoscan/vision/copy_make_border_op.hpp> and use this composition fragment with the existing graph:

auto border = graph.op<holoscan::vision::CopyMakeBorderOp>("border");
border.set_params(holoscan::vision::CopyMakeBorderOpParams{
    .max_width = 680,
    .max_height = 520,
    .max_batch_size = 1U,
    .top = 20,
    .bottom = 20,
    .left = 20,
    .right = 20,
    .border_mode = holoscan::vision::BorderMode::kConstant,
    .border_value = {0.F},
});

Connect the image to border->input. A three-channel HWC image yields [520,680,3], with the original content offset by (20,20). For an opaque black border around a U8 BGRA image, use four channel values {0.F,0.F,0.F,255.F}; the operator does not infer color order or the alpha range from the tensor alone.

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 CopyMakeBorderOp.

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.