Mercurial Hosting > traffic-intelligence
comparison c/utils.cpp @ 145:7bf8084e720f
removed bug with loadMat and added diagnosis code for empty frames
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 29 Aug 2011 19:20:37 -0400 |
parents | b32947b002da |
children | c8a149fccfda |
comparison
equal
deleted
inserted
replaced
144:b32947b002da | 145:7bf8084e720f |
---|---|
8 | 8 |
9 using namespace std; | 9 using namespace std; |
10 | 10 |
11 vector<vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) { | 11 vector<vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) { |
12 ifstream in(filename.c_str()); | 12 ifstream in(filename.c_str()); |
13 ::openCheck(in, filename, "loadNumbers"); | |
14 vector<vector<float> > result; | 13 vector<vector<float> > result; |
15 | 14 |
16 while (!in.eof()) { | 15 if (::openCheck(in, filename, "loadNumbers")) { |
17 string line = ::getlineComment(in); | 16 while (!in.eof()) { |
18 vector<string> tokens; | 17 string line = ::getlineComment(in); |
19 ::split(tokens, line, separator); | 18 vector<string> tokens; |
20 vector<float> numbers; | 19 ::split(tokens, line, separator); |
21 BOOST_FOREACH(string s, tokens) | 20 vector<float> numbers; |
22 numbers.push_back(::toInt(s)); | 21 BOOST_FOREACH(string s, tokens) |
23 if (!numbers.empty()) | 22 numbers.push_back(::toInt(s)); |
24 result.push_back(numbers); | 23 if (!numbers.empty()) |
24 result.push_back(numbers); | |
25 } | |
25 } | 26 } |
26 | 27 |
27 return result; | 28 return result; |
28 } | 29 } |
29 | 30 |