Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
143:436b87d4b992 | 144:b32947b002da |
---|---|
1 #include "cvutils.hpp" | 1 #include "cvutils.hpp" |
2 #include "utils.hpp" | |
2 | 3 |
3 #include "opencv2/core/core.hpp" | 4 #include "opencv2/core/core.hpp" |
4 #include "opencv2/highgui/highgui.hpp" | 5 #include "opencv2/highgui/highgui.hpp" |
5 #include "opencv2/features2d/features2d.hpp" | 6 #include "opencv2/features2d/features2d.hpp" |
6 | 7 |
7 #include <iostream> | 8 #include <iostream> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 using namespace std; | 11 using namespace std; |
11 using namespace cv; | 12 using namespace cv; |
13 | |
14 cv::Mat loadMat(const string& filename, const string& separator) { | |
15 vector<vector<float> > numbers = ::loadNumbers(filename, separator); | |
16 | |
17 Mat mat; | |
18 | |
19 if (!numbers.empty()) { | |
20 mat = Mat(numbers.size(),numbers[0].size(), CV_32FC1); | |
21 for (unsigned int i=0; i<numbers.size(); i++) | |
22 for (unsigned int j=0; j<numbers[0].size(); j++) | |
23 mat.at<float>(i,j) = numbers[i][j]; | |
24 } | |
25 | |
26 return mat; | |
27 } | |
12 | 28 |
13 void keyPoints2Points(const vector<KeyPoint>& kpts, vector<Point2f>& pts, const bool& clearPts /* = true */) { | 29 void keyPoints2Points(const vector<KeyPoint>& kpts, vector<Point2f>& pts, const bool& clearPts /* = true */) { |
14 if (clearPts) | 30 if (clearPts) |
15 pts.clear(); | 31 pts.clear(); |
16 pts.reserve(kpts.size()); | 32 pts.reserve(kpts.size()); |