Mercurial > hg > nsaunier > traffic-intelligence
comparison c/cvutils.cpp @ 614:5e09583275a4
Merged Nicolas/trafficintelligence into default
| author | Mohamed Gomaa <eng.m.gom3a@gmail.com> |
|---|---|
| date | Fri, 05 Dec 2014 12:13:53 -0500 |
| parents | 1e3c7fe21a38 |
| children | d3e8dd9f3ca4 8ac7f61c6e4f |
comparison
equal
deleted
inserted
replaced
| 598:11f96bd08552 | 614:5e09583275a4 |
|---|---|
| 47 | 47 |
| 48 for (unsigned int i=0; i<kpts.size(); i++) | 48 for (unsigned int i=0; i<kpts.size(); i++) |
| 49 pts.push_back(kpts[i].pt); | 49 pts.push_back(kpts[i].pt); |
| 50 } | 50 } |
| 51 | 51 |
| 52 IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels) { return ::allocateImage(cvSize(width, height), depth, channels);} | 52 // IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels) { return ::allocateImage(cvSize(width, height), depth, channels);} |
| 53 | 53 |
| 54 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) { | 54 // IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) { |
| 55 IplImage* image = cvCreateImage(size, depth, channels); | 55 // IplImage* image = cvCreateImage(size, depth, channels); |
| 56 | 56 |
| 57 if (!image) { | 57 // if (!image) { |
| 58 cerr << "Error: Couldn't allocate image. Out of memory?\n" << endl; | 58 // cerr << "Error: Couldn't allocate image. Out of memory?\n" << endl; |
| 59 exit(-1); | 59 // exit(-1); |
| 60 } | 60 // } |
| 61 | 61 |
| 62 return image; | 62 // return image; |
| 63 } | 63 // } |
| 64 | 64 |
| 65 int goToFrameNum(CvCapture* inputVideo, const int& currentFrameNum, const int& targetFrameNum) { | 65 // int goToFrameNum(CvCapture* inputVideo, const int& currentFrameNum, const int& targetFrameNum) { |
| 66 int frameNum = currentFrameNum; | 66 // int frameNum = currentFrameNum; |
| 67 if (currentFrameNum > targetFrameNum) { | 67 // if (currentFrameNum > targetFrameNum) { |
| 68 cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl; | 68 // cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl; |
| 69 } else if (currentFrameNum < targetFrameNum) { | 69 // } else if (currentFrameNum < targetFrameNum) { |
| 70 IplImage* frame = cvQueryFrame(inputVideo); | 70 // IplImage* frame = cvQueryFrame(inputVideo); |
| 71 frameNum++; | 71 // frameNum++; |
| 72 while (frame && frameNum<targetFrameNum) { | 72 // while (frame && frameNum<targetFrameNum) { |
| 73 frame = cvQueryFrame(inputVideo); | 73 // frame = cvQueryFrame(inputVideo); |
| 74 frameNum++; | 74 // frameNum++; |
| 75 } | 75 // } |
| 76 } | 76 // } |
| 77 | 77 |
| 78 return frameNum; | 78 // return frameNum; |
| 79 } | 79 // } |
| 80 | 80 |
| 81 const Scalar Colors::color[] = {Colors::red(), | 81 const Scalar Colors::color[] = {Colors::red(), |
| 82 Colors::green(), | 82 Colors::green(), |
| 83 Colors::blue(), | 83 Colors::blue(), |
| 84 Colors::cyan(), | 84 Colors::cyan(), |
| 85 Colors::magenta(), | 85 Colors::magenta(), |
| 86 Colors::yellow(), | 86 Colors::yellow(), |
| 87 Colors::white(), | 87 Colors::white(), |
| 88 Colors::black()}; | 88 Colors::black()}; |
| 89 | 89 |
| 90 // Blue, Green, Red | |
| 90 Scalar Colors::black(void) { return Scalar(0,0,0);} | 91 Scalar Colors::black(void) { return Scalar(0,0,0);} |
| 91 Scalar Colors::red(void) { return Scalar(255,0,0);} | 92 Scalar Colors::blue(void) { return Scalar(255,0,0);} |
| 92 Scalar Colors::green(void) { return Scalar(0,255,0);} | 93 Scalar Colors::green(void) { return Scalar(0,255,0);} |
| 93 Scalar Colors::blue(void) { return Scalar(0,0,255);} | 94 Scalar Colors::red(void) { return Scalar(0,0,255);} |
| 94 Scalar Colors::white(void) { return Scalar(255,255,255);} | 95 Scalar Colors::white(void) { return Scalar(255,255,255);} |
| 95 Scalar Colors::magenta(void) { return Scalar(255,0,255);} | 96 Scalar Colors::magenta(void) { return Scalar(255,0,255);} |
| 96 Scalar Colors::cyan(void) { return Scalar(0,255,255);} | 97 Scalar Colors::yellow(void) { return Scalar(0,255,255);} |
| 97 Scalar Colors::yellow(void) { return Scalar(255,255,0);} | 98 Scalar Colors::cyan(void) { return Scalar(255,255,0);} |
| 98 | 99 |
| 99 Scalar Colors::color3(const int& num) { return Colors::color[num%3];} | 100 Scalar Colors::color3(const int& num) { return Colors::color[num%3];} |
| 100 Scalar Colors::color8(const int& num) { return Colors::color[num%Colors::nColors];} | 101 Scalar Colors::color8(const int& num) { return Colors::color[num%Colors::nColors];} |
