base class for image caches that do computations on the fly More...
#include <Image/ImageCache.H>
Public Member Functions | |
ImageCache (uint maxSize=0) | |
Constructor. | |
virtual | ~ImageCache () |
Destructor. | |
virtual void | setMaxSize (const uint maxSize) |
Set maximum number of images in the cache. | |
virtual uint | getMaxSize () const |
Get maximum number of images in the cache. | |
virtual void | push_back (const Image< T > &img) |
add image to cache - if the cache gets to big, old images are popped off | |
virtual Image< T > | pop_front () |
pop the front Image (oldest) off the cache and return it | |
virtual const Image< T > & | back () const |
access the last Image (newest) in the queue | |
virtual const Image< T > & | front () const |
access the first Image (oldest) in the queue | |
virtual const Image< T > & | getImage (const uint lev) const |
Get image from a given level. | |
virtual const Image< T > & | operator[] (const uint lev) const |
Get image from a given level (shorthand for getImage()). | |
virtual uint | size () const |
return the current size of the cache | |
virtual bool | empty () const |
true if the cache contains no elements | |
virtual void | clear () |
clear the cache, preserving its maxSize | |
Protected Member Functions | |
virtual void | popOffOld () |
checks whether the cache has become too big and removes old entries | |
virtual void | doWhenAdd (const Image< T > &img) |
called when an image is added - override in your derived classes! | |
virtual void | doWhenRemove (const Image< T > &img) |
called when an image is removed - override in your derived classes | |
Protected Attributes | |
uint | itsMaxSize |
the maximum size of images to be stored | |
std::deque< Image< T > > | itsCache |
the cache of the images |
base class for image caches that do computations on the fly
This base class has no op doWhenAdd and doWhenRemove functions that should be overridden in classes derived from this one.
Definition at line 52 of file ImageCache.H.
ImageCache< T >::ImageCache | ( | uint | maxSize = 0 |
) | [inline] |
Constructor.
maxSize | the maximum size of the cache. If this size is exceeded, images are popped off the front of the cache and disregarded for the computation of the mean. If maxSize = 0, the cache is not limited. |
Definition at line 50 of file ImageCache.C.
ImageCache< T >::~ImageCache | ( | ) | [inline, virtual] |
Destructor.
Definition at line 56 of file ImageCache.C.
const Image< T > & ImageCache< T >::back | ( | ) | const [inline, virtual] |
access the last Image (newest) in the queue
Definition at line 109 of file ImageCache.C.
References ASSERT, and ImageCache< T >::itsCache.
Referenced by TcorrChannel::getOutput(), and FOEestimator::updateFOE().
void ImageCache< T >::clear | ( | ) | [inline, virtual] |
clear the cache, preserving its maxSize
Definition at line 148 of file ImageCache.C.
References ImageCache< T >::pop_front(), and ImageCache< T >::size().
Referenced by TaskRelevanceMapKillN::reset1().
void ImageCache< T >::doWhenAdd | ( | const Image< T > & | img | ) | [inline, protected, virtual] |
called when an image is added - override in your derived classes!
in ImageCache, this function is no op
Reimplemented in ImageCacheAvg< T >, ImageCacheMinMax< T >, ImageCacheAvg< float >, ImageCacheAvg< byte >, and ImageCacheMinMax< float >.
Definition at line 158 of file ImageCache.C.
Referenced by ImageCache< T >::push_back().
void ImageCache< T >::doWhenRemove | ( | const Image< T > & | img | ) | [inline, protected, virtual] |
called when an image is removed - override in your derived classes
in ImageCache, this function is no op
Reimplemented in ImageCacheAvg< T >, ImageCacheMinMax< T >, ImageCacheAvg< float >, ImageCacheAvg< byte >, and ImageCacheMinMax< float >.
Definition at line 163 of file ImageCache.C.
Referenced by ImageCache< T >::pop_front().
bool ImageCache< T >::empty | ( | ) | const [inline, virtual] |
true if the cache contains no elements
Definition at line 143 of file ImageCache.C.
References ImageCache< T >::itsCache.
const Image< T > & ImageCache< T >::front | ( | ) | const [inline, virtual] |
access the first Image (oldest) in the queue
Definition at line 117 of file ImageCache.C.
References ASSERT, and ImageCache< T >::itsCache.
Referenced by TcorrChannel::getOutput().
const Image< T > & ImageCache< T >::getImage | ( | const uint | lev | ) | const [inline, virtual] |
Get image from a given level.
Definition at line 125 of file ImageCache.C.
References ASSERT, and ImageCache< T >::itsCache.
Referenced by ImageCache< T >::operator[]().
uint ImageCache< T >::getMaxSize | ( | ) | const [inline, virtual] |
Get maximum number of images in the cache.
Definition at line 70 of file ImageCache.C.
References ImageCache< T >::itsMaxSize.
Referenced by TcorrChannel::doInput(), TcorrChannel::getOutput(), and TcorrChannel::outputAvailable().
const Image< T > & ImageCache< T >::operator[] | ( | const uint | lev | ) | const [inline, virtual] |
Get image from a given level (shorthand for getImage()).
Definition at line 133 of file ImageCache.C.
References ImageCache< T >::getImage().
Image< T > ImageCache< T >::pop_front | ( | ) | [inline, virtual] |
pop the front Image (oldest) off the cache and return it
Definition at line 98 of file ImageCache.C.
References ASSERT, ImageCache< T >::doWhenRemove(), and ImageCache< T >::itsCache.
Referenced by ImageCache< T >::clear(), and ImageCache< T >::popOffOld().
void ImageCache< T >::popOffOld | ( | ) | [inline, protected, virtual] |
checks whether the cache has become too big and removes old entries
Definition at line 85 of file ImageCache.C.
References ImageCache< T >::itsCache, ImageCache< T >::itsMaxSize, and ImageCache< T >::pop_front().
Referenced by ImageCache< T >::push_back(), and ImageCache< T >::setMaxSize().
void ImageCache< T >::push_back | ( | const Image< T > & | img | ) | [inline, virtual] |
add image to cache - if the cache gets to big, old images are popped off
Definition at line 75 of file ImageCache.C.
References ImageCache< T >::doWhenAdd(), ImageCache< T >::itsCache, and ImageCache< T >::popOffOld().
Referenced by TcorrChannel::doInput(), SimulationViewerCompress::getTraj(), TaskRelevanceMapKillN::integrate(), TaskRelevanceMapTigs2::integrate(), TaskRelevanceMapGistClassify::integrate(), TaskRelevanceMapTigs::integrate(), main(), and FOEestimator::updateFOE().
void ImageCache< T >::setMaxSize | ( | const uint | maxSize | ) | [inline, virtual] |
Set maximum number of images in the cache.
If the cache currently has more images than the new specified maximum, it will be truncated to that maximum.
Definition at line 61 of file ImageCache.C.
References ImageCache< T >::itsMaxSize, and ImageCache< T >::popOffOld().
Referenced by TcorrChannel::doInput(), SimulationViewerEyeHand::start1(), SimulationViewerEyeMvtNeuro::start1(), SimulationViewerCompress::start1(), TaskRelevanceMapKillN::start1(), SimulationViewerEyeMvt::start1(), TaskRelevanceMapGistClassify::TaskRelevanceMapGistClassify(), TaskRelevanceMapTigs::TaskRelevanceMapTigs(), and TaskRelevanceMapTigs2::TaskRelevanceMapTigs2().
uint ImageCache< T >::size | ( | ) | const [inline, virtual] |
return the current size of the cache
This may be smaller than the maximum size specified at construction or with setMaxSize(), if the cache is not full yet.
Definition at line 138 of file ImageCache.C.
References ImageCache< T >::itsCache.
Referenced by ImageCache< T >::clear(), TcorrChannel::getOutput(), main(), TcorrChannel::outputAvailable(), and FOEestimator::updateFOE().
std::deque< Image<T> > ImageCache< T >::itsCache [protected] |
the cache of the images
Definition at line 117 of file ImageCache.H.
Referenced by ImageCache< T >::back(), ImageCache< T >::empty(), ImageCache< T >::front(), ImageCache< T >::getImage(), ImageCacheMinMax< T >::getMax(), ImageCacheMinMax< T >::getMin(), ImageCacheAvg< T >::mean(), ImageCache< T >::pop_front(), ImageCache< T >::popOffOld(), ImageCache< T >::push_back(), and ImageCache< T >::size().
uint ImageCache< T >::itsMaxSize [protected] |
the maximum size of images to be stored
Definition at line 114 of file ImageCache.H.
Referenced by ImageCache< T >::getMaxSize(), ImageCache< T >::popOffOld(), and ImageCache< T >::setMaxSize().