1 Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 @page nvvid_backend_group 4 Ways to Video Decode with TensorRT Processing Sample
6 - [Overview](#overview)
7 - [Key Structure and Classes](#key)
8 - [Command Line Options](#options)
10 - - - - - - - - - - - - - - -
14 This use
case application showcases a typical appliance performing intelligent video analytics.
15 Application areas include
public safety, smart cities, and autonomous machines. This example demonstrates
16 four (4) concurrent video streams going through a decoding process
using the on chip decoders, video scaling
using on
17 chip scalar, and GPU compute. For simplicity of demonstration, only one of the channels will use
18 NVIDIA<sup>®</sup> TensorRT<sup>™</sup> to perform
object identification
19 and generate bounding box around the identified
object. This sample also uses video converter functions
20 to
do various format convrsions and uses EGLImage to demonstrate buffer sharing and image display capability.
22 In
this sample,
object detection is limited to identifying cars in video streams of 960 x 540 resolution,
23 running up to 14 FPS. The network is based on GoogleNet. The inference is performed on a frame-by-frame basis
24 and no
object tracking is involved. Note that
this network is intended to be purely an example to showcase
25 TensorRT usage to build the compute pipeline quickly. The trained GoogleNet is provided as source and was trained
26 using NVIDIA DIGITS with roughly 3000 frames taken from 5-10 feet elevation. Varying levels of detection accuracy are expected based on the video samples fed in. Given that
this sample is locked to perform at half-HD resolutions under 10 FPS, video feeds with higher FPS
for inference will show stuttering during playback.
28 This sample does not require a camera.
30 The image below shows a sample block diagram.
32 
34 The images below shows data flow details
for the channel
using TensorRT.
36 
38 `
NvEGLImageFromFd` is NVIDIA defined API to
return an `EGLImage` pointer form the file
39 descriptor buffer that is allocated by way of Tegra mechanism. `EGLImage` buffer is
40 then used by TensorRT to render the bounding box to the image.
42 #### Prerequisites ####
43 Before running the sample, you must have the following:
46 * TensorRT (previously known as GPU Inference Engine (GIE))
48 * README that provides details on the environment requirements to build and run the sample
50 - - - - - - - - - - - - - - -
52 ## Key Structure and Classes ##
54 The `context_t structure` (backend/v4l2_backend_test.h) manages all resources in sample applications.
58 |[
NvVideoDecoder](classNvVideoDecoder.html)|Contains all video decoding-related elements and functions.|
59 |[
NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions
for video format conversion.|
60 |
NvEglRenderer|Contains all EGL display rendering-related functions.|
61 |EGLImageKHR|The EGLImage used
for CUDA processing. This type is from the EGL open source graphical library.|
65 The [
NvVideoDecoder](classNvVideoDecoder.html)
class creates a new V4L2 Video Decoder.
66 The following table describes the key %
NvVideoDecoder members that
this sample uses.
81 ### %NvVideoConverter ###
84 converting related elements and functions. It performs color space conversion,
85 scaling and conversion between hardware buffer memory and software buffer
93 |
NvVideoConverter::waitForIdle |Waits until all the buffers queued on the output plane are converted and dequeued from the capture plane. This is a blocking method.|
98 `output_plane` and `capture_plane`. These objects are instantiated from the
103 [
NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html) creates an [NVv4l2Element](classNvV4l2Element.html) plane.
105 sample. `v4l2_buf` is a local variable inside the
NvV4l2ElementPlane::dqThreadCallback
106 function and, thus, the scope exists only inside the callback function. If other
107 functions of the sample must access this buffer, a prior copy of the buffer
108 inside callback function is required.
110 |Member |Description|
111 |-------------------|---|
115 |
NvV4l2ElementPlane::setDQThreadCallback |Sets the callback function of the `dqueue` buffer thread.|
121 |
NvV4l2ElementPlane::getNumQueuedBuffers |Gets the number of the V4l2 buffer in the queue.|
128 series of interfaces to load Caffe model and perform inference. The following
129 table describes the key %
GIE_Context members used in
this sample.
132 |-----------|-----------|
137 ### Functions to Create/Destroy EGLImage ##
139 The sample uses 2 global functions to create and destroy EGLImage from `dmabuf`
140 file descriptor. These functions are defined in nvbuf_utils.h.
142 |Global Function|Description|
143 |---------------|-----------|
147 - - - - - - - - - - - - - - -
149 ## Command Line Options ##
151 To run the sample, execute:
153 backend <channel-num> <in-file1> <in-file2>... <in-format> [options]
155 The following video formats are supported
for use with command line options:
162 Use the `-h` option to view the currently supported options.
164 For X11 technical details, see:
static NvVideoDecoder * createVideoDecoder(const char *name, int flags=0)
Creates a new V4L2 Video Decoder object named name.
void destroyGieContext(bool bUseCPUBuf=false)
Defines a helper class for V4L2 Video Decoder.
int dqEvent(struct v4l2_event &event, uint32_t max_wait_ms)
Dequeues an event from the element.
Defines a helper class for operations performed on a V4L2 Element plane.
void doInference(queue< vector< cv::Rect > > *rectList_queue, float *input=NULL)
int getNumGieInstances() const
int setCapturePlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type)
Sets the format on the converter output plane.
NvV4l2ElementPlane capture_plane
Sets the capture plane.
Class representing a buffer.
NvV4l2ElementPlane output_plane
Sets the output plane.
int setOutputPlaneFormat(uint32_t pixfmt, uint32_t sizeimage)
Sets the format on the decoder output plane.
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
int getControl(uint32_t id, int32_t &value)
Gets the value of a control.
Defines a helper class for V4L2 Video Converter.
int setCapturePlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height)
Sets the format on the decoder output plane.
int setExtControls(struct v4l2_ext_controls &ctl)
Sets the value of several controls.
int waitForIdle(uint32_t max_wait_ms)
Waits until all buffers queued on the output plane are converted and dequeued from the capture plane...
NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0.
int subscribeEvent(uint32_t type, uint32_t id, uint32_t flags)
Subscribes to an V4L2 event.
int setOutputPlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type)
Sets the format on the converter output plane.
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.