Mercurial Hosting > traffic-intelligence
changeset 131:3a11dba30655
added colors
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 17 Aug 2011 19:03:11 -0400 |
parents | 2a6e7a9a5c53 |
children | 45c64e68053c |
files | c/cvutils.cpp include/cvutils.hpp |
diffstat | 2 files changed, 42 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/c/cvutils.cpp Wed Aug 17 17:30:30 2011 -0400 +++ b/c/cvutils.cpp Wed Aug 17 19:03:11 2011 -0400 @@ -1,6 +1,6 @@ #include "cvutils.hpp" -//#include "opencv/cv.h" +#include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/features2d/features2d.hpp" @@ -47,3 +47,24 @@ return frameNum; } + +const Scalar Colors::color[] = {Colors::red(), + Colors::green(), + Colors::blue(), + Colors::cyan(), + Colors::magenta(), + Colors::yellow(), + Colors::white(), + Colors::black()}; + +Scalar Colors::black(void) { return Scalar(0,0,0);} +Scalar Colors::red(void) { return Scalar(255,0,0);} +Scalar Colors::green(void) { return Scalar(0,255,0);} +Scalar Colors::blue(void) { return Scalar(0,0,255);} +Scalar Colors::white(void) { return Scalar(255,255,255);} +Scalar Colors::magenta(void) { return Scalar(255,0,255);} +Scalar Colors::cyan(void) { return Scalar(0,255,255);} +Scalar Colors::yellow(void) { return Scalar(255,255,0);} + +Scalar Colors::color3(const int& num) { return Colors::color[num%3];} +Scalar Colors::color8(const int& num) { return Colors::color[num%Colors::nColors];}
--- a/include/cvutils.hpp Wed Aug 17 17:30:30 2011 -0400 +++ b/include/cvutils.hpp Wed Aug 17 19:03:11 2011 -0400 @@ -7,7 +7,6 @@ class CvCapture; /// constant that indicates if the image should be flipped - //static const int flipImage = CV_CVTIMG_FLIP; void keyPoints2Points(const std::vector<cv::KeyPoint>& kpts, std::vector<cv::Point2f>& pts, const bool& clearPts = true); @@ -22,4 +21,24 @@ Returns the frame number that was reached.*/ int goToFrameNum(CvCapture* inputVideo, const int& currentFrameNum, const int& targetFrameNum); +/// Pre-defined colors +class Colors { +public: + static const int nColors = 8; + static const cv::Scalar color[]; + + static cv::Scalar black(void); + static cv::Scalar red(void); + static cv::Scalar green(void); + static cv::Scalar blue(void); + static cv::Scalar white(void); + static cv::Scalar magenta(void); + static cv::Scalar cyan(void); + static cv::Scalar yellow(void); + + /** Maps integers to primary colors. */ + static cv::Scalar color3(const int& num); + static cv::Scalar color8(const int& num); +}; + #endif