Merge pull request #53 from omaralvarez/master
Fix error when parsing label files with unexpected chars
This commit is contained in:
+6
-13
@@ -132,21 +132,14 @@ void BatchStream::readCVimage(std::string inputFileName, std::vector<float>& res
|
|||||||
|
|
||||||
void BatchStream::readLabels(std::string inputFileName, std::vector<float>& ris) {
|
void BatchStream::readLabels(std::string inputFileName, std::vector<float>& ris) {
|
||||||
std::ifstream is(inputFileName.c_str());
|
std::ifstream is(inputFileName.c_str());
|
||||||
//read only the first number: the image sub-portion class
|
|
||||||
while (true) {
|
std::string line;
|
||||||
|
while (std::getline(is, line))
|
||||||
|
{
|
||||||
|
std::istringstream iss(line);
|
||||||
float val;
|
float val;
|
||||||
is >> val;
|
if(!(iss >> val)) { break; } // error
|
||||||
if (!is) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// insert the first number and skip all others
|
|
||||||
ris.push_back(val);
|
ris.push_back(val);
|
||||||
while( true ) {
|
|
||||||
char c;
|
|
||||||
is >> c;
|
|
||||||
if (is.peek() == '\n') //detect "\n"
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user