Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
drwnImagePyramidCache Class Reference

Caches image pyramids in main memory up to a maximum number of images or memory limit. More...

Public Member Functions

 drwnImagePyramidCache (double downSampleRate=0.5, int minSize=32, int maxLevels=DRWN_INT_MAX, bool bGreyImages=GREY_IMAGES, bool bBigMemory=BIG_MEMORY)
 constructor
 
 drwnImagePyramidCache (const vector< string > &filenames, double downSampleRate=0.5, int minSize=32, int maxLevels=DRWN_INT_MAX, bool bGreyImages=GREY_IMAGES, bool bBigMemory=BIG_MEMORY)
 constructor with filename initialization
 
 ~drwnImagePyramidCache ()
 destructor
 
void initialize (const vector< string > &filenames)
 initializes the cache with a list of filenames (cache must be clear)
 
void append (const string &filename)
 adds a filename to the list of filenames managed by the cache
 
void clear ()
 Clear all images from the cache (cannot be called if some images are still locked). Does nothing if in big memory mode.
 
bool empty () const
 returns true if the cache is empty (but may still be initialized with filenames)
 
size_t size () const
 returns number of image pyramids stored in the cache
 
size_t numLocked () const
 returns number of locked image pyramids in the cache
 
size_t memory () const
 returns memory used by in-memory image pyramids
 
const string & filename (unsigned indx) const
 return the filename for image indx
 
int index (const string &filename) const
 returns the index for filename (slow)
 
void lock (unsigned indx)
 lock an image pyramid for use (loads if not already in the cache)
 
void lock (const string &filename)
 lock an image pyramid for use (loads if not already in the cache)
 
size_t levels (unsigned indx) const
 returns the number of levels in an image pyramid (which must first be locked)
 
size_t levels (const string &filename) const
 returns the number of levels in an image pyramid (which must first be locked)
 
const cv::Mat & get (unsigned indx, unsigned level=0) const
 returns an image (which must first be locked)
 
const cv::Mat & get (const string &filename, unsigned level=0) const
 returns an image (which must first be locked)
 
void unlock (unsigned indx)
 marks an image as free
 
void unlock (const string &filename)
 marks an image as free
 
cv::Mat copy (unsigned indx, unsigned level=0)
 copies an image without locking it (caller must free the image)
 
cv::Mat copy (const string &filename, unsigned level=0)
 copies an image without locking it (caller must free the image)
 

Static Public Attributes

static size_t MAX_IMAGES = 10000
 maximum number of images in memory at any one time
 
static size_t MAX_MEMORY = 500000000
 maximum number of bytes used at any one time
 
static bool GREY_IMAGES = false
 default setting for caching images in greyscale
 
static bool BIG_MEMORY = false
 default setting for big memory mode
 

Protected Member Functions

void enforceLimits ()
 checks memory and count limits and frees images if exceeded
 
size_t memory (const vector< cv::Mat > &images) const
 compute memory used by image pyramid
 
vector< cv::Mat > load (const string &filename) const
 loads an image pyramid
 

Protected Attributes

vector< string > _filenames
 image filenames
 
vector< vector< cv::Mat > > _images
 image pyramids
 
vector< list< unsigned >
::iterator > 
_free_list_map
 ref to location in _free_list
 
vector< unsigned > _lock_counter
 allows for multiple locks
 
list< unsigned > _free_list
 index of images that can be safely released in least-recently-used order
 
bool _bGreyImages
 store images in greyscale (instead of RGB)
 
bool _bBigMemoryModel
 load all images into memory (ignores MAX_IMAGES and MAX_MEMORY)
 
size_t _imagesLoaded
 number of images loaded
 
size_t _memoryUsed
 bytes used by loaded images
 
double _downSampleRate
 downsampling rate
 
int _minImageSize
 minimum image dimension
 
int _maxLevels
 maximum pyramid height
 
unsigned _dbImagesLocked
 
unsigned _dbImagesLoaded
 
size_t _dbMaxMemUsed
 

Detailed Description

Caches image pyramids in main memory up to a maximum number of images or memory limit.

See Also
drwnImageCache.

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