Jump to content

RawBayerToBgraOp

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.


RawBayerToBgraOp

RawBayerToBgraOp converts an RG10 Bayer frame into a display-ready CUDA BGRA image. It combines optical-black subtraction, per-frame gray-world white balance, Bayer demosaicing, display gain and gamma encoding in one CUDA processing stage.


Bayer processing
For help adapting Bayer processing to your sensor and connecting the output to a display, contact RidgeRun.


Input arguments

Argument Default and meaning
width, height Positive RG10 input dimensions.
optical_black 100; black-level value subtracted after raw decoding.
bayer_grid 1; RGGB, the pattern used by the IMX274 RG10 path. Values 0–3 select the supported Bayer layouts.
cuda_device CUDA device used by the kernels; defaults to 0.
raw_shift 0; right shift applied before the 10-bit mask.
display_gain, gamma Both default to 1.0; display scaling and gamma encoding applied to the output.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA-visible memory, contiguous SDK default OnEach U16 rank-3 tensor with shape [height, width, 1]. The valid raw sample is the lower 10-bit value after raw_shift.
output CUDA device, runtime pool N/A Same activation New U8 rank-3 tensor with shape [height, width, 4] in BGRA order.

Processing behavior

The operator first decodes and clamps the RG10 values after optical-black subtraction. It accumulates red, green and blue channel averages, calculates bounded gray-world gains, then performs local Bayer interpolation. The final kernel applies display gain and gamma and writes BGRA bytes. The output is not resized and retains the input dimensions.

V4L2UserPtrSourceOp -> RawBayerToBgraOp -> X11DisplayOp
V4L2UserPtrSourceOp -> RawBayerToBgraOp -> DrmBgraDisplayOp

The operator emits on an input-driven contract and forwards frame metadata. It is the fused Holoscan 5 replacement for the separate historical 4.5 raw-processing, demosaic and gain stages; those application-local names are not registered operators in the current RidgeRun repository.

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 raw_bayer_to_bgra/raw_bayer_to_bgra.hpp and link holoscan::raw_bayer_to_bgra.

Example

The capture source and converter must use the same dimensions and CUDA device. The repository's display applications follow this pattern:

auto camera = graph.op<V4L2UserPtrSourceOp>(
    "camera", "/dev/video0", width, height, 60, 0);
auto convert = graph.op<RawBayerToBgraOp>(
    "convert", width, height, 100, 1, 0, 0, 1.0F, 1.0F);
graph.add_flow(camera->frame, convert->input);

compile_options.deployment.bind_tensor_output_device(
    holoscan::TensorOutputDevicePlacement{
        .operator_path = "convert",
        .output_port = "output",
        .device = holoscan::DeviceId{0}});

The bayer_grid values are 0=BGGR, 1=RGGB, 2=GRBG and 3=GBRG. raw_shift is applied before extracting the ten-bit value. The corrected value is clamped after subtracting optical_black; the display scale uses the remaining range 1023 - optical_black.


Raw format assumptions
The source must provide contiguous CUDA-visible RG10 data with the configured Bayer phase. This operator does not unpack MIPI RAW10 byte packing or repair an incorrect sensor mode.


Source reference
You can find the source code at RawBayerToBgraOp.


Related pages


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