Mercurial > hg > nsaunier > traffic-intelligence
comparison c/Feature.cpp @ 132:45c64e68053c
added drawing function for features
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 17 Aug 2011 19:03:25 -0400 |
| parents | 4742b2b6d851 |
| children | 63dd4355b6d1 |
comparison
equal
deleted
inserted
replaced
| 131:3a11dba30655 | 132:45c64e68053c |
|---|---|
| 1 #include "Feature.hpp" | 1 #include "Feature.hpp" |
| 2 | 2 |
| 3 #include "opencv2/core/core.hpp" | 3 #include "opencv2/core/core.hpp" |
| 4 #include "opencv2/highgui/highgui.hpp" | |
| 4 | 5 |
| 5 using namespace std; | 6 using namespace std; |
| 6 using namespace cv; | 7 using namespace cv; |
| 8 | |
| 9 FeatureTrajectory::FeatureTrajectory(const int& frameNum, const cv::Point2f& p) { | |
| 10 addPoint(frameNum, p); | |
| 11 } | |
| 7 | 12 |
| 8 void FeatureTrajectory::addPoint(const int& frameNum, const Point2f& p) { | 13 void FeatureTrajectory::addPoint(const int& frameNum, const Point2f& p) { |
| 9 positions.add(frameNum, p); | 14 positions.add(frameNum, p); |
| 10 computeMotionData(frameNum); | 15 computeMotionData(frameNum); |
| 11 } | 16 } |
| 17 | |
| 18 #ifdef USE_OPENCV | |
| 19 /// \todo add option for anti-aliased drawing, thickness | |
| 20 void FeatureTrajectory::draw(Mat& img, const Scalar& color) const { | |
| 21 Point2f p1 = positions[0]; | |
| 22 for (unsigned int i=1; i<positions.size(); i++) { | |
| 23 Point2f p2 = positions[i]; | |
| 24 line(img, p1, p2, color, 1); | |
| 25 p1 = p2; | |
| 26 } | |
| 27 } | |
| 28 #endif | |
| 12 | 29 |
| 13 // protected | 30 // protected |
| 14 | 31 |
| 15 void FeatureTrajectory::computeMotionData(const int& frameNum) { | 32 void FeatureTrajectory::computeMotionData(const int& frameNum) { |
| 16 unsigned int nPositions = positions.size(); | 33 unsigned int nPositions = positions.size(); |
