Mercurial > hg > nsaunier > traffic-intelligence
comparison c/cvutils.cpp @ 804:17e54690af8a dev
work in progress, not fully functional yet
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 01 Jun 2016 17:57:49 -0400 |
| parents | f7cf43b5ad3b |
| children |
comparison
equal
deleted
inserted
replaced
| 803:f7cf43b5ad3b | 804:17e54690af8a |
|---|---|
| 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 Point2f project(const Point2f& p, const Mat& homography) { | 14 // Point2f project(const Point2f& p, const Mat& homography) { |
| 15 //Mat homogeneous(3, 1, CV_32FC1); | 15 // float x, y; |
| 16 float x, y; | 16 // float w = homography.at<float>(2,0)*p.x+homography.at<float>(2,1)*p.y+homography.at<float>(2,2); |
| 17 float w = homography.at<float>(2,0)*p.x+homography.at<float>(2,1)*p.y+homography.at<float>(2,2); | 17 // if (w != 0) { |
| 18 if (w != 0) { | 18 // x = (homography.at<float>(0,0)*p.x+homography.at<float>(0,1)*p.y+homography.at<float>(0,2))/w; |
| 19 x = (homography.at<float>(0,0)*p.x+homography.at<float>(0,1)*p.y+homography.at<float>(0,2))/w; | 19 // y = (homography.at<float>(1,0)*p.x+homography.at<float>(1,1)*p.y+homography.at<float>(1,2))/w; |
| 20 y = (homography.at<float>(1,0)*p.x+homography.at<float>(1,1)*p.y+homography.at<float>(1,2))/w; | 20 // } else { |
| 21 } else { | 21 // x = 0; |
| 22 x = 0; | 22 // y = 0; |
| 23 y = 0; | 23 // } |
| 24 } | 24 // return Point2f(x, y); |
| 25 return Point2f(x, y); | 25 // } |
| 26 } | |
| 27 | 26 |
| 28 Mat loadMat(const string& filename, const string& separator) { | 27 Mat loadMat(const string& filename, const string& separator) { |
| 29 vector<vector<float> > numbers = ::loadNumbers(filename, separator); | 28 vector<vector<float> > numbers = ::loadNumbers(filename, separator); |
| 30 | 29 |
| 31 Mat mat; | 30 Mat mat; |
