core/vidl/vidl_image_list_ostream.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_image_list_ostream.h
00002 #ifndef vidl_image_list_ostream_h_
00003 #define vidl_image_list_ostream_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A video output stream to a list of images
00010 //
00011 // \author Matt Leotta
00012 // \date 19 Dec 2005
00013 
00014 #include "vidl_ostream.h"
00015 #include <vcl_string.h>
00016 
00017 //:A video output stream to a list of images
00018 class vidl_image_list_ostream
00019   : public vidl_ostream
00020 {
00021  public:
00022   //: Constructor
00023   vidl_image_list_ostream();
00024 
00025   //: Constructor - opens a stream
00026   vidl_image_list_ostream(const vcl_string& directory,
00027                           const vcl_string& name_format = "%05d",
00028                           const vcl_string& file_format = "tiff",
00029                           const unsigned int init_index = 0);
00030 
00031   //: Destructor
00032   virtual ~vidl_image_list_ostream() { close(); }
00033 
00034   //: Open the stream
00035   virtual bool open(const vcl_string& directory,
00036                     const vcl_string& name_format = "%05d",
00037                     const vcl_string& file_format = "tiff",
00038                     const unsigned int init_index = 0);
00039 
00040   //: Close the stream
00041   virtual void close();
00042 
00043   //: Return true if the stream is open for writing
00044   virtual bool is_open() const;
00045 
00046   //: Return the current index
00047   unsigned int index() const { return index_; }
00048 
00049   //: Return the next file name to be written to
00050   virtual vcl_string next_file_name() const;
00051 
00052   //: Write and image to the stream
00053   // \retval false if the image could not be written
00054   virtual bool write_frame(const vidl_frame_sptr& frame);
00055 
00056  private:
00057   //: The current index
00058   unsigned int index_;
00059 
00060   //: The directory to save images in
00061   vcl_string dir_;
00062 
00063   //: The printf-style format string for filenames
00064   vcl_string name_format_;
00065 
00066   //: The image file format to use
00067   vcl_string file_format_;
00068 };
00069 
00070 #endif // vidl_image_list_ostream_h_