Mercurial > hg > nsaunier > traffic-intelligence
annotate include/cvutils.hpp @ 142:a3532db00c28
added code to write velocities
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 24 Aug 2011 02:12:06 -0400 |
| parents | 47329bd16cc0 |
| children | b32947b002da |
| rev | line source |
|---|---|
| 9 | 1 #ifndef CVUTILS_HPP |
| 2 #define CVUTILS_HPP | |
| 3 | |
|
126
336926453b28
added conversion function from keypoint vector to point vector and cleaned headers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
70
diff
changeset
|
4 #include "opencv2/core/core.hpp" |
|
336926453b28
added conversion function from keypoint vector to point vector and cleaned headers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
70
diff
changeset
|
5 #include "opencv2/features2d/features2d.hpp" |
| 9 | 6 |
|
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
7 class CvCapture; |
|
139
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
8 //template<typename T> class Point_<T>; |
|
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
9 |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
10 /// constant that indicates if the image should be flipped |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
11 //static const int flipImage = CV_CVTIMG_FLIP; |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
12 |
|
139
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
13 template<typename T> |
|
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
14 float scalarProduct(const cv::Point_<T>& v1, const cv::Point_<T>& v2) { return v1.x*v2.x+v1.y*v2.y;} |
|
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
15 |
|
128
536510f60854
new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
127
diff
changeset
|
16 void keyPoints2Points(const std::vector<cv::KeyPoint>& kpts, std::vector<cv::Point2f>& pts, const bool& clearPts = true); |
|
126
336926453b28
added conversion function from keypoint vector to point vector and cleaned headers
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
70
diff
changeset
|
17 |
|
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
18 /** Allocates a new IplImage. */ |
| 9 | 19 IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels); |
| 20 | |
| 21 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels); | |
| 22 | |
|
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
23 /** Goes to the target frame number, by querying frame, |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
24 supposing the video input is currently at current frame number. |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
25 Returns the frame number that was reached.*/ |
|
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
26 int goToFrameNum(CvCapture* inputVideo, const int& currentFrameNum, const int& targetFrameNum); |
|
11
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
27 |
| 131 | 28 /// Pre-defined colors |
| 29 class Colors { | |
| 30 public: | |
| 31 static const int nColors = 8; | |
| 32 static const cv::Scalar color[]; | |
| 33 | |
| 34 static cv::Scalar black(void); | |
| 35 static cv::Scalar red(void); | |
| 36 static cv::Scalar green(void); | |
| 37 static cv::Scalar blue(void); | |
| 38 static cv::Scalar white(void); | |
| 39 static cv::Scalar magenta(void); | |
| 40 static cv::Scalar cyan(void); | |
| 41 static cv::Scalar yellow(void); | |
| 42 | |
| 43 /** Maps integers to primary colors. */ | |
| 44 static cv::Scalar color3(const int& num); | |
| 45 static cv::Scalar color8(const int& num); | |
| 46 }; | |
| 47 | |
| 9 | 48 #endif |
