00001 /*!@file Nerdcam/nerd-cam-wan.C [put description here] */ 00002 00003 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Nerdcam/nerd-cam-wan.C $ 00004 // $Id: nerd-cam-wan.C 6454 2006-04-11 00:47:40Z rjpeters $ 00005 00006 #include "Component/ModelManager.H" 00007 #include "Devices/DeviceOpts.H" 00008 #include "Devices/FrameGrabberConfigurator.H" 00009 #include "Image/ColorOps.H" 00010 #include "Image/Image.H" 00011 #include "Image/Pixels.H" 00012 #include "Raster/Raster.H" 00013 #include "Transport/FrameIstream.H" 00014 #include "Util/log.H" 00015 00016 #include <cstdio> 00017 #include <cstdlib> 00018 00019 const char* saveFile; 00020 00021 //! Does a single image grab and writes to file specified 00022 int main(const int argc, const char **argv) 00023 { 00024 // instantiate a model manager: 00025 ModelManager manager("NerdCam WAN"); 00026 00027 // Instantiate our various ModelComponents: 00028 nub::soft_ref<FrameGrabberConfigurator> 00029 gbc(new FrameGrabberConfigurator(manager)); 00030 manager.addSubComponent(gbc); 00031 00032 // choose a V4Lgrabber by default, and a few custom grabbing 00033 // defaults, for backward compatibility with an older version of 00034 // this program: 00035 manager.setOptionValString(&OPT_FrameGrabberType, "V4L"); 00036 manager.setOptionValString(&OPT_FrameGrabberDims, "320x240"); 00037 00038 // Parse command-line: 00039 if (manager.parseCommandLine(argc, argv, "<file>", 1, 1) == false) return(1); 00040 00041 // do post-command-line configs: 00042 saveFile = manager.getExtraArg(0).c_str(); 00043 00044 nub::soft_ref<FrameIstream> gb = gbc->getFrameGrabber(); 00045 if (gb.isInvalid()) 00046 LFATAL("You need to select a frame grabber type via the " 00047 "--fg-type=XX command-line option for this program " 00048 "to be useful"); 00049 00050 // let's get all our ModelComponent instances started: 00051 manager.start(); 00052 00053 Image<PixRGB<byte> > nerd; 00054 //LINFO("GRABBING %s",saveFile); 00055 for(int i = 0 ; i < 16 ; i++) 00056 nerd = gb->readRGB(); 00057 //LINFO("RESTERING %s", saveFile); 00058 Raster::WriteRGB(nerd,sformat("%snerd-cam-WAN.ppm",saveFile)); 00059 Raster::WriteGray(luminance(nerd), 00060 sformat("%snerd-cam-WAN.grey.pgm",saveFile)); 00061 00062 // stop all our ModelComponents 00063 manager.stop(); 00064 00065 // all done! 00066 return 0; 00067 } 00068 00069 // ###################################################################### 00070 /* So things look consistent in everyone's emacs... */ 00071 /* Local Variables: */ 00072 /* indent-tabs-mode: nil */ 00073 /* End: */