00001 /*!@file AppMedia/app-stream.C simple program to exercise FrameIstream 00002 and FrameOstream */ 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: Rob Peters <rjpeters at usc dot edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppMedia/app-stream.C $ 00036 // $Id: app-stream.C 9841 2008-06-20 22:05:12Z lior $ 00037 // 00038 00039 #ifndef APPMEDIA_APP_STREAM_C_DEFINED 00040 #define APPMEDIA_APP_STREAM_C_DEFINED 00041 00042 #include "Component/ModelManager.H" 00043 #include "Media/Streamer.H" 00044 00045 /* This is a trivial program bin/stream to exercise FrameIstream and 00046 FrameOstream. All it does is read an InputFrameSeries, but you can 00047 specify the input to come from anywhere (using --in) and you can 00048 specify the output to go anywhere (using one or more --out 00049 options). E.g., to view an mpeg movie (note that we make no effort 00050 to actually display the movie at the proper framerate): 00051 00052 ./bin/stream --input-frames=0-10000@1 \ 00053 --in=tests/inputs/mpegclip1.mpg --out=display 00054 00055 to display the contents of your framegrabber (again, we make no 00056 effort to sync up the framerates) 00057 00058 ./bin/stream --input-frames=0-10000@1 --in=v4l --out=display 00059 00060 to convert a movie into a series of raster files (the output files 00061 will be named starting from stream-output000000.ppm): 00062 00063 ./bin/stream --input-frames=0-10000@1 \ 00064 --in=tests/inputs/mpegclip1.mpg --out=raster 00065 00066 to record 100 frames from your your framegrabber to a movie file 00067 (the movie will be named stream-output.mpg): 00068 00069 ./bin/stream --input-frames=0-99@1 --in=v4l --out=mpeg 00070 00071 to view some white noise in case you are bored: 00072 00073 ./bin/stream --input-frames=0-999999@1 \ 00074 --in=random:1024x1024 --out=display 00075 */ 00076 00077 class CopyStreamer : public Streamer 00078 { 00079 public: 00080 CopyStreamer() 00081 : 00082 Streamer("Streamer"), 00083 itsOutPrefix("stream-output") 00084 {} 00085 00086 private: 00087 virtual void handleExtraArgs(const ModelManager& mgr) 00088 { 00089 if (mgr.numExtraArgs() > 0) 00090 itsOutPrefix = mgr.getExtraArg(0); 00091 } 00092 00093 virtual void onFrame(const GenericFrame& input, 00094 FrameOstream& ofs, 00095 const int frameNum) 00096 { 00097 ofs.writeFrame(input, itsOutPrefix, 00098 FrameInfo("copy of input frame", SRC_POS)); 00099 } 00100 00101 std::string itsOutPrefix; 00102 }; 00103 00104 int main(const int argc, const char **argv) 00105 { 00106 CopyStreamer s; 00107 return s.run(argc, argv, "?prefix?", 0, 1); 00108 } 00109 00110 // ###################################################################### 00111 /* So things look consistent in everyone's emacs... */ 00112 /* Local Variables: */ 00113 /* indent-tabs-mode: nil */ 00114 /* End: */ 00115 00116 #endif // APPMEDIA_APP_STREAM_C_DEFINED