Jetson Inference
DNN Vision Library
|
Resource URI of a video device, IP stream, or file/directory. More...
#include <URI.h>
Public Member Functions | |
URI () | |
Default constructor. More... | |
URI (const char *uri) | |
Construct a new URI from the given resource string. More... | |
bool | Parse (const char *uri) |
Parse the URI from the given resource string. More... | |
void | Print (const char *prefix="") const |
Log the URI, with an optional prefix label. More... | |
const char * | c_str () const |
Cast to C-style string (const char* ) More... | |
operator const char * () const | |
Cast to C-style string (const char* ) More... | |
operator std::string () const | |
Cast to std::string More... | |
void | operator= (const char *uri) |
Assignment operator (parse URI string) More... | |
void | operator= (const std::string &uri) |
Assignment operator (parse URI string) More... | |
Public Attributes | |
std::string | string |
Full resource URI (what was originally parsed) More... | |
std::string | protocol |
Protocol string (e.g. More... | |
std::string | path |
Path (for a network URI this comes after the port) More... | |
std::string | extension |
File extension (for files only, otherwise empty) More... | |
std::string | location |
Path, IP address, or device name. More... | |
int | port |
IP port, camera port, ect. More... | |
Resource URI of a video device, IP stream, or file/directory.
The URI object is used by videoSource, videoOutput, and videoOptions to identify which resource is being streamed. It will parse a string into protocol, path, and port/extension components.
URI protocols for videoSource input streams include MIPI CSI cameras (csi://
), V4L2 cameras (v4l2://
), RTP/RTSP networking streams (rtp://
and rtsp://
), and disk-based videos/images/directories (file://
)
- `csi://0` for MIPI CSI cameras, where `0` can be replaced with the camera port. It is also assumed that if a number with no protocol is specified (e.g. `"0"`), this means to use the MIPI CSI camera of that number (`"0"` -> `csi://0`) - `v4l2:///dev/video0` for V4L2 cameras, where `/dev/video0` can be replaced with a different video device (e.g. `v4l2:///dev/video1` for V4L2 video device `1`). If no protocol is specified but the string begins with `/dev/video`, then it is assumed that the protocol is V4L2 (`/dev/video0` -> `v4l2:///dev/video0`) - `rtp://@:1234` to recieve an RTP network stream, where `1234` is the port and `@` is shorthand for localhost. `@` can also be substituted for the IP address of a multicast group. Note that it is important to manually specify the codec and width/height when using RTP, as these values cannot be discovered from the RTP stream itself and need to be provided. @see videoOptions for more info about `--input-codec`, `--input-width`, and `--input-height`. - `rtsp://username:password@<remote-host>:1234` to subscribe to an RTSP network stream, where `<remote-host>` should be substituted for the remote host's IP address or hostname, and `1234` is the port. For example, `rtsp://192.168.1.2:5000`. The `username` and `password` are optional, and are only used for RTSP streams that require authentication. - `file:///home/user/my_video.mp4` for disk-based videos, images, and directories of images. You can leave off the `file://` protocol identifier and it will be deduced from the path. It can be a relative or absolute path. If a directory is specified that contains images, those images will be loaded in sequence (sorted alphanumerically). The path can also contain wildcard characters, for example `"images/*.jpg"` - however when using wildcards from the command line, enclose the string in quotes otherwise the OS will pre-expand them. Supported video formats for loading include MKV, MP4, AVI, and FLV. Supported codecs for decoding include H.264, H.265, VP8, VP9, MPEG-2, MPEG-4, and MJPEG. Supported image formats for loading include JPG, PNG, TGA, BMP, GIF, PSD, HDR, PIC, and PNM (PPM/PGM binary).
URI protocols for videoOutput streams include rendering to displays (display://
), broadcasting RTP/RTSP streams (rtp://
, rtsp://
), WebRTC streams (webrtc://
), and saving videos/images to disk (file://
)
- `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.
The URI strings used should take one of the above forms for input/output streams to be parsed correctly.
URI::URI | ( | ) |
Default constructor.
URI::URI | ( | const char * | uri | ) |
|
inline |
Cast to C-style string (const char*
)
|
inline |
Cast to C-style string (const char*
)
|
inline |
Cast to std::string
|
inline |
Assignment operator (parse URI string)
|
inline |
Assignment operator (parse URI string)
bool URI::Parse | ( | const char * | uri | ) |
std::string URI::extension |
File extension (for files only, otherwise empty)
std::string URI::location |
Path, IP address, or device name.
std::string URI::path |
Path (for a network URI this comes after the port)
int URI::port |
IP port, camera port, ect.
std::string URI::protocol |
Protocol string (e.g.
file
, csi
, v4l2
, rtp
, ect)
std::string URI::string |
Full resource URI (what was originally parsed)