# HG changeset patch # User Nicolas Saunier # Date 1313622191 14400 # Node ID 3a11dba306552a5af0f5255b056b5f4dd912e43b # Parent 2a6e7a9a5c53b8f8ed05f274768145538b6595ec added colors diff -r 2a6e7a9a5c53 -r 3a11dba30655 c/cvutils.cpp --- 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];} diff -r 2a6e7a9a5c53 -r 3a11dba30655 include/cvutils.hpp --- 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& kpts, std::vector& 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