changeset 532:018653d1db3c

corrected bug with empty frames (the program will stop cleanly and store features
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 29 Jun 2014 14:18:17 -0400
parents f012a8ad7a0e
children e37f38274d4f
files c/feature-based-tracking.cpp
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp	Fri Jun 27 17:32:11 2014 -0400
+++ b/c/feature-based-tracking.cpp	Sun Jun 29 14:18:17 2014 -0400
@@ -159,15 +159,17 @@
   capture->setFrameNumber(params.frame1);
   for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) {
       bool success = capture->getNextFrame(frame);
+      if (!success || frame.empty() || frame.size() != videoSize) {
+	cout << "Empty frame " << frameNum << ", breaking (" << success << " " << frame.empty() << " " << frame.size() << ")" << endl;
+	break;
+      } else if (frameNum%50 ==0)
+	cout << "frame " << frameNum << endl;
+
       if (params.undistort) {
 	remap(frame, undistortedFrame, map1, map2, interpolationMethod, BORDER_CONSTANT, 0.);
 	frame = undistortedFrame;
       }
-      //if (!success || frame.empty() || frame.size() != videoSize)
-      //break;
 
-      if (frameNum%50 ==0)
-	cout << "frame " << frameNum << endl;
       
       cvtColor(frame, currentFrameBW, CV_RGB2GRAY);