FileSystemImageSource.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_FileSystemImageSource_h_
00003 #define INCLUDED_FileSystemImageSource_h_
00004
00005 #include "FileSystemDataSource.h"
00006
00007
00008 class FileSystemImageSource : public FileSystemDataSource {
00009 public:
00010
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
00018
00019
00020
00021
00022
00023
00024 plist::Primitive<int> layer;
00025
00026 protected:
00027
00028
00029 class ImageInfo : public FileInfo {
00030 public:
00031
00032 ImageInfo(const FileSystemImageSource& ds, const std::string& name, double time) : FileInfo(name,time), dataSource(ds), width(), height(), components() {}
00033
00034
00035 virtual void prepare();
00036
00037
00038 const FileSystemImageSource& dataSource;
00039 size_t width;
00040 size_t height;
00041 size_t components;
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
00058
00059
00060
00061
00062 #endif