This sample demonstrates video capture for four video streams coming directly from camera sensors, where the streams have different resolutions. Three of the streams go through the encoding process and are saved as H.264 or H.265 files. 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.
$ sudo vi /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
Change the repository name and download URL in the deb commands shown below:
deb https://repo.download.nvidia.com/jetson/common <release> main deb https://repo.download.nvidia.com/jetson/<platform> <release> main
<release>> is the release number. Ex: r32.5.
<platform> identifies the platform's processor.
$ sudo apt-get update $ sudo apt-get install tensorrt
ENABLE_TRT := 1
$ cd frontend $ make
$ ./frontend --deploy ../../data/Model/GoogleNet_three_class/GoogleNet_modified_threeClass_VGA.prototxt \ --model ../../data/Model/GoogleNet_three_class/GoogleNet_modified_threeClass_VGA.caffemodel \ --no-preview
q
.$ cd frontend $ ./frontend -h
The following diagrams illustrate the flow of data through this sample.
$ ./frontend --deploy ../../data/Model/GoogleNet_three_class/GoogleNet_modified_threeClass_VGA.prototxt \ --model ../../data/Model/GoogleNet_three_class/GoogleNet_modified_threeClass_VGA.caffemodel
For information on libargus, see Libargus Camera API. For information on EGLStream, see documentation on the Khronos web site.
The sample defines StreamConsumer
as an abstracted class. It is not imported from other libraries.
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. |
The sample defines VideoEncoder
as an abstracted class. It is not imported from other libraries.
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. |
The sample defines VideoStreamConsumer
as an abstracted class. It is not imported from other libraries.
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. |
The sample defines TRTStreamConsumer
as an abstracted class. It is not imported from other libraries.
Class | Description |
---|---|
TRTStreamConsumer | 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 TRTStreamConsumer
members.
Members | Description |
---|---|
TRTStreamConsumer | Constructor in which to specify the name of the consumer, output video filename and select encoding format. |
threadInitialize | Initializes TensorRT context, video encoder and stream consumer. |
threadShutdown | Destroys resources. |
processFrame | Receives frames and prepares them for the TensorRT inference. |
setDeployFile | Sets the deploy file for building the TensorRT context. |
setModelFile | Sets the model file for building the TensorRT context. |
RenderThreadProc | Loops to draw the bounding box, render the frame, and encode the video. |
TRTThreadProc | Loops to do the TensorRT inference. |