00001 /*!@file AppDevices/calibrateVideo.C record from high speed camera XC and 00002 Hokuyo Laser Range finder and save to disk*/ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00006 // 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: farhan 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppDevices/calibrateVideo.C $ 00036 // $Id: calibrateVideo.C 12962 2010-03-06 02:13:53Z irock $ 00037 // 00038 #include "Component/ModelManager.H" 00039 #include "Devices/RangeFinder.H" 00040 #include "Component/OptionManager.H" 00041 #include "Devices/Serial.H" 00042 #include "Devices/FrameGrabberConfigurator.H" 00043 #include "Devices/DeviceOpts.H" 00044 #include "Image/DrawOps.H" 00045 #include "Image/Image.H" 00046 #include "Image/ShapeOps.H" 00047 #include "Image/CutPaste.H" 00048 #include "Image/ImageCache.H" 00049 #include "Image/Pixels.H" 00050 #include "Image/MathOps.H" 00051 #include "Image/IO.H" 00052 #include "Image/Layout.H" 00053 #include "GUI/SDLdisplay.H" 00054 #include "GUI/GUIOpts.H" 00055 #include "Raster/Raster.H" 00056 #include "Media/FrameSeries.H" 00057 #include "Transport/FrameIstream.H" 00058 #include "Transport/FrameInfo.H" 00059 #include "Util/Timer.H" 00060 #include "Util/log.H" 00061 #include "Util/sformat.H" 00062 #include "Video/RgbConversion.H" // for toVideoYUV422() 00063 #include "Raster/DeBayer.H" // for debayer() 00064 #include "Raster/PlaintextWriter.H" 00065 #include <algorithm> 00066 #include <iterator> 00067 #include <queue> 00068 #include <fstream> 00069 #include <iostream> 00070 00071 00072 using namespace std; 00073 Timer tim; 00074 00075 static int submain(const int argc, char** argv) 00076 { 00077 // Image<PixRGB<byte> > dispImg(640,1024,ZEROS); 00078 Image<byte> ima(640,480,ZEROS); 00079 00080 uint64 t; 00081 00082 // instantiate a model manager: 00083 ModelManager manager("getting calibration image from recording camera"); 00084 00085 nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager)); 00086 manager.addSubComponent(ofs); 00087 00088 nub::soft_ref<FrameGrabberConfigurator> 00089 gbc(new FrameGrabberConfigurator(manager)); 00090 manager.addSubComponent(gbc); 00091 00092 manager.setOptionValString(&OPT_FrameGrabberType, "XC"); 00093 manager.setOptionValString(&OPT_FrameGrabberDims, "640x478"); 00094 00095 // Parse command-line: 00096 if (manager.parseCommandLine(argc, argv, "",0,0) == false) 00097 return(1); 00098 00099 // do post-command-line configs: 00100 nub::soft_ref<FrameIstream> gb = gbc->getFrameGrabber(); 00101 00102 if (gb.isInvalid()) 00103 LFATAL("You need to have XC camera and XClibrary"); 00104 00105 00106 manager.start(); 00107 00108 //start streaming camera 00109 gb->startStream(); 00110 00111 while(1) 00112 { 00113 //read from grabber 00114 ima = gb->readGray(); 00115 Image<PixRGB<byte> > imgByte = ima; 00116 drawCircle(imgByte, Point2D<int>(320,240), 5,PixRGB<byte>(255,0,0)); 00117 ofs->writeRGB(imgByte,"Output",FrameInfo("output",SRC_POS)); 00118 00119 LINFO("grab on"); 00120 t = tim.get(); 00121 if(t > 10000) 00122 { 00123 manager.stop(); 00124 exit(1); 00125 } 00126 } 00127 00128 manager.stop(); 00129 } 00130 00131 00132 00133 extern "C" int main(const int argc, char** argv) 00134 { 00135 try 00136 { 00137 return submain(argc, argv); 00138 } 00139 catch (...) 00140 { 00141 REPORT_CURRENT_EXCEPTION; 00142 } 00143 00144 return 1; 00145 } 00146 00147 // ###################################################################### 00148 /* So things look consistent in everyone's emacs... */ 00149 /* Local Variables: */ 00150 /* indent-tabs-mode: nil */ 00151 /* End: */ 00152 00153