00001 /*!@file VFAT/fzvision.C simplified version of vision.C with feature analysis 00002 */ 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: T. Nathan Mundhenk <mundhenk@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/VFAT/fzvision.C $ 00036 // $Id: fzvision.C 14376 2011-01-11 02:44:34Z pez $ 00037 // 00038 // ############################################################ 00039 // ############################################################ 00040 // ##### --- VFAT --- 00041 // ##### Vision Feature Analysis Tool: 00042 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00043 // ##### Laurent Itti itti@pollux.usc.edu 00044 // ##### 00045 // ############################################################ 00046 // ############################################################ 00047 00048 //#include "saliency.H" 00049 #include "Component/ModelManager.H" 00050 #include "Media/FrameSeries.H" 00051 #include "GUI/XWindow.H" 00052 #include "Media/MediaSimEvents.H" 00053 #include "Neuro/StdBrain.H" 00054 #include "Neuro/NeuroSimEvents.H" 00055 #include "VFAT/featureClusterVision.H" 00056 #include "VFAT/segmentImageTrackMC.H" 00057 #include "Simulation/SimEventQueueConfigurator.H" 00058 00059 // define standard deviation multiplier for simple tracker 00060 #define H1_STD 3.5F 00061 #define H2_STD 3.5F 00062 #define S_STD 3.0F 00063 #define V_STD 2.5F 00064 00065 // DV Size 00066 00067 #define IMAGE_SIZE_X 640 00068 #define IMAGE_SIZE_Y 480 00069 #define TRACKER_NUMBER 3 00070 00071 00072 // Small NTSC Size 00073 00074 //#define IMAGE_SIZE_X 320 00075 //#define IMAGE_SIZE_Y 240 00076 00077 //! Basic entry and test binary to featureClusterVision 00078 00079 int main(const int argc, const char **argv) 00080 { 00081 MYLOGVERB = LOG_INFO; // suppress debug messages 00082 00083 // Instantiate a ModelManager: 00084 ModelManager manager("Attention Model"); 00085 00086 // Instantiate our various ModelComponents: 00087 nub::soft_ref<SimEventQueueConfigurator> 00088 seqc(new SimEventQueueConfigurator(manager)); 00089 manager.addSubComponent(seqc); 00090 00091 nub::soft_ref<InputFrameSeries> ifs(new InputFrameSeries(manager)); 00092 manager.addSubComponent(ifs); 00093 00094 nub::soft_ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager)); 00095 manager.addSubComponent(ofs); 00096 00097 nub::soft_ref<StdBrain> brain(new StdBrain(manager)); 00098 manager.addSubComponent(brain); 00099 00100 // feature analysis part of model 00101 const std::string name = "featureCluster"; 00102 const std::string tag = "fCV"; 00103 Image< PixRGB<byte> > input; 00104 Image< PixRGB<float> > finput; 00105 std::vector<covHolder<double> > covHolder; 00106 00107 // Parse command-line: 00108 if (manager.parseCommandLine(argc, argv, "<image>", 1, 1) == false) 00109 return(1); 00110 00111 nub::soft_ref<featureClusterVision<float> > 00112 fCV(new featureClusterVision<float>(manager,name,tag,brain,ifs, 00113 manager.getExtraArg(0))); 00114 manager.addSubComponent(fCV); 00115 nub::soft_ref<SimEventQueue> seq = seqc->getQ(); 00116 00117 // let's get all our ModelComponent instances started: 00118 manager.start(); 00119 bool init = true; 00120 // main loop: 00121 00122 //XWindow win1(Dims(IMAGE_SIZE_X, IMAGE_SIZE_Y), 0, 0, "CLASSES"); 00123 Image<PixRGB<float> > fima1; Image<PixRGB<byte> > bima1; 00124 XWindow win2(Dims(IMAGE_SIZE_X, IMAGE_SIZE_Y), 0, 0, "CLASSES TEMPORAL"); 00125 Image<PixRGB<float> > fima2; Image<PixRGB<byte> > bima2; 00126 XWindow win3(Dims(IMAGE_SIZE_X, IMAGE_SIZE_Y), 0, 0, "TARGETS TEMPORAL"); 00127 Image<PixRGB<float> > fima3; Image<PixRGB<byte> > bima3; 00128 Image<float> fima4; 00129 00130 //************************************************************ 00131 // SIMPLE TRACKER STUFF 00132 00133 XWindow wini(Dims(IMAGE_SIZE_X, IMAGE_SIZE_Y), 0, 0, "Test-input window"); 00134 XWindow wino(Dims(IMAGE_SIZE_X/4, (IMAGE_SIZE_Y/4)*TRACKER_NUMBER), 0, 0, "Test-output window"); 00135 XWindow winAux(Dims(500, 450), 0, 0, "Channel levels"); 00136 int wi = IMAGE_SIZE_X/4; 00137 int hi = IMAGE_SIZE_Y/4; 00138 //! Holds H2SV representation of image for simple tracker 00139 Image<PixH2SV2<float> > H2SVimage; 00140 //! output display image 00141 Image< PixRGB<byte> > display; 00142 //! Holds color to track for simple tracker 00143 std::vector<float> color(4,0.0F); 00144 //! +/- tollerance value on mean for track 00145 std::vector<float> std(4,0.0F); 00146 //! normalizer over color values (highest value possible) 00147 std::vector<float> norm(4,0.0F); 00148 norm[0] = 1.0F; norm[1] = 1.0F; norm[2] = 1.0F; norm[3] = 1.0F; 00149 //! how many standard deviations out to adapt, higher means less bias 00150 std::vector<float> adapt(4,0.0F); 00151 adapt[0] = 3.5F; adapt[1] = 3.5F; adapt[2] = 3.5F; adapt[3] = 3.5F; 00152 //! highest value for color adaptation possible (hard boundry) 00153 std::vector<float> upperBound(4,0.0F); 00154 //! lowest value for color adaptation possible (hard boundry) 00155 std::vector<float> lowerBound(4,0.0F); 00156 00157 segmentImageTrackMC<float,unsigned int,4> _segmenter(wi*hi); 00158 00159 std::vector<segmentImageTrackMC<float,unsigned int,4> > 00160 segmenters(TRACKER_NUMBER,_segmenter); 00161 00162 for(int i = 0; i < TRACKER_NUMBER; i++) 00163 { 00164 segmenters[i].SITsetFrame(&wi,&hi); 00165 segmenters[i].SITsetCircleColor(0,255,0); 00166 segmenters[i].SITsetUseSmoothing(true,10); 00167 } 00168 00169 segmenters[0].SITsetBoxColor(128,0,0 ,255,0,0); 00170 segmenters[1].SITsetBoxColor(0,128,0 ,0,255,0); 00171 segmenters[2].SITsetBoxColor(0,0,128 ,0,0,255); 00172 segmenters[3].SITsetBoxColor(128,128,0 ,255,255,0); 00173 segmenters[4].SITsetBoxColor(0,128,128 ,0,255,255); 00174 segmenters[5].SITsetBoxColor(128,0,128 ,255,0,255); 00175 00176 std::vector<bool> noTargetYet(TRACKER_NUMBER,true); 00177 std::vector<unsigned int> contTrackTime(TRACKER_NUMBER,0); 00178 00179 //************************************************************ 00180 std::ofstream outfileStart1("tracker.fzvision.log",std::ios::out); 00181 outfileStart1 << "\n*************************************************\n\n"; 00182 outfileStart1.close(); 00183 std::ofstream outfileStart2("blobs.fzvision.log",std::ios::out); 00184 outfileStart2 << "\n*************************************************\n\n"; 00185 outfileStart2.close(); 00186 while(1) { 00187 // write outputs or quit? 00188 bool shouldsave = false; 00189 bool shouldquit = false; 00190 bool gotcovert = false; 00191 if (seq->check<SimEventWTAwinner>(0)) gotcovert = true; 00192 const FrameState os = ofs->update(seq->now(), gotcovert); 00193 00194 if (os == FRAME_NEXT || os == FRAME_FINAL) 00195 shouldsave = true; 00196 00197 if (os == FRAME_FINAL) 00198 shouldquit = true; 00199 00200 if (shouldsave) 00201 { 00202 SimModuleSaveInfo sinfo(ofs, *seq); 00203 brain->save(sinfo); 00204 int foo = ifs->frame(); 00205 std::string Myname; 00206 std::string a = manager.getExtraArg(0); 00207 std::string b = "."; 00208 char c[100]; 00209 if(foo == 1) 00210 init = false; 00211 if(foo < 10) 00212 sprintf(c,"00000%d",foo); 00213 else if(foo < 100) 00214 sprintf(c,"0000%d",foo); 00215 else if(foo < 1000) 00216 sprintf(c,"000%d",foo); 00217 else if(foo < 10000) 00218 sprintf(c,"00%d",foo); 00219 else if(foo < 100000) 00220 sprintf(c,"0%d",foo); 00221 else 00222 sprintf(c,"%d",foo); 00223 Myname = a + b + c; 00224 std::cerr << "******************************************************\n"; 00225 std::cerr << "******************************************************\n"; 00226 // NOTE: added '0' at the end here because there was no value 00227 // matching the final '%d' 00228 LINFO("RUNNING FRAME %d NTARG %d",foo,0); 00229 LINFO("NAME %s",Myname.c_str()); 00230 // Upload a frame to the classifier 00231 //Raster::VisuRGB(input,"input.ppm"); 00232 fCV->fCVuploadImage(input,Myname); 00233 // classify and cluster this image 00234 fCV->fCVclusterImage(); 00235 std::cerr << "******************************************************\n"; 00236 std::cerr << "******************************************************\n"; 00237 // get back image data 00238 fCV->fCVgetClusterImages(&fima1,&fima2,&fima3,&fima4); 00239 //Raster::VisuRGB(finput,"finput.ppm"); 00240 bima1 = fima1; bima2 = fima2; bima3 = fima3; 00241 //win1.drawImage(bima1); 00242 win2.drawImage(bima2); 00243 win3.drawImage(bima3); 00244 00245 //Raster::WriteRGB(bima1,sformat("features.out.%s.ppm",c)); 00246 Raster::WriteRGB(bima2,sformat("classes.out.%s.ppm",c)); 00247 //Raster::WriteRGB(bima3,sformat("targets.out.%s.ppm",c)); 00248 // optional output of bayesian classification 00249 //fCV->fCVprintOutBayesClass(); 00250 // optional output of nearest neighbor classification 00251 //fCV->fCVprintOutNeighborClass(); 00252 00253 //std::string outFile = manager.getExtraArg(0) + c; 00254 00255 //fCV->fCVfeaturesToFile(outFile,true); 00256 // optional dump out all features post ICA to file 00257 //fCV->fCVICAfeaturesToFile(outFile); 00258 // optional check all the combined Motions 00259 //fCV->fCVcheckMotionCombined(foo); 00260 00261 //std::string file = "covMatrix"; 00262 // optional A file contaning signature data 00263 //fCV->fCVdumpCovMatrix(file); 00264 //fCV->fCVprintOutClusters(); 00265 00266 // optional SIGNATURE DATA FROM THIS CLASS (see covHolder.H) 00267 covHolder = fCV->fCVgetCovHolders(); 00268 // optional Size of the covHolder Vector 00269 00270 // See covHolder.H to see how data is stored 00271 // See covEstimate.C matchPmeanAccum to see how these 00272 // numbers are computed. 00273 std::ofstream outfile("tracker.fzvision.log",std::ios::app); 00274 outfile << ">>> FRAME " << foo; 00275 for(int i = 0; i < TRACKER_NUMBER; i++) 00276 { 00277 segmenters[i].SITsetFrameNumber(foo); 00278 } 00279 00280 for(int x = 0; x < (signed)fCV->fCVgetCovHolderSize(); x++) 00281 { 00282 covHolder[x].dumpMeToFile(a,c,init); 00283 for(int i = 0; i < TRACKER_NUMBER; i++) 00284 { 00285 if(noTargetYet[i] == true) 00286 { 00287 LINFO("%d,%f",x,covHolder[x].mean[3]); 00288 if(covHolder[x].mean[3] > 1.5F) 00289 { 00290 bool unique = true; 00291 for(int j = 0; j < TRACKER_NUMBER; j++) 00292 { 00293 if(noTargetYet[j] == false) 00294 { 00295 unsigned int umaxX,umaxY,uminX,uminY,uposX,uposY; 00296 int maxX,maxY,minX,minY; 00297 bool isSet = false; 00298 outfile << "\t\n- CHECKED " << i << " WITH " << j << " : "; 00299 if(contTrackTime[j] > 1) 00300 { 00301 segmenters[j].SITgetMinMaxBoundry(&uminX,&umaxX,&uminY,&umaxY); 00302 uposX = 0; uposY = 0; 00303 outfile << "REAL BOUNDARY "; 00304 uminX = uminX/4; uminY = uminY/4; 00305 umaxX = umaxX/4; umaxY = umaxY/4; 00306 } 00307 else 00308 { 00309 segmenters[j].SITgetExpectedTargetPosition(&uposX,&uposY,&umaxX,&umaxY,&uminX,&uminY,&isSet); 00310 // NOTE: I changed these from posX,posY to 00311 // uposX,uposY, because posX,posY haven't been 00312 // initialized yet at this point and were 00313 // generating compiler warnings: 00314 outfile << "EXPECTED BOUNDARY (" << uposX << "," << uposY << ") : "; 00315 } 00316 00317 const int fudge = 15; // get ride of this 00318 minX = (signed)uminX; minY = (signed)uminY; 00319 maxX = (signed)umaxX; maxY = (signed)umaxY; 00320 bool Xok = false; 00321 bool Yok = false; 00322 if((((signed)covHolder[x].minX/4 < minX-fudge) && ((signed)covHolder[x].maxX/4 < minX-fudge)) || 00323 (((signed)covHolder[x].minX/4 > maxX+fudge) && ((signed)covHolder[x].maxX/4 > maxX+fudge))) 00324 { 00325 Xok = true; 00326 } 00327 if((((signed)covHolder[x].minY/4 < minY-fudge) && ((signed)covHolder[x].maxY/4 < minY-fudge)) || 00328 (((signed)covHolder[x].minY/4 > maxY+fudge) && ((signed)covHolder[x].maxY/4 > maxY+fudge))) 00329 { 00330 Yok = true; 00331 } 00332 if((Xok == false) && (Yok == false)) 00333 { 00334 unique = false; 00335 } 00336 00337 outfile << covHolder[x].minX/4 << " < " << minX-fudge << " && " 00338 << covHolder[x].maxX/4 << " < " << minX-fudge << " || " 00339 << covHolder[x].minX/4 << " > " << maxX+fudge << " && " 00340 << covHolder[x].maxX/4 << " > " << maxX+fudge << " \n\tAND\n\t" 00341 << covHolder[x].minY/4 << " < " << minY-fudge << " && " 00342 << covHolder[x].maxY/4 << " < " << minY-fudge << " || " 00343 << covHolder[x].minY/4 << " > " << maxY+fudge << " && " 00344 << covHolder[x].maxY/4 << " > " << maxY+fudge << " : isSet = " << isSet 00345 << " : Unique = " << unique << "\n"; 00346 } 00347 } 00348 if(unique == true) 00349 { 00350 PixRGB<float> pRGB; 00351 PixH2SV2<float> pH2SV2; 00352 pH2SV2.p[0] = covHolder[x].mean[6]/covHolder[x].bias[6]; 00353 pH2SV2.p[1] = covHolder[x].mean[7]/covHolder[x].bias[7]; 00354 pH2SV2.p[2] = covHolder[x].mean[4]/covHolder[x].bias[4]; 00355 pH2SV2.p[3] = covHolder[x].mean[5]/covHolder[x].bias[5]; 00356 pRGB = PixRGB<float>(pH2SV2); 00357 outfile << "\n\t- " << x 00358 << " Moving Target " << covHolder[x].mean[3] << "\t" 00359 << covHolder[x].featureName[3].c_str() << "\t" 00360 << covHolder[x].mean[3] << "\t" 00361 << covHolder[x].STD[3] << "\t" 00362 << covHolder[x].bias[3] << "\t" 00363 << covHolder[x].featureName[4].c_str() << "\t" 00364 << covHolder[x].mean[4] << "\t" 00365 << covHolder[x].STD[4] << "\t" 00366 << covHolder[x].bias[4] << "\t" 00367 << covHolder[x].featureName[5].c_str() << "\t" 00368 << covHolder[x].mean[5] << "\t" 00369 << covHolder[x].STD[5] << "\t" 00370 << covHolder[x].bias[5] << "\t" 00371 << covHolder[x].featureName[6].c_str() << "\t" 00372 << covHolder[x].mean[6] << "\t" 00373 << covHolder[x].STD[6] << "\t" 00374 << covHolder[x].bias[6] << "\t" 00375 << covHolder[x].featureName[7].c_str() << "\t" 00376 << covHolder[x].mean[7] << "\t" 00377 << covHolder[x].STD[7] << "\t" 00378 << covHolder[x].bias[6] << "\n\t- " 00379 << "RED " << pRGB.p[0] << "\t" 00380 << "GREEN " << pRGB.p[1] << "\t" 00381 << "BLUE " << pRGB.p[2] << "\n"; 00382 LINFO("%s",covHolder[x].featureName[3].c_str()); 00383 LINFO("%s",covHolder[x].featureName[6].c_str()); 00384 LINFO("%s",covHolder[x].featureName[7].c_str()); 00385 LINFO("%s",covHolder[x].featureName[4].c_str()); 00386 LINFO("%s",covHolder[x].featureName[5].c_str()); 00387 LINFO("..%lx",covHolder[x].samples); 00388 outfile << "\t- Samples " << covHolder[x].samples << " ... "; 00389 if(covHolder[x].samples > 25) 00390 { 00391 outfile << "OK "; 00392 outfile << " Variance " << covHolder[x].STD[6] * H1_STD 00393 << " " << covHolder[x].STD[7] * H2_STD 00394 << " ... "; 00395 /* if((((covHolder[x].STD[6] * H1_STD) < 0.15F) || 00396 ((covHolder[x].STD[7] * H2_STD) < 0.15F) || 00397 ((covHolder[x].STD[4] * S_STD) < 0.15F)) && 00398 ((covHolder[x].STD[5] * V_STD) > 0.15F)) 00399 {*/ 00400 00401 outfile << "OK\n"; 00402 //if(covHolder[x].lifeSpan > 5) 00403 //{ 00404 00405 outfile << "<<<NEW TRACKING>>> " << x << "\t" 00406 << "FRAME " << foo << "\t" 00407 << "TRACKER " << i << "\t" 00408 << "LIFE SPAN " << covHolder[x].lifeSpan << "\t" 00409 << "(" << covHolder[x].posX/4 00410 << "," << covHolder[x].posY/4 << ")\t" 00411 << "Max (" << covHolder[x].maxX/4 00412 << "," << covHolder[x].maxY/4 << ")\t" 00413 << "Min (" << covHolder[x].minX/4 00414 << "," << covHolder[x].minY/4 << ")\n"; 00415 00416 LINFO("....%lx",covHolder[x].lifeSpan); 00417 00418 noTargetYet[i] = false; 00419 00420 color[0] = covHolder[x].mean[6]/covHolder[x].bias[6]; 00421 color[1] = covHolder[x].mean[7]/covHolder[x].bias[7]; 00422 color[2] = covHolder[x].mean[4]/covHolder[x].bias[4]; 00423 color[3] = covHolder[x].mean[5]/covHolder[x].bias[5]; 00424 00425 std[0] = (covHolder[x].STD[6]*(1/covHolder[x].bias[6])) 00426 * H1_STD; 00427 std[1] = (covHolder[x].STD[7]*(1/covHolder[x].bias[7])) 00428 * H2_STD; 00429 std[2] = (covHolder[x].STD[4]*(1/covHolder[x].bias[4])) 00430 * S_STD; 00431 std[3] = (covHolder[x].STD[5]*(1/covHolder[x].bias[5])) 00432 * V_STD; 00433 00434 upperBound[0] = covHolder[x].mean[6]/covHolder[x].bias[6] 00435 + 0.45F; 00436 upperBound[1] = covHolder[x].mean[7]/covHolder[x].bias[7] 00437 + 0.45F; 00438 upperBound[2] = covHolder[x].mean[4]/covHolder[x].bias[4] 00439 + 0.45F; 00440 upperBound[3] = covHolder[x].mean[5]/covHolder[x].bias[5] 00441 + 0.45F; 00442 00443 lowerBound[0] = covHolder[x].mean[6]/covHolder[x].bias[6] 00444 - 0.45F; 00445 lowerBound[1] = covHolder[x].mean[7]/covHolder[x].bias[7] 00446 - 0.45F; 00447 lowerBound[2] = covHolder[x].mean[4]/covHolder[x].bias[4] 00448 - 0.45F; 00449 lowerBound[3] = covHolder[x].mean[5]/covHolder[x].bias[5] 00450 - 0.45F; 00451 00452 // reset the frame to the center 00453 segmenters[i].SITsetFrame(&wi,&hi); 00454 // where should the target appear? 00455 segmenters[i].SITsetExpectedTargetPosition(covHolder[x].posX/4, 00456 covHolder[x].posY/4, 00457 covHolder[x].maxX/4, 00458 covHolder[x].maxY/4, 00459 covHolder[x].minX/4, 00460 covHolder[x].minY/4); 00461 // What colors should the target have? 00462 00463 segmenters[i].SITsetTrackColor(&color,&std,&norm,&adapt, 00464 &upperBound,&lowerBound,false,true); 00465 //} 00466 } 00467 } 00468 } 00469 } 00470 } 00471 } 00472 outfile << "\n"; 00473 outfile.close(); 00474 display = input; 00475 Image<PixRGB<byte> > Aux; 00476 Aux.resize(100,450,true); 00477 Image<byte> tempPaste; 00478 tempPaste.resize(IMAGE_SIZE_X/4, (IMAGE_SIZE_Y/4)*TRACKER_NUMBER,true); 00479 for(int i = 0; i < TRACKER_NUMBER; i++) 00480 { 00481 Image<byte> temp; 00482 temp.resize(IMAGE_SIZE_X/4, IMAGE_SIZE_Y/4,true); 00483 if(noTargetYet[i] == false) 00484 { 00485 H2SVimage = input; 00486 segmenters[i].SITtrackImageAny(H2SVimage,&display,&Aux,true); 00487 /* Retrieve and Draw all our output images */ 00488 temp = segmenters[i].SITreturnCandidateImage(); 00489 00490 00491 char foofoo[100]; 00492 sprintf(foofoo,"blobs.%d.fzvision.log",i); 00493 00494 std::ofstream outfile2(foofoo,std::ios::app); 00495 outfile2 << "FRAME " << foo << "\t" 00496 << "TRACK TIME " << contTrackTime[i] << "\t" 00497 << "BLOBS " << segmenters[i].SITnumberBlobs() << "\t" 00498 << "LOT status " << segmenters[i].SITreturnLOTtypeName() << "\t" 00499 << "LOT count " << segmenters[i].SITgetLOTcount() << "\t" 00500 << "MASS " << segmenters[i].SITgetMass() << "\n"; 00501 for(unsigned int ii = 0; ii < segmenters[i].SITnumberBlobs(); ii++) 00502 { 00503 outfile2 << "\tBLOB NUMBER " << ii << "\t" 00504 << segmenters[i].SITgetBlobReasonForKill(ii) << " ... \t" 00505 << segmenters[i].SITgetBlobMass(ii) << "\t" 00506 << segmenters[i].SITgetBlobPosX(ii) << "\t" 00507 << segmenters[i].SITgetBlobPosY(ii) << "\n"; 00508 } 00509 outfile2 << "\n"; 00510 outfile2.close(); 00511 00512 if(segmenters[i].SIT_LOTandRESET == true) 00513 { 00514 noTargetYet[i] = true; 00515 contTrackTime[i] = 0; 00516 LINFO("LOSS OF TRACK RESET"); 00517 std::ofstream outfile("tracker.fzvision.log",std::ios::app); 00518 outfile << ">>>LOSS OF TRACK " << i 00519 << " RESET AT FRAME " << foo << "\n"; 00520 outfile.close(); 00521 } 00522 else 00523 { 00524 contTrackTime[i]++; 00525 } 00526 } 00527 pasteImage(tempPaste,temp,(byte)128,Point2D<int>(0,(IMAGE_SIZE_Y/4)*i)); 00528 } 00529 Raster::WriteGray(tempPaste,sformat("tracker.candidates.out.%s.pgm",c)); 00530 wino.drawImage(tempPaste); 00531 Raster::WriteRGB(Aux,sformat("tracker.levels.out.%s.ppm",c)); 00532 winAux.drawImage(Aux); 00533 Raster::WriteRGB(display,sformat("tracker.out.%s.ppm",c)); 00534 wini.drawImage(display); 00535 } 00536 00537 if (shouldquit) break; // done 00538 00539 // why do we handle the output before the input? That's because 00540 // both the input and output frame series will switch to the next 00541 // frame at the exact same time, if input and output framerates 00542 // are equal. When the input series switches to a new frame, it 00543 // will reset any drawings that were obtained on the previous 00544 // frame. So we need to make sure we have saved those results 00545 // before we read the new frame in. 00546 00547 // if we displayed a bunch of images, let's pause: 00548 if (ifs->shouldWait() || ofs->shouldWait()) 00549 Raster::waitForKey(); 00550 00551 // read new image in? 00552 const FrameState is = ifs->update(seq->now()); 00553 if (is == FRAME_COMPLETE) break; // done 00554 if (is == FRAME_NEXT || is == FRAME_FINAL) // new frame 00555 { 00556 input = ifs->readRGB(); 00557 00558 // empty image signifies end-of-stream 00559 if (input.initialized()) 00560 { 00561 rutz::shared_ptr<SimEventInputFrame> 00562 e(new SimEventInputFrame(brain.get(), GenericFrame(input), 0)); 00563 seq->post(e); // post the image to the brain 00564 00565 // show memory usage if in debug mode: 00566 if (MYLOGVERB >= LOG_DEBUG) 00567 SHOWMEMORY("MEMORY USAGE: frame %d t=%.1fms", ifs->frame(), 00568 seq->now().msecs()); 00569 } 00570 } 00571 00572 // evolve brain: 00573 const SimStatus status = seq->evolve(); 00574 00575 if (SIM_BREAK == status) // Brain decided it's time to quit 00576 break; 00577 } 00578 00579 00580 //fCV->checkMixing(); 00581 //fCV->checkICA(); 00582 //std::string fileName = "features.txt"; 00583 fCV->fCVfeaturesToFile(manager.getExtraArg(0),false); 00584 fCV->fCVICAfeaturesToFile(manager.getExtraArg(0)); 00585 // stop all our ModelComponents 00586 00587 manager.stop(); 00588 00589 // all done! 00590 return 0; 00591 } 00592 00593 // ###################################################################### 00594 /* So things look consistent in everyone's emacs... */ 00595 /* Local Variables: */ 00596 /* indent-tabs-mode: nil */ 00597 /* End: */