L4T Multimedia API Reference

28.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages


This sample demonstrates how to capture images from a V4L2 YUV type of camera and share the image stream with NVIDIA® CUDA® engines to draw a black box on the upper left corner.

Building and Running


  • You have followed Steps 1-3 in Building and Running.
  • If you are building from your host Linux PC (x86), you have followed Step 4 in Building and Running.
  • You have the following hardware:
    • V4L2 Camera (USB or YUV Camera with the format YUYV/YVYU/UYVY/VYUY)
    • Display

To build:

  • Enter:
      $ cd 12_camera_v4l2_cuda
      $ make

To run

  • Enter:

      $ ./camera_v4l2_cuda -d /dev/video0 -s 1280x720 -f YUYV -c

    The -c option enables CUDA processing.

  • Or enter:

      $ ./camera_v4l2_cuda -d /dev/video0 -s 640x480 -f YUYV -n 30 -c

    The -n option saves the n-th frame before video converter processing.

To view supported options

  • Use the -h option.


The following diagram shows the flow of data through this sample.

Block Diagram

Block Diagram

Key Structure and Functions

The sample defines the structure and functions listed in the following tables.

context_tGlobal structure to save the context for V4L2 camera, CUDA and EglRenderer.

init_componentsInitializes V4L2 camera and EglRenderer.
prepare_buffersAllocates buffers for the capture_plane. Then, it shares the buffers with V4L2 Camera, CUDA, and EglRenderer.
start_streamStarts V4L2 camera streaming.
start_captureMain thread to enqueue and dequeue buffers.
stop_streamStops V4L2 camera streaming.