00001 /*!@file CINNIC/runCINNIC2.C this runs CINNIC2 */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: T Nathan Mundhenk <mundhenk@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CINNIC/runCINNIC2.C $ 00035 // $Id: runCINNIC2.C 12074 2009-11-24 07:51:51Z itti $ 00036 // 00037 00038 // ############################################################ 00039 // ############################################################ 00040 // ##### ---CINNIC2--- 00041 // ##### Contour Integration: 00042 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00043 // ############################################################ 00044 // ############################################################ 00045 00046 //This is the start of the execution path for the CINNIC test alg. 00047 #include "Util/log.H" 00048 #include "Util/readConfig.H" 00049 00050 #include "CINNIC/CINNIC2.H" 00051 00052 #include <stdlib.h> 00053 #include <string> 00054 #include <sys/types.h> 00055 #include <time.h> 00056 #include <cstdio> 00057 00058 //! Create a CINNIC neuron, use float 00059 ContourNeuronCreate<float> CINNICreate; 00060 //! pointer to command line argument stream 00061 std::istream* argInput; 00062 //! This is the configFile name 00063 const char* configFile; 00064 //! This is the configFile object 00065 readConfig configIn(25); 00066 00067 //! This is the main binary for CINNIC2 00068 int main(int argc, char* argv[]) 00069 { 00070 LINFO("RUNNING CINNIC 2"); 00071 time_t t1,t2; 00072 (void) time(&t1); 00073 00074 bool useFrames ; 00075 unsigned int frames = 0; 00076 if(argc > 4) 00077 { 00078 useFrames = true; 00079 frames = atoi(argv[4]); 00080 } 00081 else 00082 { 00083 useFrames = false; 00084 } 00085 00086 if(argc > 3) 00087 { 00088 configFile = argv[3]; 00089 } 00090 else 00091 { 00092 configFile = "contour.conf"; 00093 } 00094 LINFO("LOADING CONFIG FILE"); 00095 configIn.openFile(configFile); 00096 00097 LINFO("Starting CINNIC test\n"); 00098 CINNICreate.CreateNeuron(configIn); 00099 LINFO("CINNIC template Neuron copied, ready for use"); 00100 00101 std::string savefilename; 00102 00103 if(argc > 2) 00104 { 00105 savefilename = argv[2]; 00106 } 00107 else 00108 { 00109 savefilename = "noname"; 00110 } 00111 if(argc > 1) //command line argument 00112 { 00113 unsigned int currentFrame = 1; 00114 CINNIC2<XSize,Scales,AnglesUsed,Iterations,float,int> skeptic; 00115 LINFO("argc %d", argc); 00116 Image<byte> inputImage; 00117 if(useFrames == false) 00118 { 00119 00120 inputImage = Raster::ReadGray(argv[1], RASFMT_PNM); 00121 std::string filename = argv[1]; 00122 LINFO("Image Loaded"); 00123 skeptic.CINrunSimpleImage(CINNICreate,filename.c_str(),currentFrame 00124 ,inputImage,configIn); 00125 LINFO("done!"); 00126 } 00127 else 00128 { 00129 Image<PixRGB<byte> > inputImageC; 00130 for(unsigned int i = 0; i < frames; i++) 00131 { 00132 skeptic.CINtoggleFrameSeries(true); 00133 std::string filename; 00134 std::string a = argv[1]; 00135 char c[100]; 00136 if(i < 10) 00137 sprintf(c,"00000%d",i); 00138 else if(i < 100) 00139 sprintf(c,"0000%d",i); 00140 else if(i < 1000) 00141 sprintf(c,"000%d",i); 00142 else if(i < 10000) 00143 sprintf(c,"00%d",i); 00144 else if(i < 100000) 00145 sprintf(c,"0%d",i); 00146 else 00147 sprintf(c,"%d",i); 00148 filename = a + c; 00149 inputImageC = Raster::ReadRGB(filename, RASFMT_PNM); 00150 inputImage = luminance(inputImageC); 00151 LINFO("Image %s Loaded",filename.c_str()); 00152 skeptic.CINrunSimpleImage(CINNICreate,filename.c_str(),currentFrame 00153 ,inputImage,configIn); 00154 currentFrame++; 00155 } 00156 LINFO("done!"); 00157 } 00158 } 00159 else 00160 { 00161 LINFO("You must specify command line args"); 00162 LINFO("runCINNIC in_file out_file config_file"); 00163 } 00164 00165 (void) time(&t2); 00166 long int tl = (long int) t2-t1; 00167 printf("\n*************************************\n"); 00168 printf("Time to execute, %ld seconds\n",tl); 00169 printf("*************************************\n\n"); 00170 00171 return 1; 00172 } 00173 00174 // ###################################################################### 00175 /* So things look consistent in everyone's emacs... */ 00176 /* Local Variables: */ 00177 /* indent-tabs-mode: nil */ 00178 /* End: */