Jetson Linux API Reference

34.1 Release
camera_unit_sample (capture with libv4l2_nvargus)

Overview

The camera_sample application is a unit level implementation to demonstrate the use of libv4l2_nvargus interface for streaming.

The application reads the captured buffers for either EGL renderer to preview or dump the raw buffers into a file without any extra memory copy.


Building and Running

Prerequisites

To build

  • Enter:
     $ cd /usr/src/jetson_multimedia_api/samples/unittest_samples/camera_unit_sample
     $ make
    

To run

  • Enter:
    $ ./camera_sample [OPTIONS]
    

The captured preview stream can display over HDMI.

Example

   $ ./camera_sample -r 1920 1080 -fps 30 1

To view supported options

   $ ./camera_sample -h


Flow

The following diagram shows the flow through this sample.

  • The v4l2 libargus instance is created.
  • Capture Plane is set up.
  • External controls are set.
  • Buffers are allocated.
  • Empty buffers are queued on Capture Plane.
  • The Capture Plane transfers the frames to the application in raw YUV format.
  • The buffers are rendered and can also be written to a file.
  • For the Capture Plane the application supports MMAP and DMABUF memory type.


Key Structure and Classes

The sample uses the following key class and structures:

Element Description
Buffer Class modeled on v4l2_buffer structure.
Classes Description
class NvEGLRender The class contains elements and functions to render frames to EGL window.

NvEGLRender is the class that packages all the functions for video rendering. Key members used in the sample are as follows:

NvEGLRender Description
NvEglRenderer::render Render the FD to an EGL window.

The key structures and functions used in the sample are:

Function Description
dq_buffer Dequeues a buffer from the plane.
capture_plane_callback DQ Callback function.
q_buffer Queues a buffer on the plane.
req_buffers_on_capture_plane Request buffers on the encoder capture plane.
set_plane_format Set format on the encoder capture plane.
set_controls Set values of Argus properties and controls.