Mercurial > hg > nsaunier > traffic-intelligence
comparison c/test-pixels.cpp @ 9:eb38637f338d
created cvutils
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Sun, 08 Nov 2009 10:33:41 -0500 |
| parents | 59b7e3954178 |
| children |
comparison
equal
deleted
inserted
replaced
| 8:59b7e3954178 | 9:eb38637f338d |
|---|---|
| 1 #include "cvutils.hpp" | |
| 2 | |
| 1 #include "opencv/cv.h" | 3 #include "opencv/cv.h" |
| 2 #include "opencv/highgui.h" | 4 #include "opencv/highgui.h" |
| 3 | 5 |
| 4 #include <iostream> | 6 #include <iostream> |
| 5 | 7 |
| 6 using namespace std; | 8 using namespace std; |
| 7 | 9 |
| 8 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) { | |
| 9 IplImage* image = cvCreateImage(size, depth, channels); | |
| 10 | |
| 11 if (!image) { | |
| 12 cerr << "Error: Couldn't allocate image. Out of memory?\n" << endl; | |
| 13 exit(-1); | |
| 14 } | |
| 15 | |
| 16 return image; | |
| 17 } | |
| 18 | 10 |
| 19 int main(int argc, char *argv[]) { | 11 int main(int argc, char *argv[]) { |
| 20 //cout << "Hello World" << endl; | 12 //cout << "Hello World" << endl; |
| 21 | 13 |
| 22 CvCapture *inputVideo = cvCaptureFromFile(argv[1]); | 14 CvCapture *inputVideo = cvCaptureFromFile(argv[1]); |
| 23 | 15 |
| 24 IplImage* frame = cvQueryFrame(inputVideo); | 16 IplImage* frame = cvQueryFrame(inputVideo); |
| 25 IplImage* bwFrame = allocateImage(cvSize(frame->width, frame->height), IPL_DEPTH_8U, 1); | 17 IplImage* bwFrame = allocateImage(frame->width, frame->height, IPL_DEPTH_8U, 1); |
| 26 | 18 |
| 27 int frameNum = 0; | 19 int frameNum = 0; |
| 28 while (frame) { | 20 while (frame) { |
| 29 if (frameNum%10 == 0) | 21 if (frameNum%10 == 0) |
| 30 cout << frameNum << endl; | 22 cout << frameNum << endl; |
