Mercurial Hosting > traffic-intelligence
diff c/cvutils.cpp @ 144:b32947b002da
added the code to read matrices from text files
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 26 Aug 2011 19:38:11 -0400 |
parents | 3a11dba30655 |
children | 0089fb29cd26 |
line wrap: on
line diff
--- a/c/cvutils.cpp Wed Aug 24 19:43:44 2011 -0400 +++ b/c/cvutils.cpp Fri Aug 26 19:38:11 2011 -0400 @@ -1,4 +1,5 @@ #include "cvutils.hpp" +#include "utils.hpp" #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" @@ -10,6 +11,21 @@ using namespace std; using namespace cv; +cv::Mat loadMat(const string& filename, const string& separator) { + vector<vector<float> > numbers = ::loadNumbers(filename, separator); + + Mat mat; + + if (!numbers.empty()) { + mat = Mat(numbers.size(),numbers[0].size(), CV_32FC1); + for (unsigned int i=0; i<numbers.size(); i++) + for (unsigned int j=0; j<numbers[0].size(); j++) + mat.at<float>(i,j) = numbers[i][j]; + } + + return mat; +} + void keyPoints2Points(const vector<KeyPoint>& kpts, vector<Point2f>& pts, const bool& clearPts /* = true */) { if (clearPts) pts.clear();