Jump to content

YuyvToBgraOp

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






Preliminary reference
This reference is preliminary. The set of available operators and HSDK applications, along with their APIs and documented behavior, may change in future releases.


YuyvToBgraOp

YuyvToBgraOp converts a packed YUYV CUDA tensor into a contiguous CUDA BGRA tensor. It is the format-conversion stage used by the RidgeRun V4L2 display path before an X11 or DRM BGRA sink.


Video format integration
Connect your camera's YUYV output to a BGRA display pipeline with custom format conversion. Contact RidgeRun for operator development and integration.


Input arguments

The constructor takes positive width and height values. Width must be even because packed YUYV represents two pixels per four-byte group.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA device, contiguous SDK default OnEach U8 tensor with shape [height, width, 2]; the last dimension contains packed YUYV bytes.
output CUDA device, runtime pool N/A Same activation New U8 tensor with shape [height, width, 4] in BGRA order.

The operator uses the execution-context CUDA stream and forwards the input sample metadata to the output.

V4L2 capture -> YuyvToBgraOp -> X11DisplayOp
V4L2 capture -> YuyvToBgraOp -> DrmBgraDisplayOp

Build

Follow Holoscan RidgeRun Build and Installation for the module build and installation. The operator-specific include, target, and runtime requirements are listed below.

Include yuyv_to_bgra/yuyv_to_bgra.hpp and link holoscan::yuyv_to_bgra.

Example

The kernel processes one YUYV pair at a time. It interprets Y0 U Y1 V using limited-range BT.601 coefficients, clamps the resulting RGB values to [0,255] and writes two opaque BGRA pixels. The conversion is a resize-free format change; width and height remain unchanged. The output is a runtime-pool Tensor and the input metadata is forwarded.

Construction rejects non-positive dimensions, odd widths and image-size overflow. Compute additionally validates the exact byte span, shape, dtype, CUDA placement and contiguity, and returns an error when the graph has no CUDA stream or the output allocation/kernel launch fails.

auto convert = graph.op<YuyvToBgraOp>("convert", width, height);
graph.add_flow(camera->frame, convert->input);
graph.add_flow(convert->output, x11_display->input);


No implicit format negotiation
The input must already be a contiguous CUDA tensor with the declared packed layout. Host input, odd widths, invalid shapes and a missing CUDA stream are rejected.


Source reference
You can find the source code at YuyvToBgraOp.


Related pages
  • DrmDisplayOp accepts YUYV directly and performs conversion inside the display operator.
  • X11DisplayOp consumes CUDA BGRA tensors.


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