changeset 11:e77e2fd69b02

modularized code (not compiling)
author Nicolas Saunier <nico@confins.net>
date Wed, 11 Nov 2009 12:01:43 -0500
parents 068cf45c3f1b
children ff5403319cec
files c/cvutils.cpp c/optical-flow.cpp include/cvutils.hpp
diffstat 3 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/c/cvutils.cpp	Mon Nov 09 01:56:25 2009 -0500
+++ b/c/cvutils.cpp	Wed Nov 11 12:01:43 2009 -0500
@@ -18,3 +18,15 @@
 
   return image;
 }
+
+void goToFrameNum(CvCapture* capture, const int& currentFrameNum, const int& targetFrameNum) {
+  if (currentFrameNum > targetFrameNum)
+    cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl;
+
+  for (int frameNum = currentFrameNum; frameNum<targetFrameNum; ++frameNum) {
+    IplImage* frame = cvQueryFrame(inputVideo);
+    if (!frame)
+      break;
+    frameNum++;
+  }
+}
--- a/c/optical-flow.cpp	Mon Nov 09 01:56:25 2009 -0500
+++ b/c/optical-flow.cpp	Wed Nov 11 12:01:43 2009 -0500
@@ -21,19 +21,12 @@
   time_t seconds;
   time_t t0 = time(NULL);
   while (frame) {
-    if (frameNum%1000 == 0) {
-      seconds = time(NULL)-t0;
+    ::goToFrameNum(capture, frameNum, frameNum+1000);
+    seconds = time(NULL)-t0;
 
-      cout << frameNum << " " << seconds << endl;
-    }
-//     cvConvertImage(frame, bwFrame);
-    
-//     for (int i=0; i<frame->height; ++i)
-//       for (int j=0; j<frame->width; ++j)
-// 	int gray = cvGetReal2D(bwFrame, i, j);
+    cout << frameNum << " " << seconds << endl;
 
-    frame = cvQueryFrame(inputVideo);
-    frameNum++;
+    frameNum+=1000;
   }
 
   return 1;
--- a/include/cvutils.hpp	Mon Nov 09 01:56:25 2009 -0500
+++ b/include/cvutils.hpp	Wed Nov 11 12:01:43 2009 -0500
@@ -7,4 +7,6 @@
 
 IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels);
 
+void goToFrameNum(CvCapture* capture, const int& currentFrameNum, const int& targetFrameNum);
+
 #endif