Mercurial Hosting > traffic-intelligence
annotate include/cvutils.hpp @ 144:b32947b002da
added the code to read matrices from text files
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 26 Aug 2011 19:38:11 -0400 |
parents | 47329bd16cc0 |
children | 0089fb29cd26 |
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 |
144
b32947b002da
added the code to read matrices from text files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
139
diff
changeset
|
13 /** Loads a cv mat from a text file where the numbers are saved line by line separated by separator */ |
b32947b002da
added the code to read matrices from text files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
139
diff
changeset
|
14 cv::Mat loadMat(const std::string& filename, const std::string& separator); |
b32947b002da
added the code to read matrices from text files
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
139
diff
changeset
|
15 |
139
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
16 template<typename T> |
47329bd16cc0
cleaned code, added condition on smooth displacement
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
131
diff
changeset
|
17 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
|
18 |
128
536510f60854
new features generated as needed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
127
diff
changeset
|
19 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
|
20 |
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
21 /** Allocates a new IplImage. */ |
9 | 22 IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels); |
23 | |
24 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels); | |
25 | |
12
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
26 /** Goes to the target frame number, by querying frame, |
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
27 supposing the video input is currently at current frame number. |
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
28 Returns the frame number that was reached.*/ |
ff5403319cec
optical flow demo working
Nicolas Saunier <nico@confins.net>
parents:
11
diff
changeset
|
29 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
|
30 |
131 | 31 /// Pre-defined colors |
32 class Colors { | |
33 public: | |
34 static const int nColors = 8; | |
35 static const cv::Scalar color[]; | |
36 | |
37 static cv::Scalar black(void); | |
38 static cv::Scalar red(void); | |
39 static cv::Scalar green(void); | |
40 static cv::Scalar blue(void); | |
41 static cv::Scalar white(void); | |
42 static cv::Scalar magenta(void); | |
43 static cv::Scalar cyan(void); | |
44 static cv::Scalar yellow(void); | |
45 | |
46 /** Maps integers to primary colors. */ | |
47 static cv::Scalar color3(const int& num); | |
48 static cv::Scalar color8(const int& num); | |
49 }; | |
50 | |
9 | 51 #endif |