Mercurial > hg > nsaunier > traffic-intelligence
annotate c/cvutils.cpp @ 11:e77e2fd69b02
modularized code (not compiling)
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Wed, 11 Nov 2009 12:01:43 -0500 |
| parents | eb38637f338d |
| children | ff5403319cec |
| rev | line source |
|---|---|
| 9 | 1 #include "cvutils.hpp" |
| 2 | |
| 3 #include "opencv/cv.h" | |
| 4 | |
| 5 #include <iostream> | |
| 6 | |
| 7 using namespace std; | |
| 8 | |
| 9 IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels) { return ::allocateImage(cvSize(width, height), depth, channels);} | |
| 10 | |
| 11 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) { | |
| 12 IplImage* image = cvCreateImage(size, depth, channels); | |
| 13 | |
| 14 if (!image) { | |
| 15 cerr << "Error: Couldn't allocate image. Out of memory?\n" << endl; | |
| 16 exit(-1); | |
| 17 } | |
| 18 | |
| 19 return image; | |
| 20 } | |
|
11
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
21 |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
22 void goToFrameNum(CvCapture* capture, const int& currentFrameNum, const int& targetFrameNum) { |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
23 if (currentFrameNum > targetFrameNum) |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
24 cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl; |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
25 |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
26 for (int frameNum = currentFrameNum; frameNum<targetFrameNum; ++frameNum) { |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
27 IplImage* frame = cvQueryFrame(inputVideo); |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
28 if (!frame) |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
29 break; |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
30 frameNum++; |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
31 } |
|
e77e2fd69b02
modularized code (not compiling)
Nicolas Saunier <nico@confins.net>
parents:
9
diff
changeset
|
32 } |
