changeset 145:7bf8084e720f

removed bug with loadMat and added diagnosis code for empty frames
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 29 Aug 2011 19:20:37 -0400
parents b32947b002da
children 7150427c665e
files c/feature-based-tracking.cpp c/utils.cpp
diffstat 2 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp	Fri Aug 26 19:38:11 2011 -0400
+++ b/c/feature-based-tracking.cpp	Mon Aug 29 19:20:37 2011 -0400
@@ -104,7 +104,7 @@
   capture.open(params.videoFilename);
   if(capture.isOpened()) {
     videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT));
-    cout << "Video " << argv[1] <<
+    cout << "Video " << params.videoFilename <<
       ": width=" << videoSize.width <<
       ", height=" << videoSize.height <<
       ", nframes=" << capture.get(CV_CAP_PROP_FRAME_COUNT) << endl;
@@ -141,8 +141,14 @@
   for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) {
       capture >> frame;
       cout << frameNum << " " << capture.get(CV_CAP_PROP_POS_FRAMES) << " " << prevPts.size() << endl;
-      while (frame.empty())
+      int emptyFrameNum = 0;
+      while (frame.empty()) {
+	cerr << "empty frame " << emptyFrameNum  << " " << capture.get(CV_CAP_PROP_POS_FRAMES)<< endl;
 	capture >> frame;//break;
+	emptyFrameNum++;
+	if (emptyFrameNum>=3000)
+	  exit(0);
+      }
       
       cvtColor(frame, currentFrameBW, CV_RGB2GRAY);
 
--- a/c/utils.cpp	Fri Aug 26 19:38:11 2011 -0400
+++ b/c/utils.cpp	Mon Aug 29 19:20:37 2011 -0400
@@ -10,18 +10,19 @@
 
 vector<vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) {
   ifstream in(filename.c_str());
-  ::openCheck(in, filename, "loadNumbers");
   vector<vector<float> > result;
 
-  while (!in.eof()) {
-    string line = ::getlineComment(in);
-    vector<string> tokens;
-    ::split(tokens, line, separator);
-    vector<float> numbers;
-    BOOST_FOREACH(string s, tokens)
-      numbers.push_back(::toInt(s));
-    if (!numbers.empty())
-      result.push_back(numbers);
+  if (::openCheck(in, filename, "loadNumbers")) {  
+    while (!in.eof()) {
+      string line = ::getlineComment(in);
+      vector<string> tokens;
+      ::split(tokens, line, separator);
+      vector<float> numbers;
+      BOOST_FOREACH(string s, tokens)
+	numbers.push_back(::toInt(s));
+      if (!numbers.empty())
+	result.push_back(numbers);
+    }
   }
 
   return result;