MbariFrameSeries.H

Go to the documentation of this file.
00001 /*!@file MBARI/MbariFrameSeries.H Customized output frame series class
00002   for use in MbariResultViewer */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00006 // by the University of Southern California (USC) and the iLab at USC.  //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file:
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/MBARI/MbariFrameSeries.H $
00036 // $Id: MbariFrameSeries.H 6464 2006-04-13 18:01:55Z rjpeters $
00037 //
00038 
00039 #ifndef MBARI_MBARIFRAMESERIES_H_DEFINED
00040 #define MBARI_MBARIFRAMESERIES_H_DEFINED
00041 
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Image/Dims.H"
00045 #include "Raster/RasterFileFormat.H"
00046 #include "Util/Types.H"
00047 
00048 struct ModelOptionCateg;
00049 template <class T> class Image;
00050 template <class T> class PixRGB;
00051 
00052 //! MbariResultViewer options
00053 extern const ModelOptionCateg MOC_MBARIRV;
00054 
00055 // ######################################################################
00056 //! InputMbariFrameSeries manages a series of input frames
00057 /*! NOTE: this class was split off from the standard InputFrameSeries
00058     classes, in order to support the different input paradigm used in
00059     MbariResultViewer and test-mbari, while allowing the standard
00060     InputFrameSeries's interface to be minimized. */
00061 class InputMbariFrameSeries : public ModelComponent
00062 {
00063 public:
00064   //! Constructor
00065   InputMbariFrameSeries(OptionManager& mgr,
00066                         const std::string& descrName = "Frame Series",
00067                         const std::string& tagName = "FrameSeries");
00068 
00069   //! Destructor
00070   virtual ~InputMbariFrameSeries();
00071 
00072   //! Get dims of a frame on disk, without fully reading it
00073   /*! It is okay to call this before the model is started().  If input
00074       resizing is being done, this will return the resized dims.  All
00075       in all, this will return the size of whatever you will get when
00076       calling readRGB(). */
00077   Dims peekDims(const int fnum);
00078 
00079   //! Read a color frame
00080   Image< PixRGB<byte> > readRGB(const int fnum);
00081 
00082   //! Set the filename stem
00083   void setFileStem(const std::string& stem);
00084 
00085 private:
00086   //! dims to which frames should be resized on read/write, or 0x0 for none
00087   OModelParam<Dims> itsDims;
00088 
00089   //! if true, aspect ratio of original image will be preserved when resizing
00090   OModelParam<bool> itsPreserveAspect;
00091 
00092   //! input file format
00093   OModelParam<RasterFileFormat> itsRasterFileFormat;
00094 
00095   //! filename stem;
00096   std::string itsStem;
00097 };
00098 
00099 // ######################################################################
00100 //! OutputMbariFrameSeries manages a series of output frames
00101 /*! NOTE: this class was split off from the standard OutputFrameSeries
00102     class, in order to support the different output paradigm used in
00103     MbariResultViewer and test-mbari, while allowing the standard
00104     OutputFrameSeries's interface to be minimized. */
00105 class OutputMbariFrameSeries : public ModelComponent
00106 {
00107 public:
00108   //! Constructor
00109   OutputMbariFrameSeries(OptionManager& mgr);
00110 
00111   //! Destructor
00112   virtual ~OutputMbariFrameSeries();
00113 
00114   //! Set the file stem - for more info see ModelComponent
00115   void setFileStem(const std::string& stem);
00116 
00117   //! Get the file stem
00118   std::string getFileStem() const;
00119 
00120   //! Write a frame to disk with a specific frame number
00121   void writeMbariRGB(const Image< PixRGB<byte> >& image,
00122                      const std::string& otherstem,
00123                      const int framenum);
00124 
00125   //! Write a frame to disk with a specific frame number
00126   void writeMbariGray(const Image<byte>& image,
00127                       const std::string& otherstem,
00128                       const int framenum);
00129 
00130   //! Write a frame to disk with a specific frame number
00131   void writeMbariFloat(const Image<float>& image,
00132                        const std::string& otherstem,
00133                        const int flags,
00134                        const int framenum);
00135 
00136 private:
00137   //! text log file name
00138   OModelParam<std::string> itsLogFile;
00139 
00140   //! in test mode, don't do any displays
00141   OModelParam<bool> itsTestMode;
00142 
00143   //! dims to which frames should be resized on read/write, or 0x0 for none
00144   OModelParam<Dims> itsDims;
00145 
00146   //! if true, aspect ratio of original image will be preserved when resizing
00147   OModelParam<bool> itsPreserveAspect;
00148 
00149   //! show the frames using xv
00150   OModelParam<bool> itsShowFrames;
00151 
00152   //! default file format; will be used if RASFMT_AUTO is specified at read/write
00153   OModelParam<RasterFileFormat> itsRasterFileFormat;
00154 
00155   std::string itsStem;        //!< filename stem
00156   int itsDidDisplay;          //!< did we show some frames since last update?
00157 
00158   //! resize an image to our dims
00159   template <class T>
00160   Image<T> doResizeImage(const Image<T>& input) const;
00161 
00162   //! compute filename corresponding to args and return as string
00163   /*! Use sformat() to generate otherstem if you need printf-style
00164       formatting. */
00165   std::string computeFileName(const int framenum,
00166                               const std::string& otherstem) const;
00167 
00168   //! have we displayed too many windows, or can we still display more?
00169   bool okToDisplay();
00170 };
00171 
00172 // ######################################################################
00173 /* So things look consistent in everyone's emacs... */
00174 /* Local Variables: */
00175 /* indent-tabs-mode: nil */
00176 /* End: */
00177 
00178 #endif // MBARI_MBARIFRAMESERIES_H_DEFINED
Generated on Sun May 8 08:05:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3