ReformatOp
🚧 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.
-
Overview
-
Build, Run, and Validate
-
Core Concepts
-
Operators and Graphs
-
Tensor Data and Memory
-
Interprocess Communication
-
-
Application and Operator Development
- Building an HSDK Application
- Writing a Minimal Operator
- Typed Parameters and Configuration
- Reading, Writing, and Forwarding Data
- Writing Tensor Operators
- Complete Operator Patterns
- Authoring Runtime Behavior
- Runtime Parameter Updates
- Lifecycle Callbacks and Restart Control
- Performance and Debugging
- SDK Source Map
-
Operator Reference
-
Core Operators
-
Holoscan Camera
-
Holoscan RidgeRun
- Overview
- Build and Installation
- ArgusCameraOp
- V4L2SourceOp
- V4L2UserPtrSourceOp
- BgraToPlanarTensorOp
- RawBayerToBgraOp
- RawBayerToYoloTensorOp
- YuyvToBgraOp
- TensorRtInferenceOp
- DrmDisplayOp
- DrmBgraDisplayOp
- X11DisplayOp
- CudaCompositorOp
- DepthColorizerOp
- FakesinkOp
- FrameSkipperOp
- InterprocessSrcOp
- TestPatternOp
-
-
Migration from Holoscan 4.x
-
Examples
-
Core
-
Holoscan Camera
-
Holoscan RidgeRun
-
-
Benchmark and Use Cases
-
Holoscan vs GStreamer
- Overview
-
Capture and Display
-
Capture and Inference
- Compare the workloads
- Implemented Applications
- Framework Selection
- Interprocess
-
ReformatOp
ReformatOp converts CUDA image storage between interleaved HWC/NHWC and planar CHW/NCHW layouts. It produces a new contiguous tensor with the same image dimensions, channel count, scalar type, and capture metadata.
Layout describes where the channel values are stored. A BGR image remains BGR; changing the layout does not swap channels, normalize values, or convert the numeric type.
Input arguments
ReformatOpParams has one field, mode, defaulting to kInterleavedToPlanar. Its ReformatMode choices are:
| Mode | Shape Transformation |
|---|---|
kInterleavedToPlanar
|
[H,W,C] → [C,H,W]; [N,H,W,C] → [N,C,H,W].
|
kPlanarToInterleaved
|
[C,H,W] → [H,W,C]; [N,C,H,W] → [N,H,W,C].
|
The field is CompileTime, frozen for one accepted plan. Configure it before compilation and compile a new plan to change direction. It is not marked as an admitted runtime-mutable field. Output capacity follows the connected input's finite byte bound. The operator has no separate image-capacity constructor.
Ports and data contract
| Port | Memory | Queue | Trigger | Contract |
|---|---|---|---|---|
input
|
CUDA device | 1 | OnEach
|
Rank-three or rank-four image using a supported scalar type and the configured interleaved or planar layout. |
output
|
CUDA device | N/A | Same activation | Same image data in the requested layout. Capture metadata is preserved. |
The layout and direction are configured explicitly. Interleaved channels and planar pixels must be packed as required by the selected layout.
Example
With graph already declared and <holoscan/vision/reformat_op.hpp> included:
auto reformat = graph.op<holoscan::vision::ReformatOp>("to-planar");
reformat.set_params(holoscan::vision::ReformatOpParams{
.mode = holoscan::vision::ReformatMode::kInterleavedToPlanar,
});
An HWC [2,2,3] result becomes CHW [3,2,2]. The first output plane contains the first channel's four pixels, then the second and third planes follow. Connect the interleaved CUDA result to reformat->input; its output is suitable only for a consumer that accepts the resulting planar representation.
For the reverse direction, set kPlanarToInterleaved and supply CHW/NCHW input. Reformat changes storage order through GPU work; it is not a metadata-only view.
Build
Follow Build the SDK on AGX Orin for the SDK build and installation. Link the installed holoscan::vision target in the application.