Jump to content

V4L2SourceOp

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.


V4L2SourceOp

V4L2SourceOp captures an exact single-plane RG10 Bayer mode from a Linux V4L2 device using driver-owned MMAP buffers. Each dequeued frame is copied row by row into a plan-owned CUDA tensor before the driver buffer is requeued.


Camera integration
Contact RidgeRun for V4L2 camera integration. We can adapt capture operators and assess frame transfers into CUDA.


Input arguments

Argument Meaning
device V4L2 device path, for example /dev/video0.
width, height Required RG10 capture dimensions.
fps Requested capture rate; defaults to 30.
frame_limit Optional shared frame limit used by the demonstration applications.

Ports and data contract

Port Memory Queue Trigger Contract
frame CUDA device, runtime-owned N/A OnClock at fps U16 tensor with shape [height, width, 1] containing unpacked RG10 values.
V4L2SourceOp -> RawBayerToBgraOp -> X11DisplayOp or DrmBgraDisplayOp

The source negotiates the requested single-plane RG10 mode and does not emit a frame when the captured buffer is invalid.

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 v4l2_source/v4l2_source.hpp and link holoscan::v4l2_source. The camera driver must support single-plane VIDEO_CAPTURE, streaming I/O and V4L2_PIX_FMT_SRGGB10.

Example

The output is a CUDA Tensor, so applications bind the source port to a CUDA device during compilation:

auto camera = graph.op<V4L2SourceOp>(
    "camera", "/dev/video0", 1920, 1080, 60);
auto convert = graph.op<RawBayerToBgraOp>("convert", 1920, 1080);
graph.add_flow(camera->frame, convert->input);

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

At startup the source negotiates format and frame interval, requests driver-owned MMAP buffers, maps them and starts streaming. Each clock activation dequeues one buffer. The implementation copies rows with cudaMemcpy2DAsync, synchronizes before returning the buffer to V4L2, derives a capture timestamp when the driver timestamp is usable, emits the frame and requeues the buffer. A damaged buffer, unavailable frame, incompatible stride or failed requeue is reported or dropped without publishing an invalid image.

The optional frame limit counts successfully emitted frames. stop() performs STREAMOFF, unmaps all buffers and releases the V4L2 request. This operator is kept for the repository's early demonstration path; use V4L2UserPtrSourceOp when the application needs the CUDA-mapped USERPTR memory model.


Source reference
You can find the source code at V4L2SourceOp.


Related pages


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