comparison c/cvutils.cpp @ 12:ff5403319cec

optical flow demo working
author Nicolas Saunier <nico@confins.net>
date Wed, 11 Nov 2009 23:25:23 -0500
parents e77e2fd69b02
children 336926453b28
comparison
equal deleted inserted replaced
11:e77e2fd69b02 12:ff5403319cec
1 #include "cvutils.hpp" 1 #include "cvutils.hpp"
2 2
3 #include "opencv/cv.h" 3 #include "opencv/cv.h"
4 #include "opencv/highgui.h"
4 5
5 #include <iostream> 6 #include <iostream>
6 7
7 using namespace std; 8 using namespace std;
8 9
17 } 18 }
18 19
19 return image; 20 return image;
20 } 21 }
21 22
22 void goToFrameNum(CvCapture* capture, const int& currentFrameNum, const int& targetFrameNum) { 23 int goToFrameNum(CvCapture* inputVideo, const int& currentFrameNum, const int& targetFrameNum) {
23 if (currentFrameNum > targetFrameNum) 24 int frameNum = currentFrameNum;
25 if (currentFrameNum > targetFrameNum) {
24 cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl; 26 cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl;
25 27 } else if (currentFrameNum < targetFrameNum) {
26 for (int frameNum = currentFrameNum; frameNum<targetFrameNum; ++frameNum) {
27 IplImage* frame = cvQueryFrame(inputVideo); 28 IplImage* frame = cvQueryFrame(inputVideo);
28 if (!frame)
29 break;
30 frameNum++; 29 frameNum++;
30 while (frame && frameNum<targetFrameNum) {
31 frame = cvQueryFrame(inputVideo);
32 frameNum++;
33 }
31 } 34 }
35
36 return frameNum;
32 } 37 }