Jetson Inference
DNN Vision Library
imageLoader Class Reference

Load an image or set of images from disk into GPU memory. More...

#include <imageLoader.h>

Inheritance diagram for imageLoader:
videoSource

Public Member Functions

virtual ~imageLoader ()
 Destructor. More...
 
template<typename T >
bool Capture (T **image, uint64_t timeout=UINT64_MAX)
 Load the next frame. More...
 
virtual bool Capture (void **image, imageFormat format, uint64_t timeout=UINT64_MAX)
 Load the next frame. More...
 
virtual bool Open ()
 Open the stream. More...
 
virtual void Close ()
 Close the stream. More...
 
bool IsEOS () const
 Return true if End Of Stream (EOS) has been reached. More...
 
virtual uint32_t GetType () const
 Return the interface type (imageLoader::Type) More...
 
- Public Member Functions inherited from videoSource
virtual ~videoSource ()
 Destroy interface and release all resources. More...
 
template<typename T >
bool Capture (T **image, uint64_t timeout=UINT64_MAX)
 Capture the next image from the video stream. 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...
 
uint32_t GetFrameRate () const
 Return the framerate, in Hz or FPS. More...
 
const URIGetResource () const
 Return the resource URI of the stream. More...
 
const videoOptionsGetOptions () const
 Return the videoOptions 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 imageLoaderCreate (const char *path, const videoOptions &options=videoOptions())
 Create an imageLoader instance from a path and optional videoOptions. More...
 
static imageLoaderCreate (const videoOptions &options)
 Create an imageLoader 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 videoSource
static videoSourceCreate (const videoOptions &options)
 Create videoSource interface from a videoOptions struct that's already been filled out. More...
 
static videoSourceCreate (const char *URI, const videoOptions &options=videoOptions())
 Create videoSource interface from a resource URI string and optional videoOptions. More...
 
static videoSourceCreate (const char *URI, const commandLine &cmdLine)
 Create videoSource interface from a resource URI string and parsing command line arguments. More...
 
static videoSourceCreate (const char *URI, const int argc, char **argv)
 Create videoSource interface from a resource URI string and parsing command line arguments. More...
 
static videoSourceCreate (const int argc, char **argv, int positionArg=-1)
 Create videoSource interface by parsing command line arguments, including the resource URI. More...
 
static videoSourceCreate (const commandLine &cmdLine, int positionArg=-1)
 Create videoSource interface by parsing command line arguments, including the resource URI. 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 << 4)
 Unique type identifier of imageLoader class. More...
 
static const char * SupportedExtensions []
 String array of supported image file extensions, terminated with a NULL sentinel value. More...
 

Protected Member Functions

 imageLoader (const videoOptions &options)
 
bool isLooping () const
 
- Protected Member Functions inherited from videoSource
 videoSource (const videoOptions &options)
 

Protected Attributes

bool mEOS
 
size_t mLoopCount
 
size_t mNextFile
 
std::vector< std::string > mFiles
 
std::vector< void * > mBuffers
 
- Protected Attributes inherited from videoSource
bool mStreaming
 
videoOptions mOptions
 

Detailed Description

Load an image or set of images from disk into GPU memory.

Supported image formats for loading are JPG, PNG, TGA, BMP, GIF, PSD, HDR, PIC, and PNM (PPM/PGM binary). Internally, imageLoader uses the loadImage() function to load the images, so the supported formats are the same.

imageLoader has the ability to load an sequence of images from a directory, including wildcard characters (e.g. images/*.jpg), or just a single image. When given just the path to a directory, it will load all valid images from that directory.

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

Constructor & Destructor Documentation

◆ ~imageLoader()

virtual imageLoader::~imageLoader ( )
virtual

Destructor.

◆ imageLoader()

imageLoader::imageLoader ( const videoOptions options)
protected

Member Function Documentation

◆ Capture() [1/2]

template<typename T >
bool imageLoader::Capture ( T **  image,
uint64_t  timeout = UINT64_MAX 
)
inline

Load the next frame.

See also
videoSource::Capture()

◆ Capture() [2/2]

virtual bool imageLoader::Capture ( void **  image,
imageFormat  format,
uint64_t  timeout = UINT64_MAX 
)
virtual

Load the next frame.

See also
videoSource::Capture()

Implements videoSource.

◆ Close()

virtual void imageLoader::Close ( )
virtual

Close the stream.

See also
videoSource::Close()

Reimplemented from videoSource.

◆ Create() [1/2]

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

Create an imageLoader instance from a path and optional videoOptions.

◆ Create() [2/2]

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

Create an imageLoader instance from the provided video options.

◆ GetType()

virtual uint32_t imageLoader::GetType ( ) const
inlinevirtual

Return the interface type (imageLoader::Type)

Reimplemented from videoSource.

◆ IsEOS()

bool imageLoader::IsEOS ( ) const
inline

Return true if End Of Stream (EOS) has been reached.

In the context of imageLoader, EOS means that all images in the sequence have been loaded, and looping is either disabled or all loops have already been run.

◆ isLooping()

bool imageLoader::isLooping ( ) const
inlineprotected

◆ IsSupportedExtension()

static bool imageLoader::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.

◆ Open()

virtual bool imageLoader::Open ( )
virtual

Open the stream.

See also
videoSource::Open()

Reimplemented from videoSource.

Member Data Documentation

◆ mBuffers

std::vector<void*> imageLoader::mBuffers
protected

◆ mEOS

bool imageLoader::mEOS
protected

◆ mFiles

std::vector<std::string> imageLoader::mFiles
protected

◆ mLoopCount

size_t imageLoader::mLoopCount
protected

◆ mNextFile

size_t imageLoader::mNextFile
protected

◆ SupportedExtensions

const char* imageLoader::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
  • GIF
    • PSD
  • HDR
  • PIC
  • PNM / PBM / PPM / PGM
See also
IsSupportedExtension() to check a string against this list.

◆ Type

const uint32_t imageLoader::Type = (1 << 4)
static

Unique type identifier of imageLoader class.


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