Mercurial > hg > nsaunier > traffic-intelligence
comparison c/test-pixels.cpp @ 8:59b7e3954178
renaming and added make clean
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Sat, 07 Nov 2009 23:33:51 -0500 |
| parents | c/main.cpp@6509f5b1d795 |
| children | eb38637f338d |
comparison
equal
deleted
inserted
replaced
| 7:ffddccfab7f9 | 8:59b7e3954178 |
|---|---|
| 1 #include "opencv/cv.h" | |
| 2 #include "opencv/highgui.h" | |
| 3 | |
| 4 #include <iostream> | |
| 5 | |
| 6 using namespace std; | |
| 7 | |
| 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 | |
| 19 int main(int argc, char *argv[]) { | |
| 20 //cout << "Hello World" << endl; | |
| 21 | |
| 22 CvCapture *inputVideo = cvCaptureFromFile(argv[1]); | |
| 23 | |
| 24 IplImage* frame = cvQueryFrame(inputVideo); | |
| 25 IplImage* bwFrame = allocateImage(cvSize(frame->width, frame->height), IPL_DEPTH_8U, 1); | |
| 26 | |
| 27 int frameNum = 0; | |
| 28 while (frame) { | |
| 29 if (frameNum%10 == 0) | |
| 30 cout << frameNum << endl; | |
| 31 cvConvertImage(frame, bwFrame); | |
| 32 | |
| 33 for (int i=0; i<frame->height; ++i) | |
| 34 for (int j=0; j<frame->width; ++j) | |
| 35 int gray = cvGetReal2D(bwFrame, i, j); | |
| 36 | |
| 37 frame = cvQueryFrame(inputVideo); | |
| 38 frameNum++; | |
| 39 } | |
| 40 | |
| 41 return 1; | |
| 42 } |
