Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

FileSystemImageSource.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_FileSystemImageSource_h_
00003 #define INCLUDED_FileSystemImageSource_h_
00004 
00005 #include "FileSystemDataSource.h"
00006 
00007 //! Extends FileSystemDataSource to decompress image data
00008 class FileSystemImageSource : public FileSystemDataSource {
00009 public:
00010   //! constructor
00011   FileSystemImageSource(LoggedDataDriver& p, const std::string& filter)
00012     : FileSystemDataSource(p,filter), layer(0), frameNumber(0)
00013   {
00014     addEntry("Layer",layer,"Controls the resolution layer at which the image should be processed.\n0 indicates \"automatic\" mode (picks layer closest to image's resolution), positive numbers indicate the resolution layer directly.\nNegative values are relative to the number of layers marked available by the vision setup, so that typically -1 would correspond to the \"double\" layer, and -2 would correspond to the \"full\" layer.");
00015   }
00016 
00017   //! Controls the resolution layer at which the image should be processed
00018   /*! 0 indicates "automatic" mode (picks layer closest to image's resolution), positive
00019    *  numbers indicate the resolution layer directly.
00020    *  
00021    *  Negative values are relative to the number of layers marked available by the
00022    *  vision setup, so that typically -1 would correspond to the "double" layer, and -2
00023    *  would correspond to the "full" layer. */
00024   plist::Primitive<int> layer;
00025 
00026 protected:
00027   
00028   //! extends FileInfo to provide image decompression and some additional fields for image meta-data
00029   class ImageInfo : public FileInfo {
00030   public:
00031     //! constructor
00032     ImageInfo(const FileSystemImageSource& ds, const std::string& name, double time) : FileInfo(name,time), dataSource(ds), width(), height(), components() {}
00033     
00034     //! uses FileInfo's prepare to load file into memory, and then replaces with a decompressed version
00035     virtual void prepare();
00036     
00037     //! reference back to the containing data source so we can access FileSystemImageSource::layer
00038     const FileSystemImageSource& dataSource;
00039     size_t width; //!< width of image
00040     size_t height; //!< height of image
00041     size_t components; //!< number of color channels
00042   };
00043   
00044   bool sendData() {
00045     if((*curfile)->getData()==NULL)
00046       return false;
00047     const ImageInfo& curimg = dynamic_cast<const ImageInfo&>(**curfile);
00048     setImage(ImageHeader(0, layer, curimg.width, curimg.height, curimg.components, ++frameNumber, static_cast<unsigned int>(nextTime), curimg.filename), curimg.getData());
00049     return true;
00050   }
00051   
00052   virtual void enqueueFile(const std::string& name, double lifetime) { files.push_back(new ImageInfo(*this,name,lifetime)); } 
00053   
00054   unsigned int frameNumber;
00055 };
00056 
00057 /*! @file
00058  * @brief 
00059  * @author Ethan Tira-Thompson (ejt) (Creator)
00060  */
00061 
00062 #endif

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:38 2016 by Doxygen 1.6.3