00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CVideoFileWritter_H 00029 #define CVideoFileWritter_H 00030 00031 #include <mrpt/vision/utils.h> 00032 #include <mrpt/utils/CImage.h> 00033 #include <mrpt/utils/safe_pointers.h> 00034 00035 namespace mrpt 00036 { 00037 namespace vision 00038 { 00039 /** An output stream which takes a sequence of images and writes a video file in any of a given of compatible formats. 00040 * 00041 * The output file is open when calling "open", and it's closed at destructor or after calling "close". 00042 * 00043 * Example of usage: 00044 * 00045 * \code 00046 * CVideoFileWriter vid; 00047 * vid.open("test.avi","MJPG",15,TPixelCoord(320,200)); 00048 * CImage img(320,200); 00049 * vid << img; 00050 * vid.close; 00051 * \endcode 00052 * 00053 * There are two methods for adding frames to the video: 00054 * - The operator <<: Which will raise an exception on any error. 00055 * - The method writeImage, which does not raise any exception on errors. 00056 * 00057 * \note This class is a wrapper for OpenCV's CvVideoWriter. 00058 */ 00059 class MRPTDLLIMPEXP CVideoFileWriter 00060 { 00061 private: 00062 mrpt::utils::void_ptr_noncopy m_video; //!< A pointer to CvVideoWriter 00063 mrpt::vision::TImageSize m_img_size; //!< A copy of the video size 00064 00065 public: 00066 CVideoFileWriter(); //!< Default constructor, which does not open any file 00067 virtual ~CVideoFileWriter(); //!< Destructor 00068 00069 /** Open a file for writing the video. 00070 * \param out_file The video file to create for output. 00071 * \param fourcc The video codec, as a string. See notes below. 00072 * \paam fps The video FPS (frames per seconds). 00073 * \param frameSize The size of the video frames. All subsequent images must be of this size. 00074 * \param isColor Set to false to create a grayscale video. 00075 * 00076 * \note If fourcc is left as an empty string a default codec will be seleceted (e.g. "IYUV"). 00077 * \note Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" -> Motion JPEG, "XVID", etc... 00078 * 00079 * \return false on any error, true on success. 00080 */ 00081 bool open( 00082 const std::string &out_file, 00083 double fps, 00084 const mrpt::vision::TImageSize & frameSize, 00085 const std::string &fourcc = std::string(""), 00086 bool isColor = true ); 00087 00088 /** Finish the file writing and close the file output 00089 */ 00090 void close(); 00091 00092 /** Write image to the video file. 00093 * \exception std::exception On any error 00094 */ 00095 const CVideoFileWriter& operator << (const mrpt::utils::CImage& img) const; 00096 00097 /** Write image to the video file (method function, alternative to the operator <<). 00098 * \return false on any error 00099 */ 00100 bool writeImage(const mrpt::utils::CImage& img) const; 00101 00102 00103 }; // end of class 00104 00105 } // end of namespace 00106 } // end of namespace 00107 00108 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 22:58:25 EDT 2009 |