Jetson Inference
DNN Vision Library
imageWriter Class Reference

Save an image or set of images to disk. More...

#include <imageWriter.h>

Inheritance diagram for imageWriter:
videoOutput

Public Member Functions

virtual ~imageWriter ()
 Destructor. More...
 
template<typename T >
bool Render (T *image, uint32_t width, uint32_t height)
 Save the next frame. More...
 
virtual bool Render (void *image, uint32_t width, uint32_t height, imageFormat format)
 Save the next frame. More...
 
virtual uint32_t GetType () const
 Return the interface type (imageWriter::Type) More...
 
- Public Member Functions inherited from videoOutput
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 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 URIGetResource () const
 Return the resource URI of the stream. More...
 
const videoOptionsGetOptions () 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...
 
videoOutputGetOutput (uint32_t index) const
 Return a sub-stream. More...
 
virtual void SetStatus (const char *str)
 Set a status string (i.e. 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 imageWriterCreate (const char *path, const videoOptions &options=videoOptions())
 Create an imageWriter instance from a path and optional videoOptions. More...
 
static imageWriterCreate (const videoOptions &options)
 Create an imageWriter instance from the provided video options. More...
 
static bool IsSupportedExtension (const char *ext)
 Return true if the extension is in the list of SupportedExtensions. More...
 
- Static Public Member Functions inherited from videoOutput
static videoOutputCreate (const videoOptions &options)
 Create videoOutput interface from a videoOptions struct that's already been filled out. More...
 
static videoOutputCreate (const char *URI, const videoOptions &options=videoOptions())
 Create videoOutput interface from a resource URI string and optional videoOptions. More...
 
static videoOutputCreate (const char *URI, const commandLine &cmdLine)
 Create videoOutput interface from a resource URI string and parsing command line arguments. More...
 
static videoOutputCreate (const char *URI, const int argc, char **argv)
 Create videoOutput interface from a resource URI string and parsing command line arguments. More...
 
static videoOutputCreate (const int argc, char **argv, int positionArg=-1)
 Create videoOutput interface by parsing command line arguments, including the resource URI. More...
 
static videoOutputCreate (const commandLine &cmdLine, int positionArg=-1)
 Create videoOutput interface by parsing command line arguments, including the resource URI. More...
 
static videoOutputCreateNullOutput ()
 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...
 

Static Public Attributes

static const uint32_t Type = (1 << 5)
 Unique type identifier of imageWriter class. More...
 
static const char * SupportedExtensions []
 String array of supported image file extensions, terminated with a NULL sentinel value. More...
 

Protected Member Functions

 imageWriter (const videoOptions &options)
 
- Protected Member Functions inherited from videoOutput
 videoOutput (const videoOptions &options)
 

Protected Attributes

uint32_t mFileCount
 
char mFileOut [1024]
 
- Protected Attributes inherited from videoOutput
bool mStreaming
 
videoOptions mOptions
 
std::vector< videoOutput * > mOutputs
 

Detailed Description

Save an image or set of images to disk.

Supported image formats for saving are JPG, PNG, TGA, and BMP. Internally, imageLoader uses the saveImage() function to save the images, so the supported formats are the same.

imageWriter has the ability to write a sequence of images to a directory, for example images/i.jpg (where i becomes the image number), or just a single image with a static filename (e.g. images/my_image.jpg). When given just the path of a directory as output, it will default to incremental i.jpg sequencing and save in JPG format.

Note
imageWriter implements the videoOutput interface and is intended to be used through that as opposed to directly. videoOutput implements additional command-line parsing of videoOptions to construct instances.
See also
videoOutput

Constructor & Destructor Documentation

◆ ~imageWriter()

virtual imageWriter::~imageWriter ( )
virtual

Destructor.

◆ imageWriter()

imageWriter::imageWriter ( const videoOptions options)
protected

Member Function Documentation

◆ Create() [1/2]

static imageWriter* imageWriter::Create ( const char *  path,
const videoOptions options = videoOptions() 
)
static

Create an imageWriter instance from a path and optional videoOptions.

◆ Create() [2/2]

static imageWriter* imageWriter::Create ( const videoOptions options)
static

Create an imageWriter instance from the provided video options.

◆ GetType()

virtual uint32_t imageWriter::GetType ( ) const
inlinevirtual

Return the interface type (imageWriter::Type)

Reimplemented from videoOutput.

◆ IsSupportedExtension()

static bool imageWriter::IsSupportedExtension ( const char *  ext)
static

Return true if the extension is in the list of SupportedExtensions.

Parameters
extstring containing the extension to be checked (should not contain leading dot)
See also
SupportedExtensions for the list of supported Video Streaming file extensions.

◆ Render() [1/2]

template<typename T >
bool imageWriter::Render ( T *  image,
uint32_t  width,
uint32_t  height 
)
inline

Save the next frame.

See also
videoOutput::Render()

◆ Render() [2/2]

virtual bool imageWriter::Render ( void *  image,
uint32_t  width,
uint32_t  height,
imageFormat  format 
)
virtual

Save the next frame.

See also
videoOutput::Render()

Reimplemented from videoOutput.

Member Data Documentation

◆ mFileCount

uint32_t imageWriter::mFileCount
protected

◆ mFileOut

char imageWriter::mFileOut[1024]
protected

◆ SupportedExtensions

const char* imageWriter::SupportedExtensions[]
static

String array of supported image file extensions, terminated with a NULL sentinel value.

The supported extension are:

  • JPG / JPEG
  • PNG
  • TGA / TARGA
  • BMP
See also
IsSupportedExtension() to check a string against this list.

◆ Type

const uint32_t imageWriter::Type = (1 << 5)
static

Unique type identifier of imageWriter class.


The documentation for this class was generated from the following file: