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)
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   //! ignores call -- images don't provide outputs
00029   virtual void updateProvidingOutputs() {}
00030   
00031   //! extends FileInfo to provide image decompression and some additional fields for image meta-data
00032   class ImageInfo : public FileInfo {
00033   public:
00034     //! constructor
00035     ImageInfo(const FileSystemImageSource& ds, const std::string& name, float time) : FileInfo(name,time), dataSource(ds), width(), height(), components() {}
00036     
00037     //! uses FileInfo's prepare to load file into memory, and then replaces with a decompressed version
00038     virtual void prepare();
00039     
00040     //! size of the header containing image meta data
00041     virtual size_t getHeaderSize() const;
00042     //! encodes the file meta-data into the buffer: FileSystemImageSource::layer, #width, #height, #components; raw image data will then follow
00043     virtual size_t writeHeader(char* buf, size_t size) const;
00044     
00045     //! reference back to the containing data source so we can access FileSystemImageSource::layer
00046     const FileSystemImageSource& dataSource;
00047     size_t width; //!< width of image
00048     size_t height; //!< height of image
00049     size_t components; //!< number of color channels
00050   };
00051   
00052   virtual void enqueueFile(const std::string& name, float lifetime) { files.push_back(new ImageInfo(*this,name,lifetime)); } 
00053 };
00054 
00055 /*! @file
00056  * @brief 
00057  * @author Ethan Tira-Thompson (ejt) (Creator)
00058  *
00059  * $Author: ejt $
00060  * $Name: tekkotsu-4_0 $
00061  * $Revision: 1.2 $
00062  * $State: Exp $
00063  * $Date: 2007/11/09 19:01:13 $
00064  */
00065 
00066 #endif

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:00:53 2007 by Doxygen 1.5.4