Jump to content

CustomCropOp

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





CustomCropOp

CustomCropOp copies a configured rectangular region into a new CUDA tensor, preserving the selected pixel values, scalar type, channel order, and capture metadata. It removes a fixed margin or isolates an area of interest without interpolation.

The result has its own runtime-pool storage. Cropping here does not expose a borrowed view of the input allocation.

Input arguments

CustomCropOpParams describes [x,x+width) × [y,y+height):

Parameter Default and Rule
x, y Each defaults to 0; nonnegative signed 32-bit coordinates. CompileTime fields.
width, height Each defaults to 1; positive signed 32-bit dimensions. Recompile-required.
max_batch_size 1; range 1–65,535. Recompile-required and required on a complete parameter load.

The rectangle validator checks containment using widened arithmetic. A crop extending outside the image is rejected; the operator does not pad or clamp. Author the complete aggregate before compilation; changing x or y is not a live update simply because those fields are not marked recompile-required.

The output-span projection is width × height × max_batch_size × 4 channels × 8 bytes, covering the supported maximum element size. It must fit INT32_MAX. This conservative declared bound is distinct from the bytes in a particular cropped image.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA device 1 OnEach Interleaved HWC or NHWC image with one to four channels and a supported scalar type.
output CUDA device, contiguous N/A Same activation Cropped to the configured width and height. Batch and capture metadata are preserved.

The crop and batch dimensions must fit the configured bounds.

Example

In graph composition, include <holoscan/vision/custom_crop_op.hpp>. With graph already declared:

auto crop = graph.op<holoscan::vision::CustomCropOp>("crop");
crop.set_params(holoscan::vision::CustomCropOpParams{
    .x = 80,
    .y = 40,
    .width = 640,
    .height = 480,
    .max_batch_size = 1U,
});

The source image must be at least 720 pixels wide and 520 pixels high. Connect it to crop->input; the result on crop->output contains the 640 × 480 rectangle beginning at (80,40). A three-channel HWC input yields [480,640,3].

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

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.