Commits

Nicolas Saunier committed 018653d

corrected bug with empty frames (the program will stop cleanly and store features

Comments (0)

Files changed (1)

c/feature-based-tracking.cpp

   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);