Requirements
Overview
This sample demonstrates four different resolutions of video capture coming out of camera sensor directly. Among these streams, three of them go through the encoding process and are saved as H.264 or H.265 file. The fourth stream provides full resolution and uses NVIDIA® TensorRT™ to perform object detection. If target object is detected, it will draw a bounding box around the object on the frame. Finally, the frame with the bounding box is rendered on the display and simultaneously encoded as an H.264 or H.265 file.
Detailed Buffer Management
Buffer Flow of the Frontend Using GIE
Key Classes and Methods
For information on libargus, see Libargus API. For information on EGLStream, see documentation on the Khronos web site.
StreamConsumer Class
Class | Description |
StreamConsumer | A base class of the libargus OutputStream consumer. It contains a dedicated thread to poll frames from Argus::OutputStream. |
The following table describes key StreamConsumer
members.
Members | Description |
setOutputStream | Sets OutputStream which be used to create the FrameConsumer. |
getSize | Gets stream resolution. |
threadInitialize | Virtual method that initializes the consumer thread. |
threadExecute | Virtual method that manages the thread loop. |
threadShutdown | Virtual method that destroys the consumer thread. |
processFrame | Virtual method that handles one frame. |
VideoEncoder Class
Class | Description |
VideoEncoder | This is a utility class to simplify the use of V4L2 video encoder. |
The following table describes key VideoEncoder
members.
Members | Description |
VideoEncoder | Constructor in which to specify resolution, output video filename, and select encoding format. |
initialize | Initialize video encoder and stream consumer. |
shutdown | Destroy resources. |
setBufferDoneCallback | Set callback to return buffer to caller. |
encodeFromFd | Feed the encoder with a new buffer. |
VideoStreamConsumer Class
Class | Description |
VideoStreamConsumer | This class is a derived class of StreamConsumer to support video encoding. It reuses the VideoEncoder object for video encoding. |
The following table describes key VideoStreamConsumer
members.
Members | Description |
VideoEncodeStreamConsumer | Constructor in which to specify the name of the consumer, output video filename and select encoding format. |
threadInitialize | Initializes the video encoder and stream consumer. |
threadShutdown | Destroys resources. |
processFrame | Receives frames and pushes them to the encoder. |
GIEStreamConsumer Class
Class | Description |
GIEStreamConsumer | This class is a derived class of StreamConsumer to support TensorRT (GIE) inference. It also has a VideoEncoder object to support video encoding. |
The following table describes key GIEStreamConsumer
members.
Members | Description |
GIEStreamConsumer | Constructor in which to specify the name of the consumer, output video filename and select encoding format. |
threadInitialize | Initializes TensorRT (GIE) context, video encoder and stream consumer. |
threadShutdown | Destroys resources. |
processFrame | Receives frames and prepares them for the TensorRT (GIE) inference. |
setDeployFile | Sets the deploy file for building the TensorRT (GIE) context. |
setModelFile | Sets the model file for building the TensorRT (GIE) context. |
RenderThreadProc | Loops to draw the bounding box, render the frame, and encode the video. |
GIEThreadProc | Loops to do the TensorRT (GIE) inference. |
Command Line Options
./frontend [OPTIONS]
Enter the following command to view the supported options.
./frontend -h
Commands
Press 'q' to exit.