Mercurial Hosting > traffic-intelligence
diff 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 |
line wrap: on
line diff
--- a/c/cvutils.cpp Tue Aug 30 13:04:36 2011 -0400 +++ b/c/cvutils.cpp Tue Aug 30 13:38:31 2011 -0400 @@ -11,7 +11,21 @@ using namespace std; using namespace cv; -cv::Mat loadMat(const string& filename, const string& separator) { +Point2f project(const Point2f& p, const Mat& homography) { + //Mat homogeneous(3, 1, CV_32FC1); + float x, y; + float w = homography.at<float>(2,0)*p.x+homography.at<float>(2,1)*p.y+homography.at<float>(2,2); + if (w != 0) { + x = (homography.at<float>(0,0)*p.x+homography.at<float>(0,1)*p.y+homography.at<float>(0,2))/w; + y = (homography.at<float>(1,0)*p.x+homography.at<float>(1,1)*p.y+homography.at<float>(1,2))/w; + } else { + x = 0; + y = 0; + } + return Point2f(x, y); +} + +Mat loadMat(const string& filename, const string& separator) { vector<vector<float> > numbers = ::loadNumbers(filename, separator); Mat mat;