Mercurial Hosting > traffic-intelligence
comparison c/cvutils.cpp @ 147:0089fb29cd26
added projection of points and reprojection for display
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 30 Aug 2011 13:38:31 -0400 |
parents | b32947b002da |
children | 5eeb3b9fb568 |
comparison
equal
deleted
inserted
replaced
146:7150427c665e | 147:0089fb29cd26 |
---|---|
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 using namespace std; | 11 using namespace std; |
12 using namespace cv; | 12 using namespace cv; |
13 | 13 |
14 cv::Mat loadMat(const string& filename, const string& separator) { | 14 Point2f project(const Point2f& p, const Mat& homography) { |
15 //Mat homogeneous(3, 1, CV_32FC1); | |
16 float x, y; | |
17 float w = homography.at<float>(2,0)*p.x+homography.at<float>(2,1)*p.y+homography.at<float>(2,2); | |
18 if (w != 0) { | |
19 x = (homography.at<float>(0,0)*p.x+homography.at<float>(0,1)*p.y+homography.at<float>(0,2))/w; | |
20 y = (homography.at<float>(1,0)*p.x+homography.at<float>(1,1)*p.y+homography.at<float>(1,2))/w; | |
21 } else { | |
22 x = 0; | |
23 y = 0; | |
24 } | |
25 return Point2f(x, y); | |
26 } | |
27 | |
28 Mat loadMat(const string& filename, const string& separator) { | |
15 vector<vector<float> > numbers = ::loadNumbers(filename, separator); | 29 vector<vector<float> > numbers = ::loadNumbers(filename, separator); |
16 | 30 |
17 Mat mat; | 31 Mat mat; |
18 | 32 |
19 if (!numbers.empty()) { | 33 if (!numbers.empty()) { |