Mercurial Hosting > traffic-intelligence
diff c/utils.cpp @ 1002:6c5ce3ec497e
improved handling of path for feature based tracking
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 01 Jun 2018 17:19:24 -0400 |
parents | bee0e7407af7 |
children |
line wrap: on
line diff
--- a/c/utils.cpp Wed May 30 14:44:08 2018 -0400 +++ b/c/utils.cpp Fri Jun 01 17:19:24 2018 -0400 @@ -1,10 +1,13 @@ #include "utils.hpp" #include <boost/foreach.hpp> +#include <boost/filesystem.hpp> #include <iostream> #include <fstream> +namespace fs = boost::filesystem; // soon std + using namespace std; std::vector<std::vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) { @@ -27,6 +30,15 @@ return result; } +std::string getRelativeFilename(const std::string& parentDirname, const std::string& filename) { + fs::path parentPath(parentDirname); + fs::path filePath(filename); + if (filePath.is_absolute()) + return filename; + else + return (parentPath/filePath).string(); +} + int toInt(const std::string& s) { int i; fromString(i, s); return i;} //atoi float toFloat(const std::string& s) { float x; fromString(x, s); return x;}// lexical_cast<float>(s)