Jetson Inference
DNN Vision Library
|
The videoOutput API is for rendering and transmitting frames to video input devices such as display windows, broadcasting RTP network streams to remote hosts over UDP/IP, and saving videos/images/directories to disk. More...
#include <videoOutput.h>
Public Member Functions | |
virtual | ~videoOutput () |
Destroy interface and release all resources. More... | |
template<typename T > | |
bool | Render (T *image, uint32_t width, uint32_t height) |
Render and output the next frame to the stream. More... | |
virtual bool | Render (void *image, uint32_t width, uint32_t height, imageFormat format) |
Render and output the next frame to the stream. More... | |
virtual bool | Open () |
Begin streaming the device. More... | |
virtual void | Close () |
Stop streaming the device. More... | |
bool | IsStreaming () const |
Check if the device is actively streaming or not. More... | |
uint32_t | GetWidth () const |
Return the width of the stream, in pixels. More... | |
uint32_t | GetHeight () const |
Return the height of the stream, in pixels. More... | |
float | GetFrameRate () const |
Return the framerate, in Hz or FPS. More... | |
uint64_t | GetFrameCount () const |
Return the number of frames output. More... | |
const URI & | GetResource () const |
Return the resource URI of the stream. More... | |
const videoOptions & | GetOptions () const |
Return the videoOptions of the stream. More... | |
void | AddOutput (videoOutput *output) |
Add an output sub-stream. More... | |
uint32_t | GetNumOutputs () const |
Return the number of sub-streams. More... | |
videoOutput * | GetOutput (uint32_t index) const |
Return a sub-stream. More... | |
virtual void | SetStatus (const char *str) |
Set a status string (i.e. More... | |
virtual uint32_t | GetType () const |
Return the interface type of the stream. More... | |
bool | IsType (uint32_t type) const |
Check if this stream is of a particular type. More... | |
template<typename T > | |
bool | IsType () const |
Check if a this stream is of a particular type. More... | |
const char * | TypeToStr () const |
Convert this stream's class type to string. More... | |
Static Public Member Functions | |
static videoOutput * | Create (const videoOptions &options) |
Create videoOutput interface from a videoOptions struct that's already been filled out. More... | |
static videoOutput * | Create (const char *URI, const videoOptions &options=videoOptions()) |
Create videoOutput interface from a resource URI string and optional videoOptions. More... | |
static videoOutput * | Create (const char *URI, const commandLine &cmdLine) |
Create videoOutput interface from a resource URI string and parsing command line arguments. More... | |
static videoOutput * | Create (const char *URI, const int argc, char **argv) |
Create videoOutput interface from a resource URI string and parsing command line arguments. More... | |
static videoOutput * | Create (const int argc, char **argv, int positionArg=-1) |
Create videoOutput interface by parsing command line arguments, including the resource URI. More... | |
static videoOutput * | Create (const commandLine &cmdLine, int positionArg=-1) |
Create videoOutput interface by parsing command line arguments, including the resource URI. More... | |
static videoOutput * | CreateNullOutput () |
Create videoOutput interface that acts as a NULL output and does nothing with incoming frames. More... | |
static const char * | Usage () |
Usage string for command line arguments to Create() More... | |
static const char * | TypeToStr (uint32_t type) |
Convert a class type to a string. More... | |
Protected Member Functions | |
videoOutput (const videoOptions &options) | |
Protected Attributes | |
bool | mStreaming |
videoOptions | mOptions |
std::vector< videoOutput * > | mOutputs |
The videoOutput API is for rendering and transmitting frames to video input devices such as display windows, broadcasting RTP network streams to remote hosts over UDP/IP, and saving videos/images/directories to disk.
videoOutput interfaces are implemented by glDisplay, gstEncoder, and imageWriter.
The specific implementation is selected at runtime based on the type of resource URI. An instance can have multiple sub-streams, for example simultaneously outputting to a display and encoded video on disk or RTP stream.
videoOutput supports the following protocols and resource URI's:
- `display://0` for rendering to display using OpenGL, where `0` corresponds to the display number. By default, an OpenGL window will be created, unless the `--headless` command line option is used. - `rtp://<remote-host>:1234` to broadcast a compressed RTP stream to a remote host, where you should substitute `<remote-host>` with the remote host's IP address or hostname, and `1234` is the port. - `rtsp://@:8554/my_stream` to serve a compressed RTSP stream at the specified port and stream path. RTSP clients can connect to the stream at the specified path. Using this will create a RTSP server that can handle multiple videoOutput streams on the same port but with different paths (e.g. `rtsp://<hostname>:8554/my_stream_1`, `rtsp://<hostname>:8554/my_stream_2`, ect) - `webrtc://@:1234/my_stream` to serve a compressed WebRTC stream at the specified port and path that browsers can connect to and view. Users will be able to navigate their browser to `http://<hostname>:1234/my_stream` and view a rudimentary video player that plays the stream. More advanced web front-ends can be created by using standard client-side Javascript WebRTC APIs. - `file:///home/user/my_video.mp4` for saving videos, images, and directories of images to disk. You can leave off the `file://` protocol identifier and it will be deduced from the path. It can be a relative or absolute path. You can output a sequence of images using a path of the form `my_dir/image_%i.jpg` (where `%i` can include printf-style modifiers like `%03i`). The `%i` will be replaced with the image number in the sequence. If just a directory is specified, then by default it will create a sequence of the form `%i.jpg` in that directory. Supported video formats for saving include MKV, MP4, AVI, and FLV. Supported codecs for encoding include H.264, H.265, VP8, VP9, and MJPEG. Supported image formats for saving include JPG, PNG, TGA, and BMP.
|
virtual |
Destroy interface and release all resources.
|
protected |
|
inline |
Add an output sub-stream.
When a frame is rendered to this stream, it will be rendered to each sub-stream.
|
virtual |
Stop streaming the device.
Reimplemented in gstEncoder.
|
static |
Create videoOutput interface from a resource URI string and parsing command line arguments.
|
static |
Create videoOutput interface from a resource URI string and parsing command line arguments.
|
static |
Create videoOutput interface from a resource URI string and optional videoOptions.
|
static |
Create videoOutput interface by parsing command line arguments, including the resource URI.
positionArg | indicates the positional argument number in the command line of the resource URI (or -1 if a positional argument isn't used, and should instead be parsed from the --input= option). |
|
static |
Create videoOutput interface by parsing command line arguments, including the resource URI.
positionArg | indicates the positional argument number in the command line of the resource URI (or -1 if a positional argument isn't used, and should instead be parsed from the --input= option). |
|
static |
Create videoOutput interface from a videoOptions struct that's already been filled out.
It's expected that the supplied videoOptions already contain a valid resource URI.
|
static |
Create videoOutput interface that acts as a NULL output and does nothing with incoming frames.
CreateNullOutput() can be used when there are no other outputs created and programs expect one to run.
|
inline |
Return the number of frames output.
|
inline |
Return the framerate, in Hz or FPS.
|
inline |
Return the height of the stream, in pixels.
|
inline |
Return the number of sub-streams.
|
inline |
Return the videoOptions of the stream.
|
inline |
Return a sub-stream.
|
inlinevirtual |
Return the interface type of the stream.
This could be one of the following values:
Reimplemented in glDisplay, gstEncoder, and imageWriter.
|
inline |
Return the width of the stream, in pixels.
|
inline |
Check if the device is actively streaming or not.
true
if the device is streaming (open), or false
if it's closed or has reached EOS (End Of Stream).
|
inline |
Check if a this stream is of a particular type.
Can be used with glDisplay, gstEncoder, and imageWriter. For example:
if( stream->IsType<glDisplay>() ) glDisplay* display = (glDisplay*)stream; // safe to cast
|
inline |
Check if this stream is of a particular type.
|
virtual |
Begin streaming the device.
After Open() is called, frames from the device can begin to be rendered.
Open() is not stricly necessary to call, if you call one of the Render() functions they will first check to make sure that the stream is opened, and if not they will open it automatically for you.
true
on success, false
if an error occurred opening the stream. Reimplemented in gstEncoder, and glDisplay.
|
inline |
Render and output the next frame to the stream.
The image formats supported by this templated version of Render() include the following:
IMAGE_RGB8
)IMAGE_RGBA8
)IMAGE_RGB32F
)IMAGE_RGBA32F
)The image format will automatically be deduced from these types. If other types are used with this overload, a static compile-time error will be asserted.
image | CUDA pointer containing the image to output. |
width | width of the image, in pixels. |
height | height of the image, in pixels. |
true
on success, false
on error.
|
virtual |
Render and output the next frame to the stream.
The image formats supported by Render() are IMAGE_RGB8
(uchar3), IMAGE_RGBA8
(uchar4), IMAGE_RGB32F
(float3), and IMAGE_RGBA32F
(float4).
image | CUDA pointer containing the image to output. |
width | width of the image, in pixels. |
height | height of the image, in pixels. |
format | format of the image ( |
true
on success, false
on error. Reimplemented in glDisplay, gstEncoder, and imageWriter.
|
virtual |
Set a status string (i.e.
status bar text on display window). Other types of interfaces may ignore the status text.
Reimplemented in glDisplay.
|
inline |
Convert this stream's class type to string.
|
static |
Convert a class type to a string.
|
inlinestatic |
Usage string for command line arguments to Create()
|
protected |
|
protected |
|
protected |