Ticket #60: existingDetections.cc.patch
File existingDetections.cc.patch, 2.8 KB (added by , 15 years ago) |
---|
-
src/Cubes/existingDetections.cc
53 53 return FAILURE; 54 54 } 55 55 56 std::cout << " Reading from logfile : " << this->par.getLogFile() << "\n";56 std::cout << " Reading from logfile : " << this->par.getLogFile() << "\n"; 57 57 58 58 std::string temp,filename; 59 59 std::stringstream ss; 60 60 61 61 // first check filename, just to be sure 62 while(getline(logfile,temp), temp.substr(0,11)!="Image to be"){}62 while(getline(logfile,temp), (temp.size()<11 || temp.substr(0,11)!="Image to be")){} 63 63 ss.str(temp); 64 64 ss >> temp >> temp >> temp >> temp>> temp >> filename; 65 65 if(filename != this->par.getFullImageFile()){ … … 71 71 } 72 72 73 73 // read down until first Detection # line 74 while(getline(logfile,temp), temp.substr(0,9)!="Threshold"){} 74 while(getline(logfile,temp), (temp.size()<9 || temp.substr(0,9)!="Threshold")){ 75 } 75 76 float threshold,middle,spread; 76 77 bool robust; 77 logfile >> threshold >> middle >> spread >> robust; 78 std::cout << "Detection threshold used was " << threshold << "\n"; 78 getline(logfile,temp); 79 std::stringstream dataline; 80 dataline.str(temp); 81 dataline >> threshold >> middle >> spread >> robust; 82 std::cout << " Detection threshold used was " << threshold << "\n"; 79 83 this->Stats.setRobust(robust); 80 84 this->Stats.setThreshold(threshold); 81 85 this->Stats.setMiddle(middle); … … 86 90 while(!logfile.eof()){ 87 91 Detection obj; 88 92 while(getline(logfile,temp), temp.substr(0,3)!="---"){ 89 for(uint i=0;i<temp.size();i++) 90 if(temp[i]=='-' || temp[i]==',') temp[i] = ' '; 91 std::stringstream ss; 92 ss.str(temp); 93 ss >> x1 >> x2 >> ypix >> zpix; 94 Scan scn(ypix,x1,x2-x1+1); 95 obj.pixels().addScan(scn,zpix); 93 if(temp.substr(0,9)!="Detection"){ 94 for(uint i=0;i<temp.size();i++) 95 if(temp[i]=='-' || temp[i]==',') temp[i] = ' '; 96 std::stringstream ss; 97 ss.str(temp); 98 ss >> x1 >> x2 >> ypix >> zpix; 99 Scan scn(ypix,x1,x2-x1+1); 100 obj.pixels().addScan(scn,zpix); 101 } 96 102 } 97 103 obj.setOffsets(this->par); 98 obj.calcParams(); 99 if(obj.getSize()>0) this->addObject(obj); 104 if(obj.getSize()>0){ 105 obj.calcParams(); 106 this->addObject(obj); 107 } 100 108 getline(logfile,temp); // reads next line -- should be Detection #... 101 109 if(temp.substr(0,11)!="Detection #"){ 102 110 // if it is, then read two lines to finish off the file. This should trigger the eof flag above. … … 105 113 } 106 114 } 107 115 108 std::cout<<" Final object count = "<<this->objectList->size()<<std::endl;116 std::cout<<" Final object count = "<<this->objectList->size()<<std::endl; 109 117 110 118 return SUCCESS; 111 119