Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes | Friends

Grabber implementation to grab from files \. More...

#include <FileGrabber.h>

Inheritance diagram for icl::io::FileGrabber:
icl::io::Grabber icl::utils::Uncopyable icl::utils::Configurable

List of all members.

Public Member Functions

 FileGrabber ()
 Create a NULL FileGrabber.
 FileGrabber (const std::string &pattern, bool buffer=false, bool ignoreDesiredParams=false) throw (utils::FileNotFoundException)
 Create a file grabber with given pattern and parameters.
virtual ~FileGrabber ()
 Destructor.
virtual const core::ImgBaseacquireImage ()
 grab implementation
unsigned int getFileCount () const
 returns the count of files that are available
const std::string & getNextFileName () const
 returns the next to-be-grabbed file name
void bufferImages (bool omitExceptions=true)
 pre-buffers all images internally
void next ()
 internally skips the next to-be-grabbed image
void prev ()
 internally sets the next-image pointer back
void forcePluginType (const std::string &suffix)
 forces the filegrabber to use a plugin for the given suffix

Private Member Functions

const core::ImgBasegrabImage ()
 grab implementation called bz acquireImage().
void addProperties ()
 adds FileGrabbers properties to Configurable.
void processPropertyChange (const utils::Configurable::Property &p)
 callback function for property changes.
void updateProperties (const core::ImgBase *img)
 updates properties values.

Private Attributes

Data * m_data
utils::Mutex m_propertyMutex
bool m_updatingProperties

Friends

class FileGrabberPluginMapInitializer
 for the internal plugin concept

Detailed Description

Grabber implementation to grab from files \.

This implementation of a file grabber class provides an internally used and expendable plugin-based interface for reading files of different types.

Example

        FileGrabber g("image/image*.jpg"); //
        while(true){
          const core::ImgBase *image = g.grab();
          ...
        }

Constructor & Destructor Documentation

Create a NULL FileGrabber.

icl::io::FileGrabber::FileGrabber ( const std::string &  pattern,
bool  buffer = false,
bool  ignoreDesiredParams = false 
) throw (utils::FileNotFoundException)

Create a file grabber with given pattern and parameters.

Buffering

Images are buffered internally using the original image core::format i.e. most images are stored as icl8u images. At first during the grab(..) call, the images are converted automatically to the desired parameters (dependent on the desired params flag)

Parameters:
patternfile pattern (e.g. images/ *.jpg ...)
bufferflag to determine, whether images should be pre-buffered. If the flag is set to true, images are buffered immediately in the constructor. If exceptions that occur during this buffering procedure are not caught internally (i.e. these exceptions are thrown). This is necessary because, the FileGrabber can become inconsistent in this case, which must be reported explicitly using an exception.

To pre-buffer images in a error-tolerant way, use the constructor without a set buffer flag and call bufferImages(false) after the FileGrabber instantiation.

Parameters:
ignoreDesiredParamsIn some cases, grabbed images should not be adapted to the given parameters using a converter, but the original image parameters stored in the file header should be restored. In this case the ignoreDesiredParams flag must be set to true in the constructor or by using the setIgnoreDesiredParams(bool) function. To ensure compatibility to other grabbers, the "ignore desired params" flag is set to false by default.
virtual icl::io::FileGrabber::~FileGrabber ( ) [virtual]

Destructor.


Member Function Documentation

virtual const core::ImgBase* icl::io::FileGrabber::acquireImage ( ) [virtual]

grab implementation

Reimplemented from icl::io::Grabber.

adds FileGrabbers properties to Configurable.

void icl::io::FileGrabber::bufferImages ( bool  omitExceptions = true)

pre-buffers all images internally

This function is called automatically,if the "buffer"-flag of the constructor is set. The function internally pre-buffers all images, that are contained in the current FileList. During this procedure, some exception may occur:

  • FileNotFoundException, if a file list entry references a non-existing file
  • InvalidFileException, if no FileGrabberPlugin can be found to read files of the given core::format (determined by the file postfix e.g. ".icl" or ".ppm")
  • InvalidFileFormatException, if the FileGrabberPlugin encounters a file section with invalid contents (e.g. if a file header is corrupted, or if the file contains not enough data elements to fill an image with size determined by the file header)
  • ICLException some "not-more-specified" errors (e.g if a file could not be read due to missing permissions)

To skip these exceptions by just leaving out files that could not be read by any reason, the omitExceptions flag can be set (default). In this case, exceptions mentioned above are caught implicitly.
However if not even a single file could be read, a FileNotFoundException is thrown, to indicate, that the FileGrabber's grab/prev and next function will not work properly.

To indicate which files could be buffered, a reference to the internal file list is returned.

void icl::io::FileGrabber::forcePluginType ( const std::string &  suffix)

forces the filegrabber to use a plugin for the given suffix

suffix must be something like png or csv (without a trailing .) By default, the forced plugin type string is "". In this case, the filename suffix is evaluated to determine the appropriate grabber plugin.

unsigned int icl::io::FileGrabber::getFileCount ( ) const

returns the count of files that are available

const std::string& icl::io::FileGrabber::getNextFileName ( ) const

returns the next to-be-grabbed file name

grab implementation called bz acquireImage().

internally skips the next to-be-grabbed image

E.g. if the image directory "images/" contains 6 valid ".jpg"-files, the following code grabs all images with even indices (0,2, and 4)

          FileGrabber g("images/ *.jpg");
          for(int i=0;i<g.getFileCount()/2;++i){
            g.grab();
            g.next();
          }

internally sets the next-image pointer back

          FileGrabber g(...);
          g.grab(); // grabs image A
          g.grab(); // grabs image B
          g.prev();
          g.grab(); // again grabs image B

callback function for property changes.

Reimplemented from icl::io::Grabber.

void icl::io::FileGrabber::updateProperties ( const core::ImgBase img) [private]

updates properties values.


Friends And Related Function Documentation

friend class FileGrabberPluginMapInitializer [friend]

for the internal plugin concept


Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines