runCINNIC2.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
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
00059 ContourNeuronCreate<float> CINNICreate;
00060
00061 std::istream* argInput;
00062
00063 const char* configFile;
00064
00065 readConfig configIn(25);
00066
00067
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)
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
00176
00177
00178